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

Program minification

Root / Submissions / [.]

DevinF06Created:
With how SmileBASIC handles programs, you can (Most of the time) easily compress programs. Like this:
LOCATE 0,0
PRINT "TEST 123123123"
I$=I$+"12345"
LOCATE.,.?"TEST "+"123"*3INC I$,"12345
This works because: - It detects . as a number (Probably the same reason as .5 is the same as 0.5) - It runs DEFs under: A-Z and 0-9, but not . - When there's not another separator (,), it treats it as a newline - INC is just ARG1=ARG1+ARG2, still works with strings because of how variables are handled Notes: - When making something, try not compressing a lot of it, in case you easily want to change something - : makes a newline, handy for some SB commands are optional arguments (Including PRINT/? if they have no arguments):
ACLS:?"12345" 'ACLS [GR, SP, FN]
- DEC won't work as INC, because it's ARG1=ARG1-ARG2. - DEFs also won't include these: !, &, SPACE/CHR 0 and @ but variables can be defined with # - If a line starts with :, it will return a syntax error - You don't need to close a string on a newline, but not : (e.g. ?"123) - Anything after a ' (Or REM) on a line will be a comment These can only be replaced if it's a simple true/false operation (e.g. #TRUE&&#TRUE #TRUE||#FALSE) - OR can be replaced with || - AND can be replaced with && - NOT can be replaced with ! - DIV can be replaced with / - #WHITE or RGB(255,255,255) is just -1 - If you want to know what a value is (e.g. RGB(127,63,255)), then just type in ? then the command in DIRECT mode and use the shortest one (#LIME or -16713728) - IF will always execute if it's not 0 - TRUEand FALSE are just 1 and 0 - To invert a boolean (TRUE or FALSE), use NUM=!NUM - If you use something like STR$[NUM] , it will return the equilivant of:
MID$(STR$,NUM,1)
, but if it's greater than the length of the string, it would return a Subscript out of range - If a return call is not made in a DEF (e.g. RETURN NUM), it will cause a Type mismatch - If a return call return to nothing, it will cause a Syntax error (This also happens with "123"STR$(NUM)) - If there's code in the same line as the IF statement, then the command will only run one line until ENDIF (Only when a newline has been specified with CHR 10) - "123"*NUM is probably the same reason as how INC works with strings Examples: (One per line)
CLS?"Hello, "+USR$
GFILL.,.,399,239,-1
IF LEN(S$)THEN ?"TEST"
NUM=!.
?:GPUTCHR.,.,"HI",#LIME
?.LOCATE.,1?"HI"
ACLS?"TEST"

This is great, I'd love a automated program! @Simeon

Replying to:Xenoslyce
This is great, I'd love a automated program! @Simeon
Ooooooh

IF LEN(S$)THEN ?"TEST"
?"TEST"*(S$>"")

(a thread for this topic existed previously here: https://smilebasicsource.com/forum?ftid=1775)

This isn't really compression, just golfing and obfuscating.

Replying to:snail_
This isn't really compression, just golfing and obfuscating.
they meant "minification"

Replying to:snail_
This isn't really compression, just golfing and obfuscating.
Edit it then lol

OR, AND, and NOT aren't the same as ||, &&, and !. You should use || && and ! in boolean situations. (they return only 1 or 0) You should use OR AND and NOT in bitwise situations.
IF BUTTON() AND #A THEN
(runs when A is one of the buttons that are pressed) This is not the same as
IF BUTTON() && #A
(runs when any button pressed)