xxaviarxx Posted December 14, 2015 Share Posted December 14, 2015 Is there a script, tool, add-on etc that can take a jumbled mess of code (as seen in my previous posts) and turn it into a nice, neat, and unjumbled mess of code that still is readable? Link to comment Share on other sites More sharing options...
TheDcoder Posted December 14, 2015 Share Posted December 14, 2015 (edited) Unfortunately, Nope! Sorry, I forgot about Tidy , But you can do it manually too, just follow Best Coding Practices TD Edited December 14, 2015 by TheDcoder Tidy... EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 14, 2015 Moderators Share Posted December 14, 2015 xxaviarxx,Yes - to some extent. The utility is called Tidy and it comes with the full SciTE4AutoIt3 installation which you can find here. It will indent properly, fix spacing, standardise spelling, etc. You also get quite a few other utilities to help you code in AutoIt in the same package.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
xxaviarxx Posted December 14, 2015 Author Share Posted December 14, 2015 Tidy i knew about and actively use. I'm talking about making the below code (for example), um not this horrible? This is from a price calculator I am working on for my guild to calculate how much an item is worth based on stats of the item, class type, and equipment type so we don't have those questions of how many points to I need for this item instead they can check themselves. Honestly my coding skills or lack thereof scares me when I try to debug this, and rest assured the rest of the code is just as bad if not worse in some cases.$Check1 = GUICtrlRead($StrInput) >= 60 Or GUICtrlRead($DexInput) >= 60 Or GUICtrlRead($EndInput) >= 60 Or GUICtrlRead($IntInput) >= 60 Or GUICtrlRead($SprInput) >= 60 $Check2 = (GUICtrlRead($StrInput) >= 60 And GUICtrlRead($DexInput) >= 60) Or (GUICtrlRead($StrInput) >= 60 And GUICtrlRead($EndInput) >= 60) Or (GUICtrlRead($StrInput) >= 60 And GUICtrlRead($IntInput) >= 60) Or (GUICtrlRead($StrInput) >= 60 And GUICtrlRead($SprInput) >= 60) Or (GUICtrlRead($DexInput) >= 60 And GUICtrlRead($EndInput) >= 60) Or (GUICtrlRead($DexInput) >= 60 And GUICtrlRead($IntInput) >= 60) Or (GUICtrlRead($DexInput) >= 60 And GUICtrlRead($SprInput) >= 60) Or (GUICtrlRead($EndInput) >= 60 And GUICtrlRead($IntInput) >= 60) Or (GUICtrlRead($EndInput) >= 60 And GUICtrlRead($SprInput) >= 60) Or (GUICtrlRead($IntInput) >= 60 And GUICtrlRead($SprInput) >= 60) $Check3 = (GUICtrlRead($StrInput) >= 60 And GUICtrlRead($DexInput) >= 60 And GUICtrlRead($EndInput) >= 60) Or (GUICtrlRead($StrInput) >= 60 And GUICtrlRead($DexInput) >= 60 And GUICtrlRead($IntInput) >= 60) Or (GUICtrlRead($StrInput) >= 60 And GUICtrlRead($DexInput) >= 60 And GUICtrlRead($SprInput) >= 60) Or (GUICtrlRead($StrInput) >= 60 And GUICtrlRead($EndInput) >= 60 And GUICtrlRead($IntInput) >= 60) Or (GUICtrlRead($StrInput) >= 60 And GUICtrlRead($EndInput) >= 60 And GUICtrlRead($SprInput) >= 60) Or (GUICtrlRead($StrInput) >= 60 And GUICtrlRead($IntInput) >= 60 And GUICtrlRead($SprInput) >= 60) Or (GUICtrlRead($DexInput) >= 60 And GUICtrlRead($EndInput) >= 60 And GUICtrlRead($IntInput) >= 60) Or (GUICtrlRead($DexInput) >= 60 And GUICtrlRead($EndInput) >= 60 And GUICtrlRead($SprInput) >= 60) Or (GUICtrlRead($DexInput) >= 60 And GUICtrlRead($IntInput) >= 60 And GUICtrlRead($SprInput) >= 60) Or (GUICtrlRead($EndInput) >= 60 And GUICtrlRead($IntInput) >= 60 And GUICtrlRead($SprInput) >= 60) $Check4 = (GUICtrlRead($StrInput) >= 60 And GUICtrlRead($DexInput) >= 60 And GUICtrlRead($EndInput) >= 60 And GUICtrlRead($IntInput) >= 60) Or (GUICtrlRead($StrInput) >= 60 And GUICtrlRead($DexInput) >= 60 And GUICtrlRead($EndInput) >= 60 And GUICtrlRead($SprInput) >= 60) Or (GUICtrlRead($StrInput) >= 60 And GUICtrlRead($EndInput) >= 60 And GUICtrlRead($IntInput) >= 60 And GUICtrlRead($SprInput) >= 60) Or (GUICtrlRead($DexInput) >= 60 And GUICtrlRead($EndInput) >= 60 And GUICtrlRead($IntInput) >= 60 And GUICtrlRead($SprInput) >= 60) $Check5 = GUICtrlRead($StrInput) >= 60 And GUICtrlRead($DexInput) >= 60 And GUICtrlRead($EndInput) >= 60 And GUICtrlRead($IntInput) >= 60 And GUICtrlRead($SprInput) >= 60expandcollapse popupIf ($Choice = "Jewelry") Then If ($StrTM >= -1) Then Select Case GUICtrlRead($StrInput) >= 0 And GUICtrlRead($StrInput) <= 24 $StrTM = -0.75 Case GUICtrlRead($StrInput) >= 25 And GUICtrlRead($StrInput) <= 49 $StrTM = -0.50 Case GUICtrlRead($StrInput) >= 50 And GUICtrlRead($StrInput) <= 59 $StrTM = -0.25 Case GUICtrlRead($StrInput) >= 60 And GUICtrlRead($StrInput) <= 64 $StrTM = 0.25 Case GUICtrlRead($StrInput) >= 65 And GUICtrlRead($StrInput) <= 70 $StrTM = 0.50 EndSelect EndIf If ($StrTM >= -1) Then Select Case GUICtrlRead($DexInput) >= 0 And GUICtrlRead($DexInput) <= 24 $DexTM = -0.75 Case GUICtrlRead($DexInput) >= 25 And GUICtrlRead($DexInput) <= 49 $DexTM = -0.50 Case GUICtrlRead($DexInput) >= 50 And GUICtrlRead($DexInput) <= 59 $DexTM = -0.25 Case GUICtrlRead($DexInput) >= 60 And GUICtrlRead($DexInput) <= 64 $DexTM = 0.25 Case GUICtrlRead($DexInput) >= 65 And GUICtrlRead($DexInput) <= 70 $DexTM = 0.50 EndSelect EndIf If ($DexTM >= -1) Then Select Case GUICtrlRead($EndInput) >= 0 And GUICtrlRead($EndInput) <= 24 $EndTm = -0.75 Case GUICtrlRead($EndInput) >= 25 And GUICtrlRead($EndInput) <= 49 $EndTm = -0.50 Case GUICtrlRead($EndInput) >= 50 And GUICtrlRead($EndInput) <= 59 $EndTm = -0.25 Case GUICtrlRead($EndInput) >= 60 And GUICtrlRead($EndInput) <= 64 $EndTm = 0.25 Case GUICtrlRead($EndInput) >= 65 And GUICtrlRead($EndInput) <= 70 $EndTm = 0.50 EndSelect EndIf If ($EndTm >= -1) Then Select Case GUICtrlRead($IntInput) >= 0 And GUICtrlRead($IntInput) <= 24 $IntTM = -0.75 Case GUICtrlRead($IntInput) >= 25 And GUICtrlRead($IntInput) <= 49 $IntTM = -0.50 Case GUICtrlRead($IntInput) >= 50 And GUICtrlRead($IntInput) <= 59 $IntTM = -0.25 Case GUICtrlRead($IntInput) >= 60 And GUICtrlRead($IntInput) <= 64 $IntTM = 0.25 Case GUICtrlRead($IntInput) >= 65 And GUICtrlRead($IntInput) <= 70 $IntTM = 0.50 EndSelect EndIf If ($IntTM >= -1) Then Select Case GUICtrlRead($SprInput) >= 0 And GUICtrlRead($SprInput) <= 24 $SprTM = -0.75 Case GUICtrlRead($SprInput) >= 25 And GUICtrlRead($SprInput) <= 49 $SprTM = -0.50 Case GUICtrlRead($SprInput) >= 50 And GUICtrlRead($SprInput) <= 59 $SprTM = -0.25 Case GUICtrlRead($SprInput) >= 60 And GUICtrlRead($SprInput) <= 64 $SprTM = 0.25 Case GUICtrlRead($SprInput) >= 65 And GUICtrlRead($SprInput) <= 70 $SprTM = 0.50 EndSelect If ($Check1 = True And $Check2 = False) Then $T2 = 1 EndIf If ($Check2 = True And $Check3 = False) Then $Check1 = False $T2 = 2 EndIf If ($Check3 = True And $Check4 = False) Then $Check1 = False $Check2 = False $T2 = 2.5 EndIf If ($Check4 = True And $Check5 = False) Then $Check1 = False $Check2 = False $Check3 = False $T2 = 3 EndIf If ($Check5 = True) Then $Check1 = False $Check2 = False $Check3 = False $Check4 = False $T2 = 3.5 EndIf EndIfGUICtrlSetData($RPOUTPUT, Round(((((GUICtrlRead($StrInput)) * (1 + ((GUICtrlRead($StrInput)) * ($StrTM / $MAX))) * $xStr) + (((GUICtrlRead($DexInput)) * (1 + ((GUICtrlRead($DexInput)) * ($DexTM / $MAX)))) * $xDex) + (((GUICtrlRead($EndInput)) * (1 + (((GUICtrlRead($EndInput)) * ($EndTm / $MAX))))) * $xEnd) + (((GUICtrlRead($IntInput)) * (1 + ((GUICtrlRead($IntInput)) * ($IntTM / $MAX)))) * $xInt) + (((GUICtrlRead($SprInput)) * (1 + ((GUICtrlRead($SprInput)) * ($SprTM / $MAX))) * $xSpr))) * $T2)))Ok I know the Jewelry one isn't so bad but there has to be way to make it short sweet and to the point for instance like in Java where you can do something like this.Case 1 Case 2 Case 3 $Var = 90 ; make all the cases1-3 the same value as $Var when called Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 14, 2015 Moderators Share Posted December 14, 2015 Tidy i knew about and actively use. I'm talking about making the below code (for example), um not this horrible? This is from a price calculator I am working on for my guild to calculate how much an item is worth based on stats of the item, class type, and equipment type so we don't have those questions of how many points to I need for this item instead they can check themselves. Honestly my coding skills or lack thereof scares me when I try to debug this, and rest assured the rest of the code is just as bad if not worse in some cases.So, you want an automated tool that will allow you to write sloppy code and then make it right for you? You know the answer to this question even before you ask; want your code to be well-planned, well-commented, and readable by others? Then write it that way. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 14, 2015 Moderators Share Posted December 14, 2015 xxaviarxx,The first of those checks could be done like this if you put the input ControlIDs into an array:$aInputs[] = [$StrInput, $StrInput, $EndInput, $IntInput, $SprInput] $bCheck1 = True For $i = 0 To UBound($aInputs) - 1 If GUICtrlRead($aInputs[$i]) < 60 Then $bCheck1 = False ExitLoop ; As no point in checking further EndIf Next ; $bCheck1 now either "All True" or "At least one False"The other checks could no doubt also be refined, but you need to use some additional parentheses to make sure that your Ands and Ors are correctly determined as at the moment the code gives no idea which conditions are grouped.The Select structures can be replaced by Switch like this:If ($StrTM >= -1) Then Switch Number(GUICtrlRead($StrInput)) Case 0 To 24 ; Use a range for the expression $StrTM = -0.75 Case 25 To 49 $StrTM = -0.50 Case 50 To 59 $StrTM = -0.25 Case 60 To 64 $StrTM = 0.25 Case 65 To 70 $StrTM = 0.50 Case Else ; ? EndSwitchUsing Switch also means you can do this:Case 1, 2, 3 ; Multiple expressions on the same line $Var = 90which nicely answers your final question.There are no real "rules" to this - much of it is a question of experience as to the best way to structure code. Anyway I am now out of this thread - game-related stuff is not for me.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
xxaviarxx Posted December 14, 2015 Author Share Posted December 14, 2015 So, you want an automated tool that will allow you to write sloppy code and then make it right for you? You know the answer to this question even before you ask; want your code to be well-planned, well-commented, and readable by others? Then write it that way.xxaviarxx,The first of those checks could be done like this if you put the input ControlIDs into an array:$aInputs[] = [$StrInput, $StrInput, $EndInput, $IntInput, $SprInput] $bCheck1 = True For $i = 0 To UBound($aInputs) - 1 If GUICtrlRead($aInputs[$i]) < 60 Then $bCheck1 = False ExitLoop ; As no point in checking further EndIf Next ; $bCheck1 now either "All True" or "At least one False"The other checks could no doubt also be refined, but you need to use some additional parentheses to make sure that your Ands and Ors are correctly determined as at the moment the code gives no idea which conditions are grouped.The Select structures can be replaced by Switch like this:If ($StrTM >= -1) Then Switch Number(GUICtrlRead($StrInput)) Case 0 To 24 ; Use a range for the expression $StrTM = -0.75 Case 25 To 49 $StrTM = -0.50 Case 50 To 59 $StrTM = -0.25 Case 60 To 64 $StrTM = 0.25 Case 65 To 70 $StrTM = 0.50 Case Else ; ? EndSwitchUsing Switch also means you can do this:Case 1, 2, 3 ; Multiple expressions on the same line $Var = 90which nicely answers your final question.There are no real "rules" to this - much of it is a question of experience as to the best way to structure code. Anyway I am now out of this thread - game-related stuff is not for me.M23@Logan Never said it had to be readable by others I was just wondering if there was a tool to make a mess of a code nice and neat. Don't get me wrong all of my code works perfectly the way it was intended to work, it's just a pain to debug it all if something did mess up for instance my equation took me 3 days of debugging to find 5-6 ()'s missing.@Melba Can you explain how the check system works? I noticed a similar system being used when i was doing a random number thing in a previous post but never understood how it actually worked so I couldn't use a system like that. The switch statement you used for the StrTm is what I was attempting and failing at horribly so I switched to the select statement, now I understand what I was doing wrong with your example. On that train of thought is there a way to do something to combine all of those if statements and switch statements or are they going to have to stay individual like how I have it at the present time? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 14, 2015 Moderators Share Posted December 14, 2015 xxaviarxx,... Anyway I am now out of this thread - game-related stuff is not for me.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
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