Code alignment

Blitz3D Forums/Blitz3D Programming/Code alignment

Damien Sturdy(Posted 2004) [#1]
Hey peeps- Anyone know of a tool that will sort my unorganised looping out?


Ive typed code like such:
For....
yada yada
if
yada yada
endif
next


and i need it turned into

For
   Yada Yada
   if
      Yada Yada
   endif
next



Etc etc....

Please help- i need to type in some code but ive lost where my codes going. at the moment my code is very clean and efficient but my indents arent right....

Cheers :D


Amon_old(Posted 2004) [#2]
And the difference between the two is?


Damien Sturdy(Posted 2004) [#3]
oh--- HEHEH.

Tabs-- this forum must have removed them.......


Amon_old(Posted 2004) [#4]
:)

I dont think there is a tool that auto indents code for you. You may end up having to go through your code bit by bit and indenting as you see.

Have you tried the code arcs? I know theres some code in there that cleans up code but I dont know if there is an Auto formatter << for code.


Damien Sturdy(Posted 2004) [#5]
i wrote a code cleaner thatl remove all indents- i suppose i could just reindent after running.. oh well-- Someone could code this- i wouldnt know where to start realy!


Rob Farley(Posted 2004) [#6]
This sounded like an interesting challenge... So I did one!

Code is not indented by intention!




Damien Sturdy(Posted 2004) [#7]
nice one! il go test it!

[update]

It doesnt seem to be detecting my Ifs. Yup, im using "Then" too :)
nice start though!

[update 2]

This seems to work better:



Rob Farley(Posted 2004) [#8]
It won't indent if the 'if' line has a 'then' in it. If you want it to then just add 'if' to the indent list but this does mean it will go screwy if you've got any lines like: If a > 0 then a = a + 1

[edit] Just seen your update. That's fine as long as you don't have any comments or characters after the 'then'.


Strider Centaur(Posted 2004) [#9]
This should be a feature of Some IDE, I know in JAVA and C this is common place features, many literly forcing the formatting of the code. :)

Personally, I can't code anything without indents, I get way to confused way to quick. Why on earth would you not want to use them anyway?


Rob Farley(Posted 2004) [#10]
Just checked a bit more code with it and it WON'T work for if statements formed without 'Then' e.g. If a=false a=true

I totally agree Strider, however, the blitz IDE is primitive, I'm sure the more expensive ones do.


Damien Sturdy(Posted 2004) [#11]



Better, but still wont fix the above error Rob Farley talked of....


Rob Farley(Posted 2004) [#12]
It has to be said, If-Then is a bitch to indent!


Damien Sturdy(Posted 2004) [#13]
how about using an Eval statement from the code arcives on a line with an "if", but without a "then".. if the value cant be computed, then the If statement is single line... else, its multi line?

theres prolly multiple holes here....


Dreamora(Posted 2004) [#14]
If there is a working scope system the intendion is not really hard ... just intend everything within the scope 1 level :)


Curtastic(Posted 2004) [#15]
I REALLY want an IDE that does this automatically.
I mean you cannot use the tab button. you cannot erase a tab. The code just automatically tabs to where it should be while you type.


WolRon(Posted 2004) [#16]
The code just automatically tabs to where it should be while you type.

That CANT happen. The IDE has not better idea of how the final output should be than you do.

For instance, say you want to add an IF statement into some already indented code. Does the IDE immediately indent EVERYTHING after that line or does it wait to see if an EndIF appears first?

I'm not saying that it can't do it after your finished, but it can't really do anything WHILE you type in the code.


Dreamora(Posted 2004) [#17]
wolron

jaPBe, a PureBasic free IDE basing on Scintilla has this function for auto intend so actually it IS possible.
The problem is there is no really working scope system in any of the Blitz editors ( at least none I've tested and used so far )


Damien Sturdy(Posted 2004) [#18]
WHat about my last idea?!


Curtastic(Posted 2004) [#19]

For instance, say you want to add an IF statement into some already indented code. Does the IDE immediately indent EVERYTHING after that line or does it wait to see if an EndIF appears first?

no matter how large your code file is, it could be instantly tabbed. Tabs dont have to be actually inserted, it is just a matter of where it draws the text.