Igor Schein on Mon, 10 Mar 2003 13:57:43 -0500


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: problem


On Mon, Mar 10, 2003 at 12:47:57PM -0600, James G. McLaughlin wrote:
> I am using version 2.1.3 for Windows.
> 
> I do not understand why the following code does not work (it is a stripped
> down version of a program I was trying to run, stripped as much as
> possible to still produce the problem):
> 
> {
> k=3;
> print (k);
> d(n)=n^3+n^2+5;
> print (d(5));
> N=10;
> for(i = 3,N, print (i);    );
> }
> 
> It prints "3" as the value for "k" but then does nothing else - it will
> print neither d(5) or any of the "i" values in the "for" loop.
> 
> However, if I remove the braces {} from the ends, it works as it should,
> printing both the value for d(5) and all the values in the "for" loop.
> 
> In the original program, I need the braces because of the program's
> length.
> 
> Does anyone have any suggestions?

Most likely explanation is that your variables are previously defined.
Do kill(k);kill(d);kill(n);kill(N);kill(i) and rerun the segment above
- it'll work.  Alternatively, you can start afresh with gp -f.  

This is a problem with variables that I often run into - in an
involved session chances are you've already used common variables
elsewhere. The safe practice is to declare all local variables as such
in every function using local() call. 

Igor