? `A`u`t`o`m`a`t`i`c` `I`n`d`e`n`t`e`r` ● SmileBASIC Source

Sign In

Register
*Usernames are case-sensitive
Forgot my password
Another contest? You asked for it!

`A`u`t`o`m`a`t`i`c` `I`n`d`e`n`t`e`r`

Submitted
Updated
Author
12Me21
Public Key
REMOVED
Min. Compat.
All
Version
1.1
Size
2.39KB
Rating
0 votes
Description A big problem with SmileBasic is that it doesn't automatically indent your code. I made a program that adds proper indenting (based on TABSTEP) to another program. Instructions Make sure AUTO_INDENT is in the same folder as the program you want to modify (Also make sure you have nothing important in slot 3) Open AUTO_INDENT and enter the other program's name. Press [Yes]/[OK]/whatever to load and save the file Notes Doing things like IF X=1 THEN BEEP ' THEN IF X=1 THEN 'comment BEEP ENDIF NEXT:NEXT will mess up the indenting (It shouldn't harm the program though)
Categories
Keywords
13 Comment(s) 12Me21 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself DONT USE THIS ONE!!! I have a new version coming VERY SOON! AnswerXOX AnswerXOX First Year My account is over 1 year old Website Great Page Hidden Achievements Touhou Project Is Awesome! I love Touhou Project! Express Yourself 1 year ago Can you post the original source code on Pastebin, I actually enjoyed this very much and deleted it by accident 12Me21 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself Currently testing the final version. Seems to be 100% perfect. It's currently not optimized, and taking probably a hour to edit GIVERS_APP (very big program) 12Me21 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself I'll have a vastly improved version in a day or two. 12Me21 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself I finally have a solution! Originally I was lazy (and efficient), and only checked the first "word" (text with a space after it) in each line, except when the first word was "IF", where I had to check if the final 4 characters were "THEN" This causes problems when people do stuff like NEXT:NEXT (even the first one isn't detected because there's no space) REPEAT:UNTIL BUTTON() etc. So now I have a new solution! 12Me21 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself I made a function to check a line for valid occurances of a keyword. The rules it uses are: -It can't be inside a string -It can't be in a comment (comments start with ' outside a string)* -It can't have a LETTER, @, or _ directly in front of it -It can't have a NUMBER, LETTER, $, #, %, or _ directly after it I think this covers every possible scenario. So now, I can just do INLIN(LINE$, IF,0), for example, and find out if that line has the keyword IF in it (and not something like ENDIF) Now, I just need to make it find multiple keywords... And... Detect non-block IF statements. I think that could be detected if I checked if there was anything besides : , ' , or spaces after THEN... UGH... *REM is not technically a comment marker, it is just a statement that does nothing. And no one uses it. 12Me21 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself I'm just trying to think what how smileBASIC determines this, and not how I would do it, since I might miss something.. So, It seems that if there is anything after the THEN, except space and CR, (and comments,) it will be considered a single-line IF statement. So then I do something like IF {the line has IF in it} THEN IF {the line has THEN in it, and nothing is after THEN (except comments...)} THEN INC I, TAB ENDIF ENDIF comment detection... hmm... NeatNit NeatNit I like this idea! I don't know yet if it works correctly but I don't see why not :) Here's a tip for fixing the problem you described: 1. Find where a comment starts in a line. Comments start with the first ' character that isn't inside a string 2. Remove the comment entirely (for your internal processing only) 3. Remove any trailing whitespace. 4. At this point you can just use the code you already have, maybe with a few tweaks (for example, you need to put the comment back in) 5. Hopefully, bug-free automatic indentation! 12Me21 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself I will try to add this eventuallly. Luckily, the comment problem only affects IF ... THEN 'COMMENT ... ENDIF and (this is rare) IF ... THEN ... ' THEN . The main issue is things like: NEXT:NEXT. That will me much harder to solve. 12Me21 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself Oh, and also there's the problem of ' inside of strings, where it doesn't make a comment. Super_Defaultio Super_Defaultio First Month Joined in the very first month of SmileBASIC Source Website Beginner Programmer I'm just starting out! I'm still trying to grasp the basics. Programming Strength Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself This is probably one of the most useless programs here. You know that you could just press space and it will automatically keep that indention for future lines. Still don't know how this would be useful.... sorry. randomous randomous Power User Robot Hidden Easter Eggs Second Year My account is over 2 years old Website Drawing I like to draw! Hobbies It indents an otherwise non-indented code file. It can fix the indenting on a file which has broken indenting (if it works correctly). 12Me21 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself Yes, it converts any code into code with proper indenting. For example: WHILE 1 BEEP WEND would be converted to WHILE 1 BEEP WEND Etc.