is there any way to auto-indent?
BlitzMax Forums/BlitzMax Beginners Area/is there any way to auto-indent?
| ||
Is there any way to auto-format your code in BlitzMax? I mean indenting it and stuff according to some previously established best practices? Because I found that feature a big help when I was learning Flash AS. If there is no auto-format option in Blitz, I definitely would like to see one in the future. It's a good tool for helping programmers reach each others' code, too! |
| ||
you should learn this skill as indenting is vital to understand and absolutely no trouble to do. |
| ||
Basically, increase the indent whenever you use the following commands and outdent again when you use their counterpart. Function .. EndFunction Repeat .. Until/Forever While .. Wend For .. Next Type .. EndType Method .. EndMethod Select is a bit funny, but it should look something like this... Select <variable> Case <value1) ' do stuff Case <value2> ' do something else Default ' otherwise do this instead EndSelect If..Then..ElseIf..EndIf is another funny one... If <expression> Then ' do this ElseIf <expression2> Then ' do that Else ' do something else EndIf Don't forget that these can all be nested... Function CheckCollisions() For b:bullet=EachIn bulletList For a:alien=EachIn alienList If <bullet hits alien> Then score:+100 alienList.Remove(a) a=Null bulletList.Remove(b) b=Null Exit EndIf Next Next FlushMem EndFunction Notice that all the For's and If's line up with their respective Next's and EndIf's. Hope that helps |
| ||
This question is in the same vein as the other one so I'll ask it here: Is there any way to define how many spaces a tab is in the mac gui? The default is 4 and I'm used to 2... kinda annoying... |
| ||
If you look in the Blitzmax\cfg directory, there is a file called ide.ini - load this into Notepad and you can change various settings, including the tab size :-) Note - make a backup of the file first, so if you mess anything up, you can revert to the default settings. |
| ||
Is the tab size option not under File > IDE Options, as it is in the Windows version? |
| ||
Ghost Dancer: Sadly this option isn't there in the macide.cfg file :( JazzieB: The mac version has the worlds smallest preferences window, and that's it :( (In the demo version (0.8?) I couldn't even change the editors text colors; luckily that's no longer a problem) Still hoping there's some way to edit this - Maybe in some general OS X setting somewhere? |
| ||
It's more likely that you will just have to wait until the Win32/Linux IDE is ported to Mac. Which I understand will happen at the same time MaxGUI is released. |
| ||
Don't get me wrong, I know how to indent. It's just that I also know from personal experience that my own manual indents are never as consitant as I'd like them to be. A mechanical way of indenting my code would be really attractive to me. There isn't even a third party app or something that'll do it? [Edit] WOOT! IndeED does this, for free, with its Pretty Format function, and it does a very good job of it, too! If anyone else wanted this feature, it's right there in the toolbox under IDEs. Yay! [Edited again!] Except, D'OH! IndeEd's Pretty Format doesn't seem to process handle nestled commands properly. :( This: Becomes this: When I think it should probabaly look like this: I have tried messing with the PrettyFormat rules, but I haven't had any luck so far. Does anyone know what my rules should look like if I want types, functions, and other self-contained blocks of code to always end on the same line where they began? After experimenting with rules, I'm starting to think maybe the only way to do it properly would be if IndeED actually parsed the code and applied rules to each set of Function and End Function commands as a discreet pair. :/ Maybe I'll try some other IDEs, too. Does anyone know which one auto-formats the best? |