Logic errors

Basic and Machine Language

Moderator: Moderators

Post Reply
User avatar
Jeff-20
Denial Founder
Posts: 5761
Joined: Wed Dec 31, 1969 6:00 pm

Logic errors

Post by Jeff-20 »

Look at this line. Can you see why it produces a SYNTAX ERROR?

10 FOR T=1 TO 15: PRINT T AND 3: NEXT

Look closely. The problem is quite simple. Typed without spaces (as we all do), the computer wants to read "T AND 3" as "TAN D3".

Tan is a basic token, and without a parenthetical following, the computer assumes it is a mistake. THe problem is easily fixed by replacing the variable T.
High Scores, Links, and Jeff's Basic Games page.
aneurysm
not your PAL
Posts: 178
Joined: Sat Mar 06, 2004 11:06 pm

Post by aneurysm »

woah
User avatar
GreyGhost
Vic 20 Nerd
Posts: 526
Joined: Wed Oct 05, 2005 11:10 pm

Post by GreyGhost »

I got caught up with this one for five minutes:

10 INPUT "{CLR}FILE NAME:";FN$

So simple, yet so frustrating. :?
Rob
User avatar
Jeff-20
Denial Founder
Posts: 5761
Joined: Wed Dec 31, 1969 6:00 pm

Post by Jeff-20 »

DEF FN? (I'm not sure. . .)
High Scores, Links, and Jeff's Basic Games page.
Tepic
Vic 20 Devotee
Posts: 209
Joined: Wed Mar 24, 2004 10:47 pm

Post by Tepic »

I think the FN part.

A=FNB(2) etc
User avatar
Schema
factor
Posts: 1430
Joined: Tue Mar 23, 2004 7:07 am
Website: http://www.jammingsignal.com
Location: Toronto, Ontario

Post by Schema »

Jim Butterfield did a hilarious talk on this at World of Commodore last year. You can also type

10 FOR T=1 TO 15: PRINTT{graphics character}AND3: NEXT

BASIC will remove the graphics character and the line will look OK. But if you hit Return on the line again, you get the error.
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

Or for that matter TA{SHIFT+N}3. The parser will look up rather than expand the abbreviation before inserting the right token.

SYS53387E$ was solved as SYS(53387)E$. In similar fashion, PRINT(T)AND3 would also be a solution here.
Anders Carlsson

Image Image Image Image Image
Post Reply