Jump to content
IGNORED

Syntax Error?


Opry99er

Recommended Posts

Umm, I've looked at this (with biased and bloodshot eyes) for about 20 minutes now...

 

Keep receiving * SYNTAX ERROR IN 2070 *

 

Please help.... I'm sure this is a "Slap your head" moment... Just doesn't click. I can't see the error

 

 

2070 IF CMP<10 THEN GOSUB 2370 :: DISPLAY AT(15,1):"NOT ENOUGH MP"; :: FOR I=1 TO 800 :: NEXT I :: RETURN

 

 

Link to comment
Share on other sites

 

	
		
			
				14
			
			
				SYNTAX ERROR
			
			
				·          An error such as a missing or extra comma or parenthesis, parameters in the wrong order, missing parameters, missing keyword, misspelled keyword, keyword in the wrong order, or the like was detected in a TI Extended BASIC command, statement, function or subprogram.
				·          DATA or IMAGE not first and only statement on a line.
				·          Items after final ")"
				·          Missing "#" in SPRITE
				·          Missing ENTER, tail comment symbol (!), or statement separator symbol (:.
				·          Missing THEN after IF.
				·          Missing TO after FOR.
				·          Nothing after CALL, SUB, FOR, THEN or ELSE.
				·          Two E’s in a numeric constant.
				·          Wrong parameter list in a TI Extended BASIC supplied subprogram.
				·          Going into or out of a subprogram with GOTO, GOSUB, ON ERROR, etc.
				·          Calling INIT without the Memory Expansion Peripheral attached.
				·          Calling LINK or LOAD without first calling INIT.
				·          Using a constant where a variable is required.
				·          More than seven dimensions in an array.
				 
			
		
	

 
Link to comment
Share on other sites

That would explain alot.. Thank you.

 

I guess I will need to rethink the order here... This is an "Early Termination" segment of a submenu item... Kicks the user out of the block if MP isnt sufficient to cast a spell.

 

No big deal, just take some extra lines. :)

 

Thanks for the debug lesson, InsaneOne. That is one I have never come across before!

Link to comment
Share on other sites

I'm suspicious of that semicolon after "Not Enough MP"

That was my first thought... But I use ther terminating semicolon throughout the whole game to keep from obliterating stuff to the right of my DISPLAY AT.

 

I thought "My notepad shows ; ::, but XB shows ;::, something is wonky"

 

Thn I remembered that XB is smart and removes unneeded spaces from sloppy coders. :)

 

Funny, I dont think the XB manual lists the IF THEN-FOR NEXT pairing as an error... Good to have "people." :)

 

Thanks again guys.

Link to comment
Share on other sites

I found an XB manual in PDF format - the exceptions are listed in the IF..THEN section, second paragraph of the description.

 

Anyway, here is an example of how you can trick the interpreter:

 

1 X,I=0
2 !@P-
2000 if X=1 then 2010 else PRINT "X=0"::FOR I=1 to 9::PRINT "*"; ::NEXT I::END
2010 PRINT "X was equal to 1"
Change the value in line 1 to either 0 or 1 to test the if/then results.

 

If you delete line 2, prescan will be enabled, and you will receive a syntax error in line 2000.

 

;)

Link to comment
Share on other sites

Cool, Tim... :) I was looking at the Error section where it describes SYNTAX errors and did not see it listed there. :)

 

Adam, first I'm going to try a GOSUB to a single line delay routine. I can route it up from multiple places in my program.

 

Then, if that doesnt work, I'll do a custom SUB. I hate custom subs. LOL!!

 

Thanks for the useful help fellas. Glad to be moving onward and upward!!

Link to comment
Share on other sites

Hey Adam... I added a large chunk of code to the RPG.. That's what I am debugging.

 

SPELLS funcionality in "PeaceTime".

 

That mother cost me 6 hours of sleep and 4000 program bytes last night... Im sure you are intimately familiar with that routine, as Im sure it is in Realms too.

 

I was not entirely prepared for the complexity of it when I sat down at the keyboard last night... I knew it would require a bunch of new variables and some hoppy-rabbit logic, but it kind of hurt my head. LOL

