LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

Automatically running KEYs

Root / General / [.]

12Me21Created:
So, I noticed that KEY(4) (LIST ERR) has a line feed (not carriage return) at the end. It seems that you can do KEY X,command$+CHR$(13)

Yep. Just put that on the end of KEY and it will run automatically.

Now, you could do something like KEY 4,"LIST ERR:NEW 0"+CHR$(13) which would look just like the normal key, but...

Interesting to note that KEY 5,"CLS"+CHR$(13)+"PRINT 5"+CHR$(13) will just clear the screen when you tap key 5. On the other hand, KEY 5,"CLS"+CHR$(10)+"PRINT 5"+CHR$(13) will clear the screen, and put 5 at the top of the screen.

Interesting to note that KEY 5,"CLS"+CHR$(13)+"PRINT 5"+CHR$(13) will just clear the screen when you tap key 5. On the other hand, KEY 5,"CLS"+CHR$(10)+"PRINT 5"+CHR$(13) will clear the screen, and put 5 at the top of the screen.
Interesting. You could also just use this ":" to separate commands.

You could also just use this ":" to separate commands.
Not always. For example, CLEAR:CLS will not clear the screen. EDIT: Also, LOAD "FILE":RUN gives a Syntax error, which was my interest in using the keys.

You could also just use this ":" to separate commands.
Not always. For example, CLEAR:CLS will not clear the screen.
I believe : was required to separate back in PTC.

I believe : was required to separate back in PTC.
No, it was not required.

I believe : was required to separate back in PTC.
No, it was not required.
You can use it to separate commands in PTC and SmileBASIC. And what do you mean it was not required?
Not always. For example, CLEAR:CLS will not clear the screen. EDIT: Also, LOAD "FILE":RUN gives a Syntax error, which was my interest in using the keys.
Well that's weird.

[And what do you mean it was not required?
In some cases, which I do not remember well, such as for loops and some mathematical implementations (I think), another instruction could follow it with no separation.

I believe : was required to separate back in PTC.
No, it was not required.
You can use it to separate commands in PTC and SmileBASIC. And what do you mean it was not required?
In some cases, where it was clear that there was the beginning of a new command and not a continuation of the previous one, the command separator was not necessary: e.g. A=5B=2, there is no way B is part of the value that is meant to be assigned to the variable A, so it was taken to be the beginning of a new command.
Not always. For example, CLEAR:CLS will not clear the screen. EDIT: Also, LOAD "FILE":RUN gives a Syntax error, which was my interest in using the keys.
Well that's weird.
Garrr... and KEY 5,"LOAD"+CHR$(34)+"FILE"+CHR$(34)+CHR$(10)+"RUN"+CHR$(13) doesn't work. WHYYYY...

use CHR$(10), maybe EDIT: do loops work in direct mode? Then you could make an entire game :D

use CHR$(10), maybe EDIT: do loops work in direct mode? Then you could make an entire game :D
I know I used a FOR in direct in PTC once, so probably.

Garrr... and KEY 5,"LOAD"+CHR$(34)+"FILE"+CHR$(34)+CHR$(10)+"RUN"+CHR$(13) doesn't work. WHYYYY...
Can't we just use EXEC? EG:
KEY 5, "EXEC "+CHR$(34)+"FILE"+CHR$(34)+CHR$(13)

Garrr... and KEY 5,"LOAD"+CHR$(34)+"FILE"+CHR$(34)+CHR$(10)+"RUN"+CHR$(13) doesn't work. WHYYYY...
Can't we just use EXEC? EG:
KEY 5, "EXEC "+CHR$(34)+"FILE"+CHR$(34)+CHR$(13)
Can't use from direct mode
error. Why? ... It's SmileBoom. Who could know why.

EXEC is meant for use inside a program... It allows you to return to the previous program using END.

CHR$(13) is the linefeed character, while CHR$(10) is the carriage return character, correct? So when it encounters a linefeed, it probably just tosses out all the text that comes after it. CHR$(13) tells the command line "alright boys, take the input buffer and parse it." My assumption is that a function key writes its contents to input one character at a time, instead of all at once. Sticking a CHR$(10) inbetween lets you send multiple lines of code at once.