Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 07:11 02 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Unexpected Text

     Page 2 of 2    
Author Message
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1642
Posted: 01:19am 29 May 2019
Copy link to clipboard 
Print this post

Hi Peter,

You must have a reason for the 'GOTO X'. I think GOTOing out of an IF..THEN sequence is problematical because the interpreter will be looking for an ENDIF and not finding one. Why not set a flag and test it after the ENDIF?

  Quote  A = 2
B = 22
C = 0

If A = B Then
C = 1
Else
Print "NOT EQUAL"
Endif

IF C = 1 GoTo X
GoTo OUT

X: Print "EQUAL"

OUT:


Bill
Keep safe. Live long and prosper.
 
PeterB
Guru

Joined: 05/02/2015
Location: Australia
Posts: 655
Posted: 02:59am 29 May 2019
Copy link to clipboard 
Print this post

Hi Bill

My bit of code is meant to show the problem only.
The manual claims GOTO can be used and that bothers me because you could be out West of the Black Stump. That's why I tried a GOSUB / RETURN. That at least takes you back to where you started. You and I are now communicating on two topics

Peter
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1642
Posted: 03:20am 29 May 2019
Copy link to clipboard 
Print this post

G'Day Peter,

Yes, GOTO can be used in a single line IF statement but not in a multi-line one (one with IF THEN ELSE etc.). GOSUB / RETURN is good for the reason you say and the interpreter won't lose the ENDIF.

Thanks for the info on the other thread. I have an iphone and am of that age - I will check it out.

Bill
Keep safe. Live long and prosper.
 
PeterB
Guru

Joined: 05/02/2015
Location: Australia
Posts: 655
Posted: 03:42am 29 May 2019
Copy link to clipboard 
Print this post

Well done Bill (again)

Yes, it's b8888y obvious when it is explained.

Peter
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4044
Posted: 09:31am 29 May 2019
Copy link to clipboard 
Print this post

  Turbo46 said   Hi seco61,

Yes, as above, the IF statement is considered as a single line statement but as you say the ELSE on the following line will be tried to be matched to a preceding IF.

As there isn't one, wouldn't you expect it to throw an error rather that ignore the following lines?

Bill


I too would expect it to throw an error.

Perhaps too tough for the interpreter to do, sadly.

It clearly does know not to run the code in the ELSE part when it shouldn't.

John
 
     Page 2 of 2    
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025