Link to comment
Share on other sites

Peace time spells... oh yeah, I need to write that. :)

 

It's not too bad, the main pain point right now is playing the sound effect for them... at the moment I don't have enough space in the travel sound block for them all, so I'm debating loading spell sound effects individually from disk. Requires a minor refactor to do that...

Link to comment
Share on other sites

Gotcha... Yea, the code I posted in the thread should work... It's not super fancy, but it will work once debugged. I went over and over it last night while writing it, and once it's debugged, I will be very proud of it. :)

 

Feel free to glance over it and let me know what you think.

 

Right now.it is all text, but I will be adding SPRITEs to it once it is debugged.

Link to comment
Share on other sites

Umm, I've looked at this (with biased and bloodshot eyes) for about 20 minutes now...

 

Keep receiving * SYNTAX ERROR IN 2070 *

 

Please help.... I'm sure this is a "Slap your head" moment... Just doesn't click. I can't see the error

2070 IF CMP<10 THEN GOSUB 2370 :: DISPLAY AT(15,1):"NOT ENOUGH MP"; :: FOR I=1 TO 800 :: NEXT I :: RETURN

You have a error in your logic.

 

First off if you have a GOSUB 2370 that returns to a DISPLAY AT then a FOR NEXT loop but the problem is the RETURN

 

The line should read:

2070 IF CMP<10 THEN GOSUB 2370 :: DISPLAY AT(15,1):"NOT ENOUGH MP"; :: GOTO 5000

 

5000 FOR I=1 TO 800 :: NEXT I :: RETURN

 

See if a GOTO 2070 results then you have a return with no GOSUB, if you have a GOSUB to 2070 you now have a RETURN

 

I tested this many times a found the problem is the logic with gosubs that is the reason for the syntax error of the FOR NEXT loop and RETURN

(You see the XB STACK can not figure out what you want to do so gives the incorrect * SYNTAX ERROR * as the is the default error.)

 

There is no * WTF DO I DO WITH THE STACK HERE ERROR *

Edited by RXB
Link to comment
Share on other sites

This snippit is part of a routine that was GOSUBed to. If the MP value is less than 10, I GOSUB to the routine that clears the menu. It returns to this line, then displays the message, delays for a moment, then returns to the original LINE that GOSUBed line 2070.

 

If the MP value is 10 or more, the program continues to line 2080.

 

The final RETURN returns to another part of the program that originally GOSUBed to line 2070.

 

That make any sense?

Link to comment
Share on other sites

Hey Rich, do me a favor and hop on the LoBR thread... View the code box I posted this morning. It's in a different format than XB, but it translates to XB in TIdBiT.

 

The format is very clear and easy to follow. If you get a chance, look that block over and you'll see what the whole program is doing... Maybe if I have further bug issues tonight, you can lend me your expertise.

 

:)

 

Thanks to everyone who has helped so far!!

Link to comment
Share on other sites

You have a error in your logic.

 

First off if you have a GOSUB 2370 that returns to a DISPLAY AT then a FOR NEXT loop but the problem is the RETURN

 

The line should read:

2070 IF CMP<10 THEN GOSUB 2370 :: DISPLAY AT(15,1):"NOT ENOUGH MP"; :: GOTO 50000

 

5000 FOR I=1 TO 800 :: NEXT I :: RETURN

 

See if a GOTO 2070 results then you have a return with no GOSUB, if you have a GOSUB to 2070 you now have a RETURN

 

I tested this many times a found the problem is the logic with gosubs that is the reason for the syntax error of the FOR NEXT loop and RETURN

(You see the XB STACK can not figure out what you want to do so gives the incorrect * SYNTAX ERROR * as the is the default error.)

 

There is no * WTF DO I DO WITH THE STACK HERE ERROR *

It's true that the RETURN is an error in that line, but if that were causing the error message it would be RETURN WITHOUT GOSUB IN 2070. I assume that earlier in the program there was a GOSUB 2070. As Insane Multitasker reports above, this error is caused by having FOR/NEXT following an IF/THEN.

From the XB manual: "The FOR-TO-STEP statement cannot be used in an IF-THEN-ELSE statement."

