*! version 1.0.1 JPR 9-Mar-93 updated 12-Mar-93. program define lexport version 3.0 local tmpfile "_lexport.dta" parse "`*'", parse(" ,") if "`*'"=="" | "`1'"=="," { error 198 } local fn "`1'" mac shift local options "REPLACE" /* mean the same thing */ parse "`*'" local cmd "$S_LEXPO" local suffix "$S_LEXPO2" if "`cmd'"=="" { local cmd "c:\st\transfer" } if "`suffix'"=="" { local suffix "> nul" } capture confirm file `cmd'.exe if _rc { capture confirm file `cmd'.com if _rc { capture confirm file `cmd'.bat if _rc { di in red "I cannot find Stat/Transfer (`cmd')" exit 799 } } } /* Old code (WWG) fails (a) because replace!="" shd be replace=="" and (b) because Stata may create a 0-length read-only file as a result of the "confirm new file" command. if "`replace'"!="" { confirm new file `fn'.wk1 } else { capture erase `fn'.wk1 } Replacement code works the other way around. */ if "`replace'"=="" { capture confirm file `fn'.wk1 if !_rc { di in red "file `fn'.wk1 already exists" exit 602 } } capture erase `fn'.wk1 /* command set up */ /* execute command */ local sfn "$S_FN" quietly save `tmpfile', replace capture { ! `cmd' `tmpfile' `fn'.wk1 `suffix' } local rc=_rc mac def S_FN "`sfn'" capture erase `tmpfile' /* diagnose result */ if `rc'==1 { /* user pressed break.. */ capture erase `fn'.wk1 exit 1 } if `rc'==0 { /* all okay (maybe) */ capture confirm file `fn'.wk1 if _rc==0 { di in blu "(Lotus-format file `fn'.wk1 saved)" exit } } /* Problems */ di in red "I temporarily saved your data as `tmpfile'." di in red "I then issued the command:" _n di in red " `cmd' `tmpfile' `fn'.wk1 `suffix'" _n if `rc' { di in red "and got back a return code of `rc'." capture confirm file `fn'.wk1 if _rc==0 { di in red "The file `fn'.wk1 exists," di in red "so I do not know what to make of it." } else { di in red "The file `fn'.wk1 was not created." } exit `rc' } di in red "The file `fn'.wk1 was not created." exit 799 end exit comments: $S_LEXPO is the transfer command, default "transfer" $S_LEXPO2 is the suffix, default "> nul" The command is assumed to be: $S_LEXPO fn.dta fn.wk1 $S_LEXPO2 e.g., transfer _lexport.dta fn.wk1 > nul