? Program minification ● SmileBASIC Source

Sign In

Register
*Usernames are case-sensitive
Forgot my password
Space-Restriction Challenge QSP Phase Ends on March 26!

Program minification

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"
Author
DevinF06
Updated
Rating
1 vote
Categories
Keywords
  • SmileBASIC
  • Program
  • Minification
8 Comment(s) TheV360 TheV360 Pokemon Is Awesome! I love Pokemon! Express Yourself First Day Joined on the very first day of SmileBASIC Source Website Night Person I like the quiet night and sleep late. Express Yourself 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) snail_ snail_ Helper Received for being very helpful around SmileBASIC Source Achievements OSP Contest 2 Contest Participant I participated in the second SmileBASIC Source OSP Contest! Night Person I like the quiet night and sleep late. Express Yourself This isn't really compression, just golfing and obfuscating. Yttria Yttria Head Admin they meant "minification" IAmRalsei IAmRalsei Forum Leader Hidden Achievements First Year My account is over 1 year old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Edit it then lol Yttria Yttria Head Admin (a thread for this topic existed previously here: https://smilebasicsource.com/forum?ftid=1775) 12Me21 12Me21 Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself IF LEN(S$)THEN ?"TEST" ?"TEST"*(S$>"") Xenoslyce Xenoslyce Video Games I like to play video games! Hobbies Night Person I like the quiet night and sleep late. Express Yourself Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength This is great, I'd love a automated program! @Simeon Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies Ooooooh