If efficiency is what you're going after (which is not really what I do if I'm showing example code), then it would be more efficient to code:IF editgetdoc() \== '' THEN
RETURN guisay("No document is loaded!") Eliminating the DO/END makes a difference. (Of course, the above assumes that the program running your script doesn't expect your script to return anything. That is true of both Script Launcher and Programmer Center. Otherwise, the program may do something weird with the return of RXSAY).
But, the most efficient thing to do is to set Programmer Center to raise a condition for an error, and utilize CATCH. Then you eliminate all of the error checking after each call:
rexxedheading = 1
rexxederr = 1
editgetdoc()
editgettext('scriptname.')
scriptname = STRIP(scriptname.1)
IF TRANSLATE(FILESPEC('E', scriptname)) \== ".rex" THEN
scriptname = scriptname || '.rex'
editopendoc(scriptname)
CATCH user 1
CONDITION('M') |