I’ve put together a little reformat code script that adds some extra functionality to the IDE.
I’ve been working on the script on and off ever since I asked Norman for an option to turn off the automatic removal of empty parenthesis. Norman kindly reminded me about the ReformatCode system and gave me some initial pointers and ideas to get me started. He has also kindly fixed most of the bugs I’ve found.
-Pad the inside of parentheses with a space. So a(b,c) will become a( b,c )
-Pad the outside of parentheses with a space. So a(b,c) will become a (b,c)
-Pad empty parentheses with a space. So a() will become a( )
-Remove empty parentheses. So a() will become a
-Pad commas. So a(b,c) will become a(b, c)
-Pad operators. So a=b+c will become a = b + c
-Pad inline ifs so a=if(b=1,0,1) will become a=if (b=1,0,1)
-Pad before a line continuation mark (underscore)
-Aid with some common transpositions i.e. endif will become End If
-Comment replacement e.g. ’ will become // or vice versa
-Pad comments before and after the comment mark
-Code replacement, a++ (a=a+1), a+=1 (a=a+1), if a!=1 (if a<>1) etc.
-Macros, quickly insert pre-defined text with autocomplete description
-Automatic calculation of windows declare types
If you have any questions, feature requests or bug reports please post them below.
If something is formatting incorrectly for you, please post what you typed and what you expected to see on separate lines, thanks.
I would only suggest using this in version 2018r1 as there may be some issues with previous versions that have had bug fixes in the latest release. If you would like to know what these are because you’d like to us this on your current version then let me know and I’ll dig out the bug reports and let you know what you need to void.
I downloaded and added to the scripts folder of 2018r1.1, runnning the script gave me a lot of script errors.
[quote]Compiler error [11] Error found while compiling on line 311. Continue?
Compiler error [11] Error found while compiling on line 312. Continue?
Compiler error [2] Error found while compiling on line 312. Continue?
Compiler error [201] Error found while compiling on line 312. Continue?
Compiler error [11] Error found while compiling on line 320. Continue?
…
[/quote]
Am i missing something?
I think this will be awesome for me as well. Really miss i++ syntax. Add adding declares will be nice and easy
Oh, you dont run the script, you just put it in the Scripts folder and restart the IDE, it will then load and run from then on while you move around your code.
Glad Norman “reminded” you of this feature. As for me, I had no idea such a capability existed.
I’ve had this request (<https://xojo.com/issue/40097>) in since 2015 (and a similar request dating back to fogbugz era). Seem that the hooks were already there.
The macro idea was a bit of an ahha moment for me when playing with the reformat code system. It was working very well inserting multi line macros and it was a bit heartbreaking having to limit it to a single line when the bug was found.
Norman knows about the feature request so hopefully it will come out soon.
I’m sure a community driven library of useful code snippets will follow as soon as its implemented
It turns out that I’m kind of asleep this morning - I use Screenflow on the Mac, and do my Windows and Linux screen recordings in VMs, so I already have Animated GIF output - D’oh!
In the last year Xojo changed the way they format Select Case constructs. It used to be that Xojo would allow you to indent each Case clause. Like this:
Select Case RetCode
Case 1
MsgBox("A")
Case 2
MsgBox("B")
Case 3
MsgBox("C")
End Select
Now Xojo forces the Case clauses to be at the same indent level as the Select Case/End Select.
Select Case RetCode
Case 1
MsgBox("A")
Case 2
MsgBox("B")
Case 3
MsgBox("C")
End Select
This makes no sense to me because the Case clauses are children of the Select Case/End Select. Is this something that your code reformatter could be enhanced to handle?