Immediate mode (i.e. not in a program) BASIC commands

All aspects of programming on the Commander X16.
Post Reply
Martin Schmalenbach
Posts: 140
Joined: Tue Jul 21, 2020 10:08 pm

Immediate mode (i.e. not in a program) BASIC commands

Post by Martin Schmalenbach »

Hi

I'm sure this is just a 'me' thing but searches aren't helping and I don't seem to find what I'm looking for in the BASIC Prog. Ref Guide on GITHUB.

What are the commands that BASIC supports in 'immediate' mode, i.e. when it is NOT running BASIC program? I believe we have some new additions - OLD for un-NEWing a program, REN for renumber.

Are there others, if so, what are they and where can I find documentation on them?

Thanks in advance!
DragWx
Posts: 363
Joined: Tue Mar 07, 2023 9:07 pm

Re: Immediate mode (i.e. not in a program) BASIC commands

Post by DragWx »

ALL BASIC commands can be run from inside or from outside the context of a program. Also, anything that can be typed at the READY prompt can be executed as a line in a BASIC program. AFAIK, there aren't any that are limited to one or the other.
(EDIT: This is incorrect -- there are three which are limited to running inside or outside a program, see later posts)

All of the supported BASIC commands on the X16 can be found here in the documentation. There are several commands in the docs that are listed but not explained, those are all taken directly from C64 BASIC and explanations can be found here.
Last edited by DragWx on Tue Jun 27, 2023 4:14 pm, edited 1 time in total.
Martin Schmalenbach
Posts: 140
Joined: Tue Jul 21, 2020 10:08 pm

Re: Immediate mode (i.e. not in a program) BASIC commands

Post by Martin Schmalenbach »

DragWx wrote: Tue Jun 27, 2023 1:29 am ALL BASIC commands can be run from inside or from outside the context of a program. Also, anything that can be typed at the READY prompt can be executed as a line in a BASIC program. AFAIK, there aren't any that are limited to one or the other.

All of the supported BASIC commands on the X16 can be found here in the documentation. There are several commands in the docs that are listed but not explained, those are all taken directly from C64 BASIC and explanations can be found here.
Got it - thanks very much for that clarification. I think what confused me for a while is I thought I'd seen somewhere there were search and/or replace commands made available in the editor. I guess that was wishful thinking mixed in with seeing some code for these functions in an old C64 magazine a lifetime or 3 ago!!
mobluse
Posts: 177
Joined: Tue Aug 04, 2020 2:16 pm
Location: Lund, Sweden
Contact:

Re: Immediate mode (i.e. not in a program) BASIC commands

Post by mobluse »

There are some typical editor commands that can't be used inside a program e.g. REN, and there are some typical program commands that can't be used outside a program e.g. INPUT.
Example session using x16emu R43 (I changed the color of the user input to yellow):
READY.
10 REN
RUN

?ILLEGAL DIRECT ERROR IN 10
READY.
INPUT Y

?ILLEGAL DIRECT ERROR
READY.
I believe one could change the implementation so that all commands could work both bare in the editor and in a program, but it might be a lot of work. ZX Spectrum BASIC can have INPUT in immediate mode. E.g. in ZX Spectrum+ you can run this outside a program:

Code: Select all

for i=1 to 3:input a:print a+a:next i
X16&C64 Quiz: Try It Now! Huge Char Demo: Try It Now! DECPS: Try It Now! Aritm: Try It Now!
DragWx
Posts: 363
Joined: Tue Mar 07, 2023 9:07 pm

Re: Immediate mode (i.e. not in a program) BASIC commands

Post by DragWx »

Wow, you're right! I didn't know that.

After looking through the ROM, it looks like there's only three that throw a "direct" error: INPUT/INPUT#, GET/GET#, and REN.

Fun fact: The way BASIC checks if you're running a command in direct mode or not is by checking the high byte of the current program line number to see if it's $FF. Normally, that would encompass line numbers 65280..65535, but BASIC avoids any problems by not allowing you to use line numbers higher than 63999.
Martin Schmalenbach
Posts: 140
Joined: Tue Jul 21, 2020 10:08 pm

Re: Immediate mode (i.e. not in a program) BASIC commands

Post by Martin Schmalenbach »

Thanks all - useful stuff there - good to know :D
Post Reply