Developers Jos Posted February 24, 2004 Developers Posted February 24, 2004 (edited) Been working on a script that cleans up the indentation of au3 scripts and though i would share it with you... It will replace the leading Spaces/Tabs with the correct number of spaces/tabs to make the script more reable. comments/suggestions are welcome EDIT: Updated with Continuation lines support.... EDIT: source now in a later post Edited February 25, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
CyberSlug Posted February 24, 2004 Posted February 24, 2004 Looks nice Does the script handle lines that are line continued and indented? I have a number of such lines in my AutoSense script. Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Developers Jos Posted February 24, 2004 Author Developers Posted February 24, 2004 (edited) nope... will look at that... tnx EDIT: Removed the remark.... don't know what happend but downloaded the original and that looks ok.. Edited February 25, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
GrahamS Posted February 24, 2004 Posted February 24, 2004 One suggestion. Often if I have a very complicated line of code then I hand format it (in AutoIt, using the line continuation character). It would be nice to be able to turn the formatting off and on again using keywords - these would have to contained in comments so as to avoid messing up the script. Perhaps ;;;Tidy-Off MsgBox(0, "", "Contrived example that will come out as a sort of table" & @LF &_ " 1 One" & @LF &_ " 2 Two") ;;;Tidy-On As for the script - great. When I'm reading other peoples scripts that don't indent then the first thing I do is go through and add spaces! Now I can do this automatically. Perhaps we can find a way to run all code samples sent to the forum through this script prior to being displayed GrahamS
Developers Jos Posted February 24, 2004 Author Developers Posted February 24, 2004 (edited) Perhaps we can find a way to run all code samples sent to the forum through this script prior to being displayed Must be possible... right Jon ??? Seriously... just update the above script to cope with continuations..It does 2 extra tabbings for the continued lines...Would that solve your issue ?? Edited February 24, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
GrahamS Posted February 24, 2004 Posted February 24, 2004 Seriously... just update the above script to cope with continuations.. It does 2 extra tabbings for the continued lines... Would that solve your issue ??Was about to say no, but then thought a bit more A little bit of reformatting on my part will achieve the effect I'm looking for and still be compatible with your modified script, i.e. MsgBox(0, "", _ "Contrived example that will come out as a sort of table" & @LF &_ " 1 One" & @LF &_ " 2 Two") should not be modified by your script Thanks GrahamS
Developers Jos Posted February 24, 2004 Author Developers Posted February 24, 2004 (edited) A little bit of reformatting on my part will achieve the effect I'm looking for and still be compatible with your modified script, i.e.Not sure if i understand this... the script removes ALL leading spaces and TAB characters and then start formatting. In case of a continuation the script will do the following: (assume you specified 3 spaces as the indent characters and i replaced a space by a dot just to show what it does) ...MsgBox(0, "", "Contrived example that will come out as a sort of table" & @LF &_ ........." 1 One" & @LF &_ ........." 2 Two") as Larry would say: Trust me...just run it and see what it does.... Edited February 24, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
GrahamS Posted February 24, 2004 Posted February 24, 2004 Let me see if I can explain. What I want to do, say, is to have all three lines in the message box text line up (I do this a lot using message box when I have multiple lines so that I can see how it will appear when the program is run). So, replacing spaces by dots, my original was .MsgBox(0, "", "Contrived example that will come out as a sort of table" & @LF &_ ..............." 1 One" & @LF &_ ..............." 2 Two") As you pointed out, when using an ident of 3 spaces it is tidied to look like ...MsgBox(0, "", "Contrived example that will come out as a sort of table" & @LF &_ ........." 1 One" & @LF &_ ........." 2 Two") Not what I want, since the quotes on line 2 are not lined up with the quote at the start of "Contrived... But what I realised was that I could reformat my original a bit to look like ...MsgBox(0, "", _ ........."Contrived example that will come out as a sort of table" & @LF &_ ........." 1 One" & @LF &_ ........." 2 Two") Has everything lined up like I want, plus when the tidy script is run on this it will basically leave it alone. So I'm happy. You can forget about my request for keywords to turn tidying off and on - I don't need it. So to paraphrase Larry - I trust you, I've seen what it does and I like it GrahamS
Administrators Jon Posted February 24, 2004 Administrators Posted February 24, 2004 When I'm reading other peoples scripts that don't indent then the first thing I do is go through and add spaces!David mocks me when I say that I have to do this to read his and C code. I'm completely code blind unless something is perfectly indented at tab size 2/4. If I can't see the obvious block structure from the other side of the room then it's just gibberish. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/
Developers Jos Posted February 24, 2004 Author Developers Posted February 24, 2004 ok ...understand now what you meant.... thanks for the feedback.. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Developers Jos Posted February 25, 2004 Author Developers Posted February 25, 2004 (edited) Added functionality to the Tidy Script that will change all Keyword/function/macros to proper case.EDIT 2/26:- update to be able to cope with Select inside Select. - created the possibility to run it agains the script you edit: Just compile the script to tidy.exe. create an userfunction in your editor to call tidy.exe "yourscripfilename" ....It will in this case create an backup called scriptname.old?.au3 where ? is an sequence number.EDIT: its available on Yahoo called "tidy.zip" ... it contains the script and needed tables. http://groups.yahoo.com/group/AutoItList/files/AU3/UTIL/ Edited February 26, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
steve8tch Posted February 26, 2004 Posted February 26, 2004 Where can we get hold of this script - I had a quick look in the usual places - couldn't find it.
Developers Jos Posted February 26, 2004 Author Developers Posted February 26, 2004 Where can we get hold of this script - I had a quick look in the usual places - couldn't find it.The script that you see listed is "it" ..... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
steve8tch Posted February 26, 2004 Posted February 26, 2004 Script won't run because functions.txt isn't present. Any thoughts?
Developers Jos Posted February 26, 2004 Author Developers Posted February 26, 2004 Script won't run because functions.txt isn't present.Any thoughts?ok ...understand now. I made the whole thing available on yahoo called "tidy.zip" ... it contains the script and needed tables. http://groups.yahoo.com/group/AutoItList/files/AU3/UTIL/ SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
steve8tch Posted February 26, 2004 Posted February 26, 2004 Gave this tidy up script an outing - it looks really good - my smaller scripts were tidied up nicely..but.. my big script (2500 lines... don't ask!!) didn't get tidied. All the leading spaces were removed and that was that. its not the end of the world but.. I thought I'd let you know. Keep up this great work.
Developers Jos Posted February 28, 2004 Author Developers Posted February 28, 2004 Added/changed the following in this version:- write warning comment line into the script when indentation fails like on old v3 scripts that don't have a Then at the end of a If statement.- Added the userfunctions and internal functions to the set to proper case.- Added Binary array search to speed it up a bit- Added Sort function to sort the input files- Changed the backup name from:XYZ.AU3.old1 to XYZ.old1.AU3- bug fixes in indentation logicTo download: http://www.hiddensoft.com/fileman/users/jdeb/tidy.zipDescription from the script:; Script Function: Tidy au3 scripts ; What does it do: ; 1. $TABCHAR -> Cleans up the indentation of au3 scripts with spaces or Tabs. ; 2. $PROPER -> When Set to 1: ; The script will also change all Functions/Keywords/Macros to proper case as defined in the ; files made available by Jon. ; $UserFunc -> When set to 1 ; Also All userfunctions from Userfunctions.txt and all FUNC in the script are loaded into ; the Functions table. Only works when $PROPER=1 ; 3. $VARS -> Script can chance all Variables to Uppercase or Lowercase. ; ; This script will prompt for an AutoItscript file lets say XYZ.AU3 ; It will create a new file called XYZ_N.AU3 that is properly indented with spaces or Tabs ; ; IT also has the possibility to run it agains the script you edit: ; 1. Just compile the script to tidy.exe. ; 2. create an userfunction in your editor to call tidy.exe "yourscripfilename" .... ; It will in this case create an backup called scriptname.old?.au3 where ? is an sequence number. ; When finished the original file is copied to XYZ.AU3.old1 and the original is replaced. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Developers Jos Posted February 28, 2004 Author Developers Posted February 28, 2004 Found some more "special situation" the script didn't coupe with correctly. Changed and uploaded the script (ver 0.2.10) If you find any more issue, please let me know... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Developers Jos Posted March 1, 2004 Author Developers Posted March 1, 2004 (edited) uploaded a new version (0.2.11) with some added functionality: $ENDFUNC_COMMENT-> Add a comment after EndFunc like : "EndFunc;==> FunctionName" $GEN_DOC-> 0=no 1=yes 2=prompt Generates documentation file with program logic and Xref reports for Variables and UDF's. Example Documentation: --snip-- 0067 ; =============================== 0068 ; Get input and check output file 0069 ; =============================== 0070 $FILE = "" 0071 +-If $CMDLINE[0] = 1 Then 0072 | $FILE = $CMDLINE[1] 0073 | $OFILE = StringReplace($FILE,'.au3','_x.au3') 0074 | FileRecycle($OFILE) 0075 +-Else 0076 | +-While Not FileExists($FILE) Or StringRight($FILE,4) <> '.au3' 0077 | | $FILE = FileOpenDialog( "...to Tidy?","", "AutoIt3(*.AU3)", 1 ) 0078 | | +-If @error = 1 Then 0079 | | | $RC = MsgBox(4100, "AutoIt3 Tidy", "Do you want to ....?" ) 0080 | | | If $RC = 6 Then Exit 0081 | | +-EndIf 0082 | +-Wend 0083 | $OFILE = StringReplace($FILE,'.au3','_n.au3') --snip-- ====================== === Xref reports ===== ====================== Function/Variable name ==> Row(col) col = char. position after the first non space/tab character == UserFunctions===================== _Doc_Functions => 568(31),725(6) _Doc_Variables => 592(20),709(6) _FileRead2Array => 154(1),161(1),168(1),687(6) BinarySearch => 566(8),595(7),597(7),624(6) == Variables ================================ $A_SIZE => 653(1),654(12),658(19) $ALL_REC => 693(1),698(4),699(1),701(1),701(13),704(24) $BS_RC => 54(8),566(36),568(19),595(32),597(34),624(54),640(1),643(1) $C_DIM => 668(5),669(26),670(18),670(50),671(25) Comments/Suggestions/Problems ? let me know... tnx Edited March 2, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now