Colleagues
I have encountered unexpected behavior manifested through the quit command (version 8 in both Linux and Windows Vista). Basically, I want to exit a script when certain conditions occur. The file testfile does not exist so the loop is entered. Having executed the q() command, I expected the final cat statement to not be executed (which is the case in R). I have solved the particular situation in which this occurred. However, I am interested in understanding why Splus behaves this way. It appears to be that the problem resides in how the contents of the loop are executed: if the three commands presently in the loop appear outside of the loop, the quit commands is executed at the time that it is called. So, it appears that Splus executes all the contents of the loop before the quit is implemented whereas R executes the commands in sequence.
if (!file.exists("testfile")) { cat("This could should be executed\n") q(n=1) cat("This command should never be executed\n") }
Also, n=1 in the q() command returns "status". In Linux, this can be recovered at the command line with echo $status. However, I can't get this to work in Windows (i.e., %status% does not contain the value) and I have been led to believe that this command is not implemented in Windows. Has anyone been successful with this?
Dennis
Dennis Fisher MD P < (The "P Less Than" Company) Phone: 1-866-PLessThan (1-866-753-7784) Fax: 1-415-564-2220 www.PLessThan.com
|