LoginLogin
Might make SBS readonly: thread

USE Command

Root / FAQs / [.]

PixelStudioCreated:
Hello, just wondering if anyone found out how to use the USE command and how to structure it. The :3

Thx×

Seems useless as the programs are already executable without using "USE" From the doc: "Makes a program in the specified program SLOT executable" Example USE 2 I can just call EXEC 2 without USE 2 to and it works anyway.

EXEC runs the entire code of another slot from the top, and as you said, can be used without USE. After a USE, though, you can jump to specific places in the other code with GOTO or GOSUB, or call a function from the other block, to use it more selectively. You can jump to labels in another program slot with, for example GOTO "n:@LABEL" where n is a slot 0-3. To do this, you have to USE n first. You can also access functions that are defined in a COMMON DEF block in another slot as well, but you have to USE that slot first. It seems that when you run a program, SmileBASIC searches it for DEF blocks and loads them into memory; if you include a USE command in your program, it also searches the slot you USE'd for DEF blocks and loads them as well (before executing any other code, I think). Also, you can write lines of code to another PRG slot, with instructions like PRGEDIT, PRGSET, etc. After you write lines of code in slot n, you have to USE n to alert the system that that code has changed, and then you can access that code with EXEC, GOTO, function calls, etc. etc.

oh. Really wish Smileboom went into more detail. thx beautysoap.

Cool thx

Yea, I use USE when making libraries. PRG 0:
USE 1
SET_UP_GAME
PRINT "I just used slot 1"
PRG 1:
COMMON DEF SET_UP_GAME
  PRINT "Apple juice"
END

Thanks?