Quote:
You can do this :
EXPORT Test()
BEGIN
local a;
a:=3.14159;
A:=a;
M1:=EVAL('[[COS(A),0,1],[SIN(A),1,0]]');
END;
This avoid M1 to be evaluated in the compilation time.
EDIT : I saw your edit now ;) In my opinion EVAL is better than EXPR but same result
By the way, it's not very different from the HP50G
Actually, this does _NOT_ work (only tested with matrices) -- with or without the single quotes. In this example, the program is compiled to use whatever the global A value was at the time of compiling. Here's how to test this.
First, store 0 into A before editing the program. Then, edit the program and do nothing to the source code. Just open the editor and then close out the editor with the [ESC] key. Then run the program. You would expect something close to [[-1,0,1],[0,1,0]] but you actually get [[1,0,1],[0,1,0]] because the parser converted the global variable into 0 (the value prior to opening the program editor) upon exiting with [ESC].
But now that you have run the program once (or however many times, it doesn't matter because the value of A was pre-compiled to be 0), go back into the program editor -- open it once and immediately close it. Then re-run the program, and you get the expected [[-1,0,1],[0,1,0]].
The reason is that after your program was initially run, the global variable A was then set to approx. pi, so that upon exiting the editor the second time, the parser compiles the program to use the now-current A value of pi.
Open the editor again (third time) and edit the lower-case 'a' value and you will not see any changes in the output of the program until you "recompile" it by opening and closing the editor a fourth time (to use the updated global variable A).
So the point is you HAVE to use expr(" blah ");
Edited: 25 Sept 2013, 2:33 p.m.