{{tag>category:"AREV32" author:"Robert Heard" author:"Andrew McAuley"}} [[https://www.revelation.com/the-works|Join The Works program to have access to the most current content, and to be able to ask questions and get answers from Revelation staff and the Revelation community]] ==== Curious compiler conundrum (AREV32) ==== === At 22 JAN 2024 09:07:38PM Robert Heard wrote: === Hello AREV32 techies, I was trying to work out limits on decimal places during calculations. I used a simple loop wherein I kept dividing a variable by 10. Such odd results for such a simple program! I had been using EVAL at TCL, so I emulated this in a program called TEST_FRACTION. Program code below. I am hoping that someone with inside knowledge will be able to advise what is happening? I had stuck in a check on STATUS() thinking this might have been set, but it seems to have made things worse. In only the most basic program (Test 5), did I get the full 20 lines expected. Since when does a FOR loop abort without any kind of message? I'm hoping I've used this "code" reference correctly. Could not see a way to attach anything to this. Also, if someone can point me to info regarding decimal limits and/or "precision" calculations, that would be most helpful. Robert PRINT @(-1): PRINT "TEST 1: FOR I=1 TO 20; A=A/10; PRINT I,A,B" EXECUTE "EVAL A=1; FOR I = 1 TO 20; A=A/10; IF A=0 THEN B=0 ELSE B=A; PRINT I,A,B; NEXT I" * Yields only 5 lines, then "Press any key to continue...". INPUT CONT PRINT "TEST 2: FOR I=1 TO 20; A=A/10; PRINT I,A,B; PRINT 'FINISHED'" EXECUTE "EVAL A=1; FOR I = 1 TO 20; A=A/10; IF A=0 THEN B=0 ELSE B=A; PRINT I,A,B; NEXT I; PRINT 'FINISHED'" * Yields only 5 lines, 'FINISHED', then "Press any key to continue...". INPUT CONT PRINT "TEST 3: FOR I=1 TO 20; A=A/10; C=STATUS(); PRINT C; PRINT I,A,B" EXECUTE "EVAL A=1; FOR I = 1 TO 20; A=A/10; C=STATUS(); IF C THEN PRINT I:' STATUS=':C; IF A=0 THEN B=0 ELSE B=A; PRINT I,A,B; NEXT I" * Yields NO results, only "Press any key to continue..." INPUT CONT PRINT "TEST 4: FOR I=1 TO 20; A=A/10; C=STATUS(); PRINT C; PRINT I,A,B; PRINT 'FINISHED'" EXECUTE "EVAL A=1; FOR I = 1 TO 20; A=A/10; C=STATUS(); IF C THEN PRINT I:' STATUS=':C; IF A=0 THEN B=0 ELSE B=A; PRINT I,A,B; NEXT I; PRINT 'FINISHED'" * Yields only FINISHED', then "Press any key to continue...". INPUT CONT PRINT "TEST 5: A=1; FOR I=1 TO 20; PRINT I,A; PRINT 'FINISHED'" EXECUTE "EVAL A=1; FOR I = 1 TO 20; PRINT I,A; NEXT I; PRINT 'FINISHED'" * Yields 20 lines, 'FINISHED', then "Press any key to continue...". INPUT CONT PRINT "TEST 6: A=1.000; FOR I=1 TO 20; A=_DIVX(A,10.000,8); PRINT I,A,B" EXECUTE "EVAL A=1.000; FOR I = 1 TO 20; A=_DIVX(A,10.000,8); IF A=0 THEN B=0 ELSE B=A; PRINT I,A,B; NEXT I" * Yields only 4 lines with 8 decimal places, then "Press any key..." INPUT CONT END ---- === At 23 JAN 2024 03:21AM Andrew McAuley wrote: === Semi-colons mean "continue the line". So everything after the else belongs to the else. Why do it in such a tortuous fashion? Why not just write the program instead of executing an eval? Then your else clauses can be ended. For precision [url=https://revdevx.com/tag/extended-precision/]see here.[/url] [url=https://www.sprezzatura.com]The Sprezzatura Group[/url] [url=https://www.sprezzatura.com/blog]The Sprezzatura Blog[/url] [i]World leaders in all things RevSoft[/i] [img]https://www.sprezzatura.com/zz.gif[/img] ---- === At 23 JAN 2024 07:19PM Robert Heard wrote: === Thanks Andrew, Loving the sound of the SetEPMode routine. Now we've got some control! You don't state within your example when compare "a < 1", how to NOT have it revert to DOUBLE LONG. Can I assume that by using "_CMPX" will retain EXTENDED precision? As for the "tortuous" method used, I was curious to see if there are any differences between running a program and using EVAL at TCL. Yet to be determined. At the first stage, I wanted to confirm that I got the same results as using EVAL at TCL. Will revert to using standard code in RBasic program to see if gives me for insight. As for use of ";" in a line of code when using EVAL, I have found that the way to avert all of remaining code following an ELSE clause was to use as: IF cond1 THEN; [these stmts; fall; within; THEN;] END ELSE; [these stmts; fall; within; ELSE;] END; remaining stmts; executed; in; sequence. Robert. ---- === At 24 JAN 2024 05:02AM Andrew McAuley wrote: === Yes, expand semi colons to field marks and that makes perfect sense :) [url=https://www.sprezzatura.com]The Sprezzatura Group[/url] [url=https://www.sprezzatura.com/blog]The Sprezzatura Blog[/url] [i]World leaders in all things RevSoft[/i] [img]https://www.sprezzatura.com/zz.gif[/img] ---- === At 09 FEB 2024 10:27PM Robert Heard wrote: === Revisiting this... Have since found that what I thought was an answer to the IF THEN ELSE clause confusion, does not seem to be accurate. I had stated that my solution was to use: IF condition1 THEN; stmt1; stmt2; END ELSE; stmt3; stmt4; END; ... continue with remaining program does NOT work as expected. I have tried to use the Edit Replace function of ";" to @FM (using Ctrl-S and "ASCII table", but yields a null message and "Press any key to continue...". Below is my EVAL statement: EVAL A="HELLO"; IF A[1,1] >= "D" THEN; PRINT ">= D"; END ELSE; PRINT "< D"; END; PRINT "NOW AFTER THE THEN/ELSE CLAUSE"; STOP So the question is, what is MEANT to be the statement separator used in an EVAL command at TCL? Robert. [[https://www.revelation.com/revweb/oecgi4p.php/O4W_HANDOFF?DESTN=O4W_RUN_FORM&INQID=WORKS_READ&SUMMARY=1&KEY=C008D3BC614F9F4581EEC2CC1AFFD85E|View this thread on the Works forum...]]