REPEAT . . . UNTIL loop problem
|
02-13-2021, 10:50 PM
(This post was last modified: 02-13-2021 10:51 PM by cahlucas.)
Post: #1
|
|||
|
|||
REPEAT . . . UNTIL loop problem
Hi all,
This time I have a loop problem that I cannot solve. For a graphics program, I have a REPEAT - UNTIL loop as the outermost program loop to keep the program running until it ends, see the code below. Somewhere in the code, the value 1 is stored in the variable 'exit' when a certain key is pressed. I get a 'syntax error' when I press the menu key 'Cntrl.', whereby the cursor is just in front of the UNTIL. As far as I can tell there is nothing wrong with the code, but I don't understand where that error message is coming from. Maybe someone can give me an idea to solve this problem. I hope to hear from you soon. Sincerely, Karel. Code:
I use HP-16C, WP-34S emulator, HP-35s, HP-48GX, HP-50g, and HP Prime G2. |
|||
02-13-2021, 11:30 PM
Post: #2
|
|||
|
|||
RE: REPEAT . . . UNTIL loop problem
I don't know why you have this syntax error, but I would try two things:
First replace: UNTIL exit==1; by: UNTIL exit; Then if you (likely) still have the same error, replace: REPEAT . . . UNTIL exit==1; by: WHILE exit==0 DO . . . END; |
|||
02-13-2021, 11:32 PM
(This post was last modified: 02-13-2021 11:33 PM by StephenG1CMZ.)
Post: #3
|
|||
|
|||
RE: REPEAT . . . UNTIL loop problem
One possibility when the code looks OK and the variable name is a common name like "exit" - Is it possible that "exit" is a reserved word or used elsewhere?
In such cases you could try a less common name like "ext17" and hope the problem goes away... Hope the Prime experts can suggest something more helpful. Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
02-14-2021, 12:23 AM
Post: #4
|
|||
|
|||
RE: REPEAT . . . UNTIL loop problem
(02-13-2021 11:32 PM)StephenG1CMZ Wrote: One possibility when the code looks OK and the variable name is a common name like "exit" - Is it possible that "exit" is a reserved word or used elsewhere? Dear Mr. Stephen, This is tested by me, and it does not work. Still thanks for your answer. Sincerely, Karel. I use HP-16C, WP-34S emulator, HP-35s, HP-48GX, HP-50g, and HP Prime G2. |
|||
02-14-2021, 12:38 AM
Post: #5
|
|||
|
|||
RE: REPEAT . . . UNTIL loop problem
(02-13-2021 11:30 PM)Didier Lachieze Wrote: I don't know why you have this syntax error, but I would try two things: Dear Mr. Lachieze, Thank you for your answer. The "UNTIL exit" came for the "UNTIL exit == 1;", and it didn't work either. The "WHILE DO END;" loop I have tested, and unfortunately does not work either. Sincerely, Karel. I use HP-16C, WP-34S emulator, HP-35s, HP-48GX, HP-50g, and HP Prime G2. |
|||
02-14-2021, 01:24 AM
(This post was last modified: 02-14-2021 03:27 AM by toml_12953.)
Post: #6
|
|||
|
|||
RE: REPEAT . . . UNTIL loop problem
(02-13-2021 10:50 PM)cahlucas Wrote: Hi all,This works for me. Are you sure you have exit:=1 in a proper conditional? Code:
Tom L Cui bono? |
|||
02-14-2021, 12:16 PM
Post: #7
|
|||
|
|||
RE: REPEAT . . . UNTIL loop problem
(02-13-2021 10:50 PM)cahlucas Wrote: I get a 'syntax error' when I press the menu key 'Cntrl.', whereby the cursor is just in front of the UNTIL ... Possibly syntax error is not from loop, but FREEZE ? (or, whatever before it ?) Just curious, which key is the menu key 'Cntrl' ? |
|||
02-14-2021, 07:46 PM
Post: #8
|
|||
|
|||
RE: REPEAT . . . UNTIL loop problem
(02-14-2021 01:24 AM)toml_12953 Wrote: This works for me. Are you sure you have exit:=1 in a proper conditional? Dear Tom L., Yes, I have the command 'exit:=1;' placed in a correct conditional. The error this thread is about has only recently occurred, before that, the program worked fine. Sincerely, Karel. I use HP-16C, WP-34S emulator, HP-35s, HP-48GX, HP-50g, and HP Prime G2. |
|||
02-14-2021, 07:51 PM
Post: #9
|
|||
|
|||
RE: REPEAT . . . UNTIL loop problem
I think toml_12953 got it right with a missing END in an IF statement or something similar. The IF statement with a missing END can be located anywhere in the repeat until block.
PHP Code: EXPORT Test_Until_1() |
|||
02-14-2021, 07:58 PM
Post: #10
|
|||
|
|||
RE: REPEAT . . . UNTIL loop problem
(02-14-2021 12:16 PM)Albert Chan Wrote: Possibly syntax error is not from loop, but FREEZE ? (or, whatever before it ?) Dear Mr. Chan, The syntax error is not caused by a statement before the UNTIL. All the code there is correct. The 'Cntrl.' (or 'Ctrl.') key is the key where you can check the program for syntax errors. You will find it at the bottom right of the other menu keys, if you have a program open for editing. Maybe ever used it? Sincerely, Karel. I use HP-16C, WP-34S emulator, HP-35s, HP-48GX, HP-50g, and HP Prime G2. |
|||
02-14-2021, 08:09 PM
Post: #11
|
|||
|
|||
RE: REPEAT . . . UNTIL loop problem
(02-14-2021 07:51 PM)Gene222 Wrote: I think toml_12953 got it right with a missing END in an IF statement or something similar. The IF statement with a missing END can be located anywhere in the repeat until block. Dear Mr. Gene, There is no 'END;' statement forgotten. The 'IF-THEN-END' structure is part of a 'CASE' structure that has been carefully constructed, using the menu from 'Tmplt', in the program editor. Sincerely, Karel. I use HP-16C, WP-34S emulator, HP-35s, HP-48GX, HP-50g, and HP Prime G2. |
|||
02-15-2021, 01:40 AM
Post: #12
|
|||
|
|||
RE: REPEAT . . . UNTIL loop problem
(02-14-2021 08:09 PM)cahlucas Wrote:(02-14-2021 07:51 PM)Gene222 Wrote: I think toml_12953 got it right with a missing END in an IF statement or something similar. The IF statement with a missing END can be located anywhere in the repeat until block. If you post the entire program we won't have to guess. Tom L Cui bono? |
|||
02-15-2021, 11:27 AM
Post: #13
|
|||
|
|||
RE: REPEAT . . . UNTIL loop problem
(02-15-2021 01:40 AM)toml_12953 Wrote:(02-14-2021 08:09 PM)cahlucas Wrote: Dear Mr. Gene, REPEAT commands UNTIL test Executes commands UNTIL test is true IF..THEN..END...ELSE is not a command. FOR .... FROM...DO commands CASE IF.... IF END END HP 33C 34C 11C 41CX 12C 15C HP71B 35s 50g Prime Rev. A, C, D. DM 41X, 42. TI 58C, 59, 74, 92-II, Voyage 200, nspire CX II-T, Sanyo ICC 82D and more |
|||
02-15-2021, 01:02 PM
Post: #14
|
|||
|
|||
RE: REPEAT . . . UNTIL loop problem
(02-15-2021 11:27 AM)Wolfgang Wrote:(02-15-2021 01:40 AM)toml_12953 Wrote: If you post the entire program we won't have to guess. That much we know. Obviously, he's either leaving something out of or adding something to his actual program that's causing the problem, though. We'd need to see a copy of the whole program to help him. Tom L Cui bono? |
|||
02-15-2021, 01:25 PM
Post: #15
|
|||
|
|||
RE: REPEAT . . . UNTIL loop problem
(02-15-2021 01:02 PM)toml_12953 Wrote:(02-15-2021 11:27 AM)Wolfgang Wrote: REPEAT commands UNTIL test i repeat: The problem are further nested IF Conditions inside a REPEAT... UNTIL LOOP. This is imho not allowed. Hence syntax errors. HP 33C 34C 11C 41CX 12C 15C HP71B 35s 50g Prime Rev. A, C, D. DM 41X, 42. TI 58C, 59, 74, 92-II, Voyage 200, nspire CX II-T, Sanyo ICC 82D and more |
|||
02-15-2021, 02:43 PM
(This post was last modified: 02-15-2021 02:46 PM by Didier Lachieze.)
Post: #16
|
|||
|
|||
RE: REPEAT . . . UNTIL loop problem
(02-15-2021 01:25 PM)Wolfgang Wrote: The problem are further nested IF Conditions inside a REPEAT... UNTIL LOOP. This is imho not allowed. Hence syntax errors. Well, the program example from the on-calc help for CASE does just that: it includes a CASE statement with several IF THEN END; inside a REPEAT UNTIL loop and there is no syntax error when you press the "Check" soft key (labelled "Cntrl." if you select Nederlands as the calc language). I also tried to add a nested IF THEN ELSE END; inside one of the IF statements and still no syntax error. If there is a syntax error with the cursor just in front of the UNTIL it means that the UNTIL was not expected at this place, so likely a previous statement is still open hence the missing END; suggestion but, as toml_12953 said, without the original code there is not much more that we can do to help. |
|||
02-15-2021, 03:18 PM
(This post was last modified: 02-15-2021 03:24 PM by Wolfgang.)
Post: #17
|
|||
|
|||
RE: REPEAT . . . UNTIL loop problem
(02-15-2021 02:43 PM)Didier Lachieze Wrote: [quote='Wolfgang' pid='143019' dateline='1613395513'] HP 33C 34C 11C 41CX 12C 15C HP71B 35s 50g Prime Rev. A, C, D. DM 41X, 42. TI 58C, 59, 74, 92-II, Voyage 200, nspire CX II-T, Sanyo ICC 82D and more |
|||
02-15-2021, 03:26 PM
(This post was last modified: 02-15-2021 03:27 PM by Didier Lachieze.)
Post: #18
|
|||
|
|||
RE: REPEAT . . . UNTIL loop problem
(02-15-2021 03:18 PM)Wolfgang Wrote: Now, thats an example for CASE.....and not for REPEAT--UNTIL Loops only. The IF Conditions are inside the CASE LOOP In this example the CASE loop is included in a REPEAT-UNTIL loop. This is exactly what the OP described for his program: (02-14-2021 08:09 PM)cahlucas Wrote: Dear Mr. Gene, Obviously we need the original program to provide more meaningful answers. |
|||
02-15-2021, 10:20 PM
Post: #19
|
|||
|
|||
RE: REPEAT . . . UNTIL loop problem
Make a copy of the program. Then start removing chunks of code from the copy until you discover the cause of the syntax error. The key here is that you don't care of the copy works, you just want to determine the syntax error.
|
|||
02-15-2021, 11:03 PM
(This post was last modified: 02-15-2021 11:05 PM by cahlucas.)
Post: #20
|
|||
|
|||
RE: REPEAT . . . UNTIL loop problem
Here is the framework of my program, at least the part where you can derive control from. I will not publish the entire program here, to keep the overview as simple as possible. Things unrelated to program control have been left out. But this should be enough to track down the error. I hope you can find it. Sincerely, Karel.
Code:
I use HP-16C, WP-34S emulator, HP-35s, HP-48GX, HP-50g, and HP Prime G2. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)