Kurto2021 Posted December 14, 2010 Share Posted December 14, 2010 (edited) I have some code here that I made a program for something I do here at work. It was originally really small but has kept getting bigger and bigger.....I am wondering if there is a some way I can add a loop in here or something so that the code is not so repetitive....when I change 1 line i have to change it about 50 times. how do I post the code in here? Between these tags: expandcollapse popup Edited December 14, 2010 by Jos example code tags Link to comment Share on other sites More sharing options... Moderators Melba23 Posted December 14, 2010 Melba23 Moderators 31.1k 477 I'm old, what's your excuse? Moderators Share Posted December 14, 2010 (edited) Kurto2021,Your code was unreadable, so I asked a Mod to fix it or remove it - you can see the result. It lookedas if the AutoIT code tags were not working properly for you. Try putting [code ] before and [/code ] after your posted code (but omit the trailing space - it is only there so the tags display here).Once we get some readable code, we can take a look at how we might help. M23Edit: Typnig! Edited December 14, 2010 by Melba23 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... Kurto2021 Posted December 14, 2010 Kurto2021 Active Members 67 1 Author Share Posted December 14, 2010 http://66.7.221.19/~oareplay/Opie/Big%20Group.au3 going to try this another way Link to comment Share on other sites More sharing options... Moderators Melba23 Posted December 14, 2010 Melba23 Moderators 31.1k 477 I'm old, what's your excuse? Moderators Share Posted December 14, 2010 Kurto2021, Got it this time. 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... Moderators Melba23 Posted December 14, 2010 Melba23 Moderators 31.1k 477 I'm old, what's your excuse? Moderators Share Posted December 14, 2010 Kurto2021, You need to learn about arrays and loops! I would suggest that you store the ControlIDs for your checkboxes in an array. Then you can loop through the aray to see which are checked and run the same code for each one that is. Here is a very simple script to show you what I mean: #include <GUIConstantsEx.au3> Global $aCheckbox[5] = [4] $hGUI = GUICreate("Test", 500, 500) $aCheckbox[1] = GUICtrlCreateCheckbox("One", 10, 10, 100, 20) $aCheckbox[2] = GUICtrlCreateCheckbox("Two", 10, 50, 100, 20) $aCheckbox[3] = GUICtrlCreateCheckbox("Three", 10, 90, 100, 20) $aCheckbox[4] = GUICtrlCreateCheckbox("Four", 10, 130, 100, 20) $hButton = GUICtrlCreateButton("Read", 10, 200, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton ; Loop through the checkboxes For $i = 1 To $aCheckbox[0] ; If one is checked If GUICtrlRead($aCheckbox[$i]) = 1 Then ; Run the code using that checkbox as input - the loop index tells you which one it is MsgBox(0, "Aha!", "Checkbox " & $i & " is checked!") EndIf Next EndSwitch WEnd I am afraid I am not rewriting the 2000-odd lines of your script, I leave that to you, but I am sure you can see how you might do it based on the above. Please came back again if you run into problems. 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...
Zedna Posted December 14, 2010 Share Posted December 14, 2010 As Melba said arrays can be handy here. Also using functions (Task1, Task2 here) is very important. Here is version shrinkedjust by using functions Task1(), Task2() It's without arrays mentioned by Melba expandcollapse popup#include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 703, 447, 193, 125) $AL = GUICtrlCreateCheckbox("Alabama", 32, 56, 89, 17) $AZ = GUICtrlCreateCheckbox("Arizona", 32, 80, 89, 17) $AR = GUICtrlCreateCheckbox("Arkansas", 32, 104, 81, 17) $CA = GUICtrlCreateCheckbox("California", 32, 128, 81, 17) $CO = GUICtrlCreateCheckbox("Colorado", 32, 152, 81, 17) $CT = GUICtrlCreateCheckbox("Connecticut", 32, 176, 89, 17) $DE = GUICtrlCreateCheckbox("Deleware", 32, 200, 81, 17) $DC = GUICtrlCreateCheckbox("DC", 32, 224, 89, 17) $FL = GUICtrlCreateCheckbox("Florida", 32, 248, 81, 17) $GA = GUICtrlCreateCheckbox("Georgia", 128, 56, 97, 17) $HI = GUICtrlCreateCheckbox("Hawaii", 128, 80, 97, 17) $ID = GUICtrlCreateCheckbox("Idaho", 128, 104, 97, 17) $IL = GUICtrlCreateCheckbox("Illinois", 128, 128, 97, 17) $IN = GUICtrlCreateCheckbox("Indiana", 128, 152, 97, 17) $IA = GUICtrlCreateCheckbox("Iowa", 128, 176, 97, 17) $KS = GUICtrlCreateCheckbox("Kansas", 128, 200, 97, 17) $KY = GUICtrlCreateCheckbox("Kentucky", 128, 224, 97, 17) $LA = GUICtrlCreateCheckbox("Louisiana", 128, 248, 97, 17) $ME = GUICtrlCreateCheckbox("Maine", 232, 56, 97, 17) $MD = GUICtrlCreateCheckbox("Maryland", 232, 80, 97, 17) $MA = GUICtrlCreateCheckbox("Massachusettes", 232, 104, 97, 17) $MI = GUICtrlCreateCheckbox("Michigan", 232, 128, 97, 17) $MO = GUICtrlCreateCheckbox("Missouri", 232, 152, 97, 17) $MS = GUICtrlCreateCheckbox("Mississippi", 232, 176, 97, 17) $MN = GUICtrlCreateCheckbox("Minnesota", 232, 200, 97, 17) $MT = GUICtrlCreateCheckbox("Montana", 232, 224, 97, 17) $NE = GUICtrlCreateCheckbox("Nebraska", 232, 248, 97, 17) $NH = GUICtrlCreateCheckbox("New Hampshire", 336, 56, 97, 17) $NJ = GUICtrlCreateCheckbox("New Jersey", 336, 80, 97, 17) $NM = GUICtrlCreateCheckbox("New Mexico", 336, 104, 97, 17) $NY = GUICtrlCreateCheckbox("New York", 336, 128, 97, 17) $NC = GUICtrlCreateCheckbox("North Carolina", 336, 152, 97, 17) $ND = GUICtrlCreateCheckbox("North Dakota", 336, 176, 97, 17) $OH = GUICtrlCreateCheckbox("Ohio", 336, 200, 97, 17) $OK = GUICtrlCreateCheckbox("Oklahoma", 336, 224, 97, 17) $OR = GUICtrlCreateCheckbox("Oregon", 336, 248, 97, 17) $PA = GUICtrlCreateCheckbox("Pennsylvania", 448, 56, 97, 17) $RI = GUICtrlCreateCheckbox("Rhode Island", 448, 80, 97, 17) $SC = GUICtrlCreateCheckbox("South Carolina", 448, 104, 97, 17) $TN = GUICtrlCreateCheckbox("Tennessee", 448, 128, 97, 17) $TX = GUICtrlCreateCheckbox("Texas", 448, 152, 97, 17) $UT = GUICtrlCreateCheckbox("Utah", 448, 176, 97, 17) $VT = GUICtrlCreateCheckbox("Vermont", 448, 200, 97, 17) $VA = GUICtrlCreateCheckbox("Virginia", 448, 224, 97, 17) $WV = GUICtrlCreateCheckbox("West Virginia", 448, 248, 97, 17) $WI = GUICtrlCreateCheckbox("Wisconsin", 560, 56, 97, 17) $KC = GUICtrlCreateCheckbox("Kansas City", 560, 80, 97, 17) $NYC = GUICtrlCreateCheckbox("NYC", 560, 104, 97, 17) $OHC = GUICtrlCreateCheckbox("Ohio Cities", 560, 128, 97, 17) $PHI = GUICtrlCreateCheckbox("Philadelphia", 560, 152, 97, 17) $STL = GUICtrlCreateCheckbox("St. Louis", 560, 176, 97, 17) $Group1 = GUICtrlCreateGroup("Fed Files", 30, 280, 420, 110) GUICtrlCreateGroup("", -99, -99, 1, 1) $Input1 = GUICtrlCreateInput("", 40, 298, 121, 21) $Input2 = GUICtrlCreateInput("", 40, 330, 121, 21) $Input3 = GUICtrlCreateInput("", 40, 362, 121, 21) $Input4 = GUICtrlCreateInput("", 176, 298, 121, 21) $Input5 = GUICtrlCreateInput("", 176, 330, 121, 21) $Input6 = GUICtrlCreateInput("", 176, 362, 121, 21) $Input7 = GUICtrlCreateInput("", 312, 298, 121, 21) $Input8 = GUICtrlCreateInput("", 312, 330, 121, 21) $Input9 = GUICtrlCreateInput("", 312, 362, 121, 21) $Group2 = GUICtrlCreateGroup("Diag Files", 490, 280, 150, 110) GUICtrlCreateGroup("", -99, -99, 1, 1) $Input10 = GUICtrlCreateInput("", 508, 298, 121, 21) $Input11 = GUICtrlCreateInput("", 508, 330, 121, 21) $Input12 = GUICtrlCreateInput("", 508, 362, 121, 21) $YearCombo = GUICtrlCreateCombo("0", 48, 16, 81, 25) $Retrieve = GUICtrlCreateButton("Retrieve FD / State", 72, 400, 105, 25, 0) $Procom = GUICtrlCreateButton("Procom", 200, 400, 113, 25, 0) $ProPOB = GUICtrlCreateButton("Ren / Backup PRO", 336, 400, 105, 25, 0) $Button4 = GUICtrlCreateButton("Button4", 464, 400, 121, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() $var1 = GUICtrlRead($Input1) $var2 = GUICtrlRead($Input2) $var3 = GUICtrlRead($Input3) $var4 = GUICtrlRead($Input4) $var5 = GUICtrlRead($Input5) $var6 = GUICtrlRead($Input6) $var7 = GUICtrlRead($Input7) $var8 = GUICtrlRead($Input8) $var9 = GUICtrlRead($Input9) $var10 = GUICtrlRead($Input10) $var11 = GUICtrlRead($Input11) $var12 = GUICtrlRead($Input12) If GUICtrlRead($YearCombo) > 7 Then $Decade = '0' Else $Decade = '1' EndIf $Year = GUICtrlRead($YearCombo) $System = "P" $ddpath = "C:\fx\" & $decade & $Year & "\dd\" $ddfile = "dd"& $Year & "p$fd" $ddfile = "DD" & $Year & $System & "$FD" $Ffile = $decade & $Year & $System & "$F" $wsmfile = $decade & $Year & $System & "$WSM" $diagfile = $decade & $Year & $System & "$D" ;$StDiagfile = $decade & $Year & $System & "$D"&$State $printfile = $decade & $Year & $System & "$P" Switch $nMsg Case $Retrieve $delete = MSGbox(4, "Warning", "Would you like to delete all files from C:\fx\" & $decade & $year & "\dd\") If $delete = 6 then FileDelete("C:\fx\" & $decade & $year & "\dd\*.*") _FileCopy("G:\WFX32\" & $decade & $Year & $System & "\" & $ddfile & ".*", $ddpath) _FileCopy("G:\WFX32\" & $decade & $Year & $System & "\" & $Ffile & ".*", $ddpath) _FileCopy("G:\WFX32\" & $decade & $Year & $System & "\" & $wsmfile & ".*", $ddpath) _FileCopy("G:\WFX32\" & $decade & $Year & $System & "\" & $printfile & ".*", $ddpath) _FileCopy("G:\WFX32\" & $decade & $Year & $System & "\" & $diagfile & ".*", $ddpath) FileSetAttrib($ddpath & $ddfile & ".*", "-R") FileSetAttrib($ddpath & $Ffile & ".*", "-R") FileSetAttrib($ddpath & $wsmfile & ".*", "-R") FileSetAttrib($ddpath & $printfile & ".*", "-R") FileSetAttrib($ddpath & $diagfile & ".*", "-R") $time2 = FileGetTime("C:\fx\10\dd\10p$f.dat", 0) If Not @error Then $yyyymd2 = $time2[1] & "/" & $time2[2] & "/" & $time2[0] MsgBox(1, "title", "retrieved") ;GUICtrlSetData($Message, $yyyymd2) EndIf EndIf Task1($AL, "AL", True) ; roc Task1($AZ, "AZ") Task1($AR, "AR") Task1($CA, "CA") Task1($CO, "CO") Task1($CT, "CT") Task1($DE, "DE") Task1($DC, "DC") Task1($FL, "FL") Task1($GA, "GA") Task1($HI, "HI") Task1($ID, "ID") Task1($IL, "IL") Task1($IN, "IN") Task1($IA, "IA") Task1($KS, "KS") Task1($KY, "KY") Task1($LA, "LA") Task1($ME, "ME") Task1($MD, "MD") Task1($MA, "MA") Task1($MI, "MI") Task1($MO, "MO") Task1($MS, "MS") Task1($MN, "MN") Task1($MT, "MT") Task1($NE, "NE") Task1($NH, "NH") Task1($NJ, "NJ") Task1($NM, "NM") Task1($NY, "NY") Task1($NC, "NC") Task1($ND, "ND") Task1($OH, "OH") Task1($OK, "OK") Task1($OR, "OR") Task1($PA, "PA") Task1($RI, "RI") Task1($SC, "SC") Task1($TN, "TN") Task1($TX, "TX") Task1($UT, "UT") Task1($VT, "VT") Task1($VA, "VA") Task1($WV, "WV") Task1($WI, "WI") Task1($KC, "KC") Task1($NYC, "NYC") Task1($OHC, "OHC") Task1($PHI, "PHI") Task1($STL, "STL") Task2($Var1) Task2($Var2) Task2($Var3) Task2($Var4) Task2($Var5) Task2($Var6) Task2($Var7) Task2($Var8) Task2($Var9) Task2($Var10) Task2($Var11) Task2($Var12) Case $Procom Run("C:\os2\execute\procom" & $year & ".exe", "c:\fx\" & $decade & $Year & "\") Case $PROPOB $RENPRO = msgbox(4, "Warning", "Do you want to delete the PRO files and rename POB files to PRO. This will also zip the Pro files and back them up on H:\Biggroup\STD") If $RENPRO = 6 Then FileDelete("C:\wfx32\print\*.pro") FileCopy("C:\wfx32\print\*.pob", "C:\wfx32\print\*.pro", 1) FileDelete("C:\wfx32\print\*.pob") Run("c:\wfx32\print\pkzip.exe P" & $Year & "QCPRO.zip *.pro","") FileCopy("C:\wfx32\print\P" & $Year & "QCPRO.zip", "H:\Biggroup\std\", 1) EndIf Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _FileCopy($fromFile, $tofile) Local $FOF_RESPOND_YES = 16 Local $FOF_SIMPLEPROGRESS = 256 $winShell = ObjCreate("shell.application") $winShell.namespace($tofile).CopyHere($fromFile, $FOF_RESPOND_YES) EndFunc ;==>_FileCopy Func Task1($state_var, $state, $roc = False) If GUICtrlRead($state_var) = 1 then FileCopy("P:\temp\dd" & $Year & "p$" & $state & ".*", "C:\fx\" & $decade & $Year & "\dd\*.*", 9) $time = FileGetTime($ddpath & "DD" & $Year & "P$"& $State & ".dat", 0) if $time[3] > 11 Then if $time[3] = 12 then $hour = $time[3] Else $hour = $time[3] - 12 EndIf $AMPM = "PM" Else if $time[3] = 0 Then $hour = 12 Else $hour = $time[3] Endif $AMPM = "AM" EndIf If Not @error Then $yyyymdi = $time[1] & "/" & $time[2] & "/" & $time[0] & " " & $hour & ":" & $time[4] & " " & $AMPM Else $yyyymdi = "No File Local" EndIf $continue = MsgBox(1,$State &" File Date", $yyyymdi) if $continue = 1 Then Runwait("draw" & $Year & ".exe " & $ddpath & "dd"& $Year &"p$"& $State & " " & $ddpath & $ddfile) RunWait("Garbo" & $Year & ".exe " & $ddpath & "dd" & $Year & "p$"& $State & " " & $ddpath & $DDfile, "c:\fx\" & $decade & $Year & "\dd\") RunWait("Greta" & $Year & ".exe " & $ddpath & "dd" & $Year & "p$"& $State & " " & $ddpath & $DDfile, "c:\fx\" & $decade & $Year & "\dd\") If $roc Then Runwait("roc" & $Year & ".exe " & $ddpath & "dd" & $Year & "p$"& $State & " " & " " & $ddpath & $Ffile, "c:\fx\" & $decade & $Year & "\dd\") EndIf EndIf EndFunc ; Task1 Func Task2($Var) If $Var <> '' then $Search = FileFindFirstFile("P:\temp\" & $Var & ".dat") If $Search = -1 Then ; -1 means file doesn't exist msgbox(1, "Error", $Var & " was not found on P:\temp") Else FileCopy("P:\temp\" & $Var &".*" , "C:\fx\" & $decade & $Year & "\dd\*.*", 9) $time = FileGetTime($ddpath & $Var & ".dat", 0) if $time[3] > 11 Then if $time[3] = 12 then $hour = $time[3] Else $hour = $time[3] - 12 EndIf $AMPM = "PM" Else if $time[3] = 0 Then $hour = 12 Else $hour = $time[3] Endif $AMPM = "AM" EndIf If Not @error Then $yyyymdi = $time[1] & "/" & $time[2] & "/" & $time[0] & " " & $hour & ":" & $time[4] & " " & $AMPM Else $yyyymdi = "No File Local" EndIf $continue = MsgBox(1,$Var &" File Date", $yyyymdi) if $continue = 1 Then Runwait("draw" & $Year & ".exe " & $ddpath & $Var & " " & $ddpath & $ddfile) RunWait("Garbo" & $Year & ".exe " & $ddpath & $Var & " " & $ddpath & $DDfile, "c:\fx\" & $decade & $Year & "\dd\") RunWait("Greta" & $Year & ".exe " & $ddpath & $Var & " " & $ddpath & $DDfile, "c:\fx\" & $decade & $Year & "\dd\") EndIf EndIf EndIf EndFunc ; Task2 Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
Kurto2021 Posted December 14, 2010 Author Share Posted December 14, 2010 yeah I guess I should have said I wasn't expecting people to rewrite it.....I was just trying to figure out if there was some way to do it in a loop so that if I add an additional item I am not redoing it 50+ times. I am sure you noticed that for every state I repeat the exact same code along with some cities and some variable fed data. Just to let you know what the is ....we write tax software and everyday at a certain time I have to pull all the files in that each programmer has worked on and released. Then build them into one file......I run a few tests on each file draw to compile and check for code errors, garbo to check for print errors and greta to make sure all cursor movement is valid....once I verify these items I then use roc....which slams each one into one big file in order for me to put the entire program together..... Link to comment Share on other sites More sharing options...
Zedna Posted December 14, 2010 Share Posted December 14, 2010 yeah I guess I should have said I wasn't expecting people to rewrite it.....I was just trying to figure out if there was some way to do it in a loop so that if I add an additional item I am not redoing it 50+ times. I am sure you noticed that for every state I repeat the exact same code along with some cities and some variable fed data.Have you read my previous post? Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
Zedna Posted December 14, 2010 Share Posted December 14, 2010 Cleaned up little bit more, especially cleaned main loop ... (but still without arrays) expandcollapse popup#include <GUIConstants.au3> Global $Decade, $Year #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 703, 447, 193, 125) $AL = GUICtrlCreateCheckbox("Alabama", 32, 56, 89, 17) $AZ = GUICtrlCreateCheckbox("Arizona", 32, 80, 89, 17) $AR = GUICtrlCreateCheckbox("Arkansas", 32, 104, 81, 17) $CA = GUICtrlCreateCheckbox("California", 32, 128, 81, 17) $CO = GUICtrlCreateCheckbox("Colorado", 32, 152, 81, 17) $CT = GUICtrlCreateCheckbox("Connecticut", 32, 176, 89, 17) $DE = GUICtrlCreateCheckbox("Deleware", 32, 200, 81, 17) $DC = GUICtrlCreateCheckbox("DC", 32, 224, 89, 17) $FL = GUICtrlCreateCheckbox("Florida", 32, 248, 81, 17) $GA = GUICtrlCreateCheckbox("Georgia", 128, 56, 97, 17) $HI = GUICtrlCreateCheckbox("Hawaii", 128, 80, 97, 17) $ID = GUICtrlCreateCheckbox("Idaho", 128, 104, 97, 17) $IL = GUICtrlCreateCheckbox("Illinois", 128, 128, 97, 17) $IN = GUICtrlCreateCheckbox("Indiana", 128, 152, 97, 17) $IA = GUICtrlCreateCheckbox("Iowa", 128, 176, 97, 17) $KS = GUICtrlCreateCheckbox("Kansas", 128, 200, 97, 17) $KY = GUICtrlCreateCheckbox("Kentucky", 128, 224, 97, 17) $LA = GUICtrlCreateCheckbox("Louisiana", 128, 248, 97, 17) $ME = GUICtrlCreateCheckbox("Maine", 232, 56, 97, 17) $MD = GUICtrlCreateCheckbox("Maryland", 232, 80, 97, 17) $MA = GUICtrlCreateCheckbox("Massachusettes", 232, 104, 97, 17) $MI = GUICtrlCreateCheckbox("Michigan", 232, 128, 97, 17) $MO = GUICtrlCreateCheckbox("Missouri", 232, 152, 97, 17) $MS = GUICtrlCreateCheckbox("Mississippi", 232, 176, 97, 17) $MN = GUICtrlCreateCheckbox("Minnesota", 232, 200, 97, 17) $MT = GUICtrlCreateCheckbox("Montana", 232, 224, 97, 17) $NE = GUICtrlCreateCheckbox("Nebraska", 232, 248, 97, 17) $NH = GUICtrlCreateCheckbox("New Hampshire", 336, 56, 97, 17) $NJ = GUICtrlCreateCheckbox("New Jersey", 336, 80, 97, 17) $NM = GUICtrlCreateCheckbox("New Mexico", 336, 104, 97, 17) $NY = GUICtrlCreateCheckbox("New York", 336, 128, 97, 17) $NC = GUICtrlCreateCheckbox("North Carolina", 336, 152, 97, 17) $ND = GUICtrlCreateCheckbox("North Dakota", 336, 176, 97, 17) $OH = GUICtrlCreateCheckbox("Ohio", 336, 200, 97, 17) $OK = GUICtrlCreateCheckbox("Oklahoma", 336, 224, 97, 17) $OR = GUICtrlCreateCheckbox("Oregon", 336, 248, 97, 17) $PA = GUICtrlCreateCheckbox("Pennsylvania", 448, 56, 97, 17) $RI = GUICtrlCreateCheckbox("Rhode Island", 448, 80, 97, 17) $SC = GUICtrlCreateCheckbox("South Carolina", 448, 104, 97, 17) $TN = GUICtrlCreateCheckbox("Tennessee", 448, 128, 97, 17) $TX = GUICtrlCreateCheckbox("Texas", 448, 152, 97, 17) $UT = GUICtrlCreateCheckbox("Utah", 448, 176, 97, 17) $VT = GUICtrlCreateCheckbox("Vermont", 448, 200, 97, 17) $VA = GUICtrlCreateCheckbox("Virginia", 448, 224, 97, 17) $WV = GUICtrlCreateCheckbox("West Virginia", 448, 248, 97, 17) $WI = GUICtrlCreateCheckbox("Wisconsin", 560, 56, 97, 17) $KC = GUICtrlCreateCheckbox("Kansas City", 560, 80, 97, 17) $NYC = GUICtrlCreateCheckbox("NYC", 560, 104, 97, 17) $OHC = GUICtrlCreateCheckbox("Ohio Cities", 560, 128, 97, 17) $PHI = GUICtrlCreateCheckbox("Philadelphia", 560, 152, 97, 17) $STL = GUICtrlCreateCheckbox("St. Louis", 560, 176, 97, 17) $Group1 = GUICtrlCreateGroup("Fed Files", 30, 280, 420, 110) GUICtrlCreateGroup("", -99, -99, 1, 1) $Input1 = GUICtrlCreateInput("", 40, 298, 121, 21) $Input2 = GUICtrlCreateInput("", 40, 330, 121, 21) $Input3 = GUICtrlCreateInput("", 40, 362, 121, 21) $Input4 = GUICtrlCreateInput("", 176, 298, 121, 21) $Input5 = GUICtrlCreateInput("", 176, 330, 121, 21) $Input6 = GUICtrlCreateInput("", 176, 362, 121, 21) $Input7 = GUICtrlCreateInput("", 312, 298, 121, 21) $Input8 = GUICtrlCreateInput("", 312, 330, 121, 21) $Input9 = GUICtrlCreateInput("", 312, 362, 121, 21) $Group2 = GUICtrlCreateGroup("Diag Files", 490, 280, 150, 110) GUICtrlCreateGroup("", -99, -99, 1, 1) $Input10 = GUICtrlCreateInput("", 508, 298, 121, 21) $Input11 = GUICtrlCreateInput("", 508, 330, 121, 21) $Input12 = GUICtrlCreateInput("", 508, 362, 121, 21) $YearCombo = GUICtrlCreateCombo("0", 48, 16, 81, 25) $Retrieve = GUICtrlCreateButton("Retrieve FD / State", 72, 400, 105, 25, 0) $Procom = GUICtrlCreateButton("Procom", 200, 400, 113, 25, 0) $ProPOB = GUICtrlCreateButton("Ren / Backup PRO", 336, 400, 105, 25, 0) $Button4 = GUICtrlCreateButton("Button4", 464, 400, 121, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Retrieve GetDecadeYear() $System = "P" $ddpath = "C:\fx\" & $decade & $Year & "\dd\" $ddfile = "dd"& $Year & "p$fd" $ddfile = "DD" & $Year & $System & "$FD" $Ffile = $decade & $Year & $System & "$F" $wsmfile = $decade & $Year & $System & "$WSM" $diagfile = $decade & $Year & $System & "$D" ;$StDiagfile = $decade & $Year & $System & "$D"&$State $printfile = $decade & $Year & $System & "$P" $delete = MSGbox(4, "Warning", "Would you like to delete all files from C:\fx\" & $decade & $year & "\dd\") If $delete = 6 then FileDelete("C:\fx\" & $decade & $year & "\dd\*.*") _FileCopy("G:\WFX32\" & $decade & $Year & $System & "\" & $ddfile & ".*", $ddpath) _FileCopy("G:\WFX32\" & $decade & $Year & $System & "\" & $Ffile & ".*", $ddpath) _FileCopy("G:\WFX32\" & $decade & $Year & $System & "\" & $wsmfile & ".*", $ddpath) _FileCopy("G:\WFX32\" & $decade & $Year & $System & "\" & $printfile & ".*", $ddpath) _FileCopy("G:\WFX32\" & $decade & $Year & $System & "\" & $diagfile & ".*", $ddpath) FileSetAttrib($ddpath & $ddfile & ".*", "-R") FileSetAttrib($ddpath & $Ffile & ".*", "-R") FileSetAttrib($ddpath & $wsmfile & ".*", "-R") FileSetAttrib($ddpath & $printfile & ".*", "-R") FileSetAttrib($ddpath & $diagfile & ".*", "-R") $time2 = FileGetTime("C:\fx\10\dd\10p$f.dat", 0) If Not @error Then $yyyymd2 = $time2[1] & "/" & $time2[2] & "/" & $time2[0] MsgBox(1, "title", "retrieved") ;GUICtrlSetData($Message, $yyyymd2) EndIf EndIf Task1($AL, "AL", True) ; roc Task1($AZ, "AZ") Task1($AR, "AR") Task1($CA, "CA") Task1($CO, "CO") Task1($CT, "CT") Task1($DE, "DE") Task1($DC, "DC") Task1($FL, "FL") Task1($GA, "GA") Task1($HI, "HI") Task1($ID, "ID") Task1($IL, "IL") Task1($IN, "IN") Task1($IA, "IA") Task1($KS, "KS") Task1($KY, "KY") Task1($LA, "LA") Task1($ME, "ME") Task1($MD, "MD") Task1($MA, "MA") Task1($MI, "MI") Task1($MO, "MO") Task1($MS, "MS") Task1($MN, "MN") Task1($MT, "MT") Task1($NE, "NE") Task1($NH, "NH") Task1($NJ, "NJ") Task1($NM, "NM") Task1($NY, "NY") Task1($NC, "NC") Task1($ND, "ND") Task1($OH, "OH") Task1($OK, "OK") Task1($OR, "OR") Task1($PA, "PA") Task1($RI, "RI") Task1($SC, "SC") Task1($TN, "TN") Task1($TX, "TX") Task1($UT, "UT") Task1($VT, "VT") Task1($VA, "VA") Task1($WV, "WV") Task1($WI, "WI") Task1($KC, "KC") Task1($NYC, "NYC") Task1($OHC, "OHC") Task1($PHI, "PHI") Task1($STL, "STL") Task2($Input1) Task2($Input2) Task2($Input3) Task2($Input4) Task2($Input5) Task2($Input6) Task2($Input7) Task2($Input8) Task2($Input9) Task2($Input10) Task2($Input11) Task2($Input12) Case $Procom GetDecadeYear() Run("C:\os2\execute\procom" & $year & ".exe", "c:\fx\" & $decade & $Year & "\") Case $PROPOB $RENPRO = msgbox(4, "Warning", "Do you want to delete the PRO files and rename POB files to PRO. This will also zip the Pro files and back them up on H:\Biggroup\STD") If $RENPRO = 6 Then GetDecadeYear() FileDelete("C:\wfx32\print\*.pro") FileCopy("C:\wfx32\print\*.pob", "C:\wfx32\print\*.pro", 1) FileDelete("C:\wfx32\print\*.pob") Run("c:\wfx32\print\pkzip.exe P" & $Year & "QCPRO.zip *.pro","") FileCopy("C:\wfx32\print\P" & $Year & "QCPRO.zip", "H:\Biggroup\std\", 1) EndIf Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _FileCopy($fromFile, $tofile) Local $FOF_RESPOND_YES = 16 Local $FOF_SIMPLEPROGRESS = 256 $winShell = ObjCreate("shell.application") $winShell.namespace($tofile).CopyHere($fromFile, $FOF_RESPOND_YES) EndFunc ;==>_FileCopy Func Task1($state_var, $state, $roc = False) If GUICtrlRead($state_var) = 1 then FileCopy("P:\temp\dd" & $Year & "p$" & $state & ".*", "C:\fx\" & $decade & $Year & "\dd\*.*", 9) $time = FileGetTime($ddpath & "DD" & $Year & "P$"& $State & ".dat", 0) if $time[3] > 11 Then if $time[3] = 12 then $hour = $time[3] Else $hour = $time[3] - 12 EndIf $AMPM = "PM" Else if $time[3] = 0 Then $hour = 12 Else $hour = $time[3] Endif $AMPM = "AM" EndIf If Not @error Then $yyyymdi = $time[1] & "/" & $time[2] & "/" & $time[0] & " " & $hour & ":" & $time[4] & " " & $AMPM Else $yyyymdi = "No File Local" EndIf $continue = MsgBox(1,$State &" File Date", $yyyymdi) if $continue = 1 Then Runwait("draw" & $Year & ".exe " & $ddpath & "dd"& $Year &"p$"& $State & " " & $ddpath & $ddfile) RunWait("Garbo" & $Year & ".exe " & $ddpath & "dd" & $Year & "p$"& $State & " " & $ddpath & $DDfile, "c:\fx\" & $decade & $Year & "\dd\") RunWait("Greta" & $Year & ".exe " & $ddpath & "dd" & $Year & "p$"& $State & " " & $ddpath & $DDfile, "c:\fx\" & $decade & $Year & "\dd\") If $roc Then Runwait("roc" & $Year & ".exe " & $ddpath & "dd" & $Year & "p$"& $State & " " & " " & $ddpath & $Ffile, "c:\fx\" & $decade & $Year & "\dd\") EndIf EndIf EndFunc ; Task1 Func Task2($control) $Var = GUICtrlRead($control) If $Var <> '' then $Search = FileFindFirstFile("P:\temp\" & $Var & ".dat") If $Search = -1 Then ; -1 means file doesn't exist msgbox(1, "Error", $Var & " was not found on P:\temp") Else FileCopy("P:\temp\" & $Var &".*" , "C:\fx\" & $decade & $Year & "\dd\*.*", 9) $time = FileGetTime($ddpath & $Var & ".dat", 0) if $time[3] > 11 Then if $time[3] = 12 then $hour = $time[3] Else $hour = $time[3] - 12 EndIf $AMPM = "PM" Else if $time[3] = 0 Then $hour = 12 Else $hour = $time[3] Endif $AMPM = "AM" EndIf If Not @error Then $yyyymdi = $time[1] & "/" & $time[2] & "/" & $time[0] & " " & $hour & ":" & $time[4] & " " & $AMPM Else $yyyymdi = "No File Local" EndIf $continue = MsgBox(1,$Var &" File Date", $yyyymdi) if $continue = 1 Then Runwait("draw" & $Year & ".exe " & $ddpath & $Var & " " & $ddpath & $ddfile) RunWait("Garbo" & $Year & ".exe " & $ddpath & $Var & " " & $ddpath & $DDfile, "c:\fx\" & $decade & $Year & "\dd\") RunWait("Greta" & $Year & ".exe " & $ddpath & $Var & " " & $ddpath & $DDfile, "c:\fx\" & $decade & $Year & "\dd\") EndIf EndIf EndIf EndFunc ; Task2 Func GetDecadeYear() If GUICtrlRead($YearCombo) > 7 Then $Decade = '0' Else $Decade = '1' EndIf $Year = GUICtrlRead($YearCombo) EndFunc Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search 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