s-news
[Top] [All Lists]

Re: Unexpected behavior within a script ; returning "status" to the oper

To: Dennis Fisher <fisher@plessthan.com>, s-news@lists.biostat.wustl.edu
Subject: Re: Unexpected behavior within a script ; returning "status" to the operating system
From: mats pistol <mats_pistol@yahoo.com>
Date: Sat, 1 Dec 2007 16:59:49 +0000 (GMT)
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=iad/xZx2LzvgTVNOIzu0ZMiiiEoJE5dQ+xz82+RwRIlKl0HIWj7fTyJAJg/Vf9Tu2KG5JL9hRSvv6oBrRwxwyi7I/xPwdZuLN5mfMnF8knVXtl4StsKsZBWe4dTK9iVnD8PlViHnST2iQrsq4MNm3asRhSWYnDq2AhLyH/UZr20=;
In-reply-to: <DE733F60-A27F-425C-9BAA-71BF56221C8C@plessthan.com>
I have seen the same type of behaviour with S+ v6 and
v7 in loops; S+ does execute commands which should not
be executed.

Your summary example is very good;

I have had this problem occur in Calculations which
affect the final answer!!  Nowadays I festoon S+ code
with numerous checks to catch this type of problem.

You have raised a critical issue which has, for some
time, damaged my confidence in S+. 
Repeated suggestions to Insightful have been met with
'its difficult'.


--- Dennis Fisher <fisher@plessthan.com> wrote:

> 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
> 
> 



      __________________________________________________________
Sent from Yahoo! - the World's favourite mail http://uk.mail.yahoo.com


<Prev in Thread] Current Thread [Next in Thread>