Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exclamation marks in foreach loops

    Hello, everyone.

    I'd like some advice, please.

    I've come across some code by both Brendan Halpin and Alan Riley. It's the second ever posting on this section of the Forum. The code by Brendan is:


    Code:
    foreach topic in topic1 topic2 topic3 {    
         translate `topic'.sthlp `topic'.ps, translator(smcl2ps) replace header(off) logo(off) pagesize(A4)    
         !ps2pdf `topic'.ps    
         !rm `topic'.ps
    }
    and Alan's response is

    Code:
    foreach topic in topic1 topic2 topic3 {    
         translate `topic'.sthlp `topic'.ps, translator(smcl2ps) replace header(off) logo(off) pagesize(A4)    
         !ps2pdf `topic'.ps    
         !rm `topic'.ps
    }
    My question relates to the use of the exclamation mark in the second and third lines of the -foreach- loop.
    Code:
    !ps2pdf `topic'.ps    
    !rm `topic'.ps
    Can someone point me to documentation about the symbol's function? I've trawled through the Stata documentation and the web with more than enough false positive hits.

    Thanks.
    Is there a better way of turning .sthlp files (self-written) into .pdf files than something like the following (assumes unix-y environment): foreach topic in

  • #2
    Code:
    help shell

    Comment


    • #3
      Brilliant.

      Thanks, mate.

      Comment

      Working...
      X