| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Re: Something strange going on. |
On Wednesday, April 11, 2018 at 12:33:17 PM UTC+2, Shaun Bebbington wrote: > Hi, > > I found something odd today in the powerful CBM BASIC v2.0. > > Having worked with Sinclair BASIC quite a lot recently, I use GOTO X where X is a valid line number (i.e., LET X = 100). But I know that's not possible with Microsoft BASIC. Of course there is the ON X GO TO 100,200 ... > > So I thought "I know, I'll try and use a function, could CBM BASIC use this as a look up table". The following, I expected to go to the value in the function A() which returns 10, but... > > 0 DEF FN A(X) = 10 > 1 PRINT FN A(0) > 2 GO TO FN A(0) > 3 PRINT "END GRACEFULLY" > 4 END > 10 PRINT "STOP" > 11 STOP > > Try it for yourself. What's going on here? > > Thanks in advance. > > Shaun. I went the "hard" way and traced what happens using VICE's monitor's 'z' command. I recommend that you do the same, consulting a commented BASIC ROM listing if necessary. But there's a much easier way to get the idea: Let your programs start at line 1 instead of 0. Chris Edit: The above should read "Let your programs start _with_ line number 1". Here's a short version of the "hard" way: - Start x64 from a console window (otherwise breakpoints might not work) - Enter a one-liner "0 goto 0" - RUN the one-liner - Enter VICE's monitor (Ctrl-h) - Enter 'bk a971' in VICE's monitor - Enter 'x' in VICE's monitor - Not(ic)e that the C-flag is set but every other time the breakpoint is reached Now repeat the above procedure, but let your one-liner be "0 goto a" instead this time. Note that the C-flag is set _all_ the time. --- SoupGate-Win32 v1.05* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3) SEEN-BY: 57/0 116/102 153/150 250 317/2 3 393/68 633/267 280 640/384 712/620 SEEN-BY: 712/848 770/0 1 3 100 340 772/0 1 210 500 @PATH: 770/3 1 712/848 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.