Am I missing some feature of the syntax command, or is this function
provided by a general routine I should call? I'm writing a program that
should provide the standard option to save a .gph graph file. The program
should not run to completion then fail on a technicality, so I use the
following code to validate the option - but can it be more specific than
a "string". This code is either not needed, or may be of use to other
program writers:
syntax ... [ saving(string) ...];
...
* Check saving details
if "`saving'" != "" {
tokenize "`saving'", parse(",")
loc saving "`1'"
if index("`saving'", ".")==0 loc saving "`saving'.gph"
capture confirm file `saving'
if _rc==0 { /* existing file */
if "`3'" != "replace" {
di "Invalid save file - did you mean to replace?"
exit
}
loc saving "`saving',replace"
}
else { /* invalid file - may be new */
capture confirm new file `1'
if _rc!=0 {
di "Invalid save filename"
exit
}
}
}
Constructive comments welcomed.
R. Allan Reese Email: [email protected]
Associate Manager GRI Direct voice: +44 1482 466845
Graduate School Voice messages: +44 1482 466844
Hull University, Hull HU6 7RX, UK. Fax: +44 1482 466436
====================================================================
Be careful in handling the battery of the remote control transmitter
If swallowed consult a physician immediately for emergency treatment
[Safety instructions: Hitachi CP-X275 data projector]
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/