* 6 October (10) 1991 (12:33) * (c) Marc Jacobs, Utrecht, The Netherlands ( Telefax: 31 30 53 44 05) * ( E-mail: CUSMAR@CC.RUU.NL) * * Menu maker in STATA * Features 1: Is there a dataset in memory? Save it or drop it? * 2: Test validity of choice, can be more sophisticated * Problems 1: Pause in program? (via DOS shell it is possible) * 2: Clear screen in Stata (now via the DOS shell, unelegant) * 3: Displaying ASCII > 128 seems impossible * Trying 1: Calling other programs or do-files program define t_menu version 2.1 capture confirm existence %S_FN if (_rc~=6) { !cls mac def _bad 1 while %_bad { di in bl "WARNING! " in gr "Current data set in use is %S_FN" di in gr "Do you want me to save it first?" _n di in ye _col(15) "1" in bl " - SAVE " in gr "%S_FN" di in ye _col(15) "2" in bl " - DROP " in gr "%S_FN" di _newline(2) in gr "Your choice? " _request(_dr_sv) if ("%_dr_sv" == "1") { save, replace capture drop _all capture label drop _all mac def _bad 0 } else if ("%_dr_sv" == "2") { capture drop _all capture label drop _all mac def _bad 0 } } } mac def _cont 1 while %_cont { !cls /* schoon het scherm, via de shell */ /* zet het woord menu in het midden neer */ disp in ye _col(38) " MENU " disp _n(3) disp in ye _col(15) "1" in gr " - Prepare data set 1" disp in ye _col(15) "2" in gr " - Prepare data set 2" disp in ye _col(15) "3" in gr " - Prepare data set 3" disp in ye _col(15) "4" in gr " - Option 4" disp in ye _col(15) "5" in gr " - Option 5" disp in ye _col(15) "6" in gr " - Option 6" disp in ye _col(15) "7" in gr " - Option 7" disp in ye _col(15) "8" in gr " - Option 8" disp in ye _col(15) "9" in gr " - Just quit" disp _newline(1) disp in gr "make choice " _request(_choice) if "%_choice" == "1" { disp in bl "Preparing data set 1 for analyses" /* Stata commands */ } else if "%_choice" == "2" { disp in bl "Preparing data set 2 for analyses" /* Stata commands */ } else if "%_choice" == "3" { disp in bl "Preparing data set 3 for analyses" /* Stata commands */ } else if "%_choice" == "4" { } else if "%_choice" == "5" { } else if "%_choice" == "6" { } else if "%_choice" == "7" { } else if "%_choice" == "8" { } else if "%_choice" == "9" { disp in bl "Bye bye" exit } else { disp _newline(2) disp in bl "WARNING!" in gr /* */ " Choice not valid, choose number smaller then 9." !pause } } end