This code fragment compiles ok, but errors at runtime:
Code:
EXPORT test()
BEGIN
local A,J1,T1,KT;
KT:={2.5, pi,3.79,4.22};
J1:=1;
T1:=MAKELIST(A,A,KT(J1),1.5*PI,((1.5*PI-KT(J1))/51));
END;
Yet, when KT, J1, and T1 are entered in the HOME command line individually, they work just fine. Something in the MAKELIST(...) is troublesome, but what?
Ideas?
-Dale-
It appears that MAKELIST expects the variable to be a global variable A and not a local variable A. Remove A from the list of local variables and your program runs fine. When you use A as a local variable, I believe it substitutes the current value of A into the command (which is presumably 0). So the program essentially does: MAKELIST(0,0,blah...)
Thanks, I tried many things, and it has been driving me nuts all day!
-Dale-
This may even be a bug since A here is supposed to be a dummy variable in how it is used in MAKELIST.
I'm pretty sure there's a bug or two with makelist. It behaved differently in home, cas, and ppl. I was too tired to write it up and submit it!
(01-11-2015 01:25 AM)DrD Wrote: [ -> ]I'm pretty sure there's a bug or two with makelist. It behaved differently in home, cas, and ppl. I was too tired to write it up and submit it!
Well, there is a different makelist() function in CAS. MAKELIST() is different from makelist().
MAKELIST(expression, var, start, stop, step): when used in Home view, expression must be in terms of global variables, and var must be a global variable. When used in the CAS view, the command must be manually typed in upper case; var may be any undefined variable. The result is a list delimited by {}.
makelist(function, start, stop, step): a command similar to MAKELIST but designed for CAS use; returns a CAS list delimited by []. The function must be a valid CAS function, either defined in the CAS (e.g. f(x):=x^2, then simply use f as the argument or x->x^2).
When in CAS mode, selecting MAKELIST from the catalog actually produces makelist and uses the makelist() function. You have to manually type MAKELIST in upper case since the catalog auto-switches to lower case when in CAS mode.
In non-CAS PPL, most functions (generally speaking) are assumed to be upper case even when typed in lower case because PPL programs are assumed to be running in Home View. Thus typing makelist() in a non-CAS PPL program will be interpreted as MAKELIST()
While working with the difficulty the MAKELIST() command had become for me, I tried many things. The code fragment I presented was just the last 'box' I found myself in.
You are right about needing a global for the dummy var for the MAKELIST() parameters, however that did not resolve my problem. On the command line I could manually enter the MAKELIST() command and it worked. Programmatically, it would cause an error.
Using a global, I could get the full program to work on the emulator, but it would NOT work on the physical device. I trimmed my full program to just a shortened fragment containing the MAKELIST() segment, wherein I used the length() command. It turned out that the length() command would not work on the physical device, programmatically OR on the command line, either.
In short, I did the "C-F-O" ON reset, and it fixed the problems. The program now runs in both environments as hoped. The state of the physical machine had become corrupted in some way.
Not my first encounter with this sort of issue ...
When you say C-F-O reset, do you mean that you formatted the memory of the "c:" drive? Or that you rebooted into C-F-O and then pressed 9 to reset?
If the latter, just doing the "warm start" of on-symb to do a full boot up sequence would have done the same thing to my knowledge.
I used the "C-F-O ON" '9. Reset' from the list of options. At the end of a tiring day, filled with largely unsuccessful efforts, it was the next thing that occurred to me.
I didn't try "On-Sym" but I will try to remember that for the rigors of my next adventure!
That is basically equivalent to ON-F3 on the 50g (a full reboot). Just don't hold on to SYMB too long or you end up in the bootloader updater...