this gets a syntax error:

10 IF X=5 THEN 20::FOR I=1 TO 10::NEXT I

20 END

This will not:

10 IF X=5 THEN 20

15 FOR I=1 TO 10::NEXT I

20 END

Here's another odd line that gives an error:

10 FOR I=1 TO 10::IF I=5 THEN 20::NEXT I

20 END

Remove the NEXT from line 10 and the error goes away:

10 FOR I=1 TO 10::IF I=5 THEN 20

15 NEXT I

20 END

  • Like 1
Link to comment
Share on other sites

You have a error in your logic.

 

First off if you have a GOSUB 2370 that returns to a DISPLAY AT then a FOR NEXT loop but the problem is the RETURN

 

The line should read:

2070 IF CMP<10 THEN GOSUB 2370 :: DISPLAY AT(15,1):"NOT ENOUGH MP"; :: GOTO 50000

 

5000 FOR I=1 TO 800 :: NEXT I :: RETURN

 

See if a GOTO 2070 results then you have a return with no GOSUB, if you have a GOSUB to 2070 you now have a RETURN

 

I tested this many times a found the problem is the logic with gosubs that is the reason for the syntax error of the FOR NEXT loop and RETURN

(You see the XB STACK can not figure out what you want to do so gives the incorrect * SYNTAX ERROR * as the is the default error.)

 

There is no * WTF DO I DO WITH THE STACK HERE ERROR *

Not true.

 

The syntax error in Owen's example is generated as a result of using a FOR..NEXT loop as part of an IF..THEN statement. The RETURN statement is irrelevant. In the case of an IF..THEN Statement, the programmer should either place the RETURN on a separate line or there should be a return for each branch.

 

A return should follow from the stack. For example, IF X=1 THEN PRINT::RETURN ELSE RETURN would be an acceptable practice to ensure the stack does not exhaust itself. Recursive GOSUB routines work just fine as does jumping around the program, so long as the programmer anticipates where the stack will return.

Link to comment
Share on other sites

The joys of debugging a recursive GOSUB block escape me right now. :)

 

Let's just say I am knee deep in sh** and trying to dig my way out with some original TI joysticks-o-pain.

 

Good news is, I've squashed 5 or 6 so far and I think I am getting close...

Edited by Opry99er
Link to comment
Share on other sites

Not true.

 

The syntax error in Owen's example is generated as a result of using a FOR..NEXT loop as part of an IF..THEN statement. The RETURN statement is irrelevant. In the case of an IF..THEN Statement, the programmer should either place the RETURN on a separate line or there should be a return for each branch.

 

A return should follow from the stack. For example, IF X=1 THEN PRINT::RETURN ELSE RETURN would be an acceptable practice to ensure the stack does not exhaust itself. Recursive GOSUB routines work just fine as does jumping around the program, so long as the programmer anticipates where the stack will return.

You are right I was incorrect.

 

Personally I would never have put a FOR NEXT in a IF THEN ELSE as that would be really hard to debug?

 

If you had 30 of these the stack would fill up very quickly with these attempting to return the correct address.

 

It is not that they can not be done, the problem is the amount of memory the TI99/4A has to work with.

 

A much better way to write programs in XB is use SUB name and SUBEND and SUBEXIT then to use GOSUB and RETURN.

Edited by RXB
Link to comment
Share on other sites

The FOR NEXT is not inside the IF THEN... It occurs after the close of the IF THEN. I guess to avoid stack overflow/underflow/confusion, the authors of TI XB made it so that the two could not inhabit the same line of code.

 

Sort of seems like using a hatchet where a scalpel is needed though.

 

As Tim's prescan example shows, tge logic is sound, just not allowed in TI XB.

Link to comment
Share on other sites

The FOR NEXT is not inside the IF THEN... It occurs after the close of the IF THEN. I guess to avoid stack overflow/underflow/confusion, the authors of TI XB made it so that the two could not inhabit the same line of code.

 

Sort of seems like using a hatchet where a scalpel is needed though.

 

As Tim's prescan example shows, the logic is sound, just not allowed in TI XB.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...