Leoj Posted June 6, 2007 Share Posted June 6, 2007 I want to not only reduce the length of this script but improve its functionality. Currently it supports spitting out HTML/CSS to display pictures on your computer... but only a maximum of 8. I would like to have it go up to ~60 pictures (will be using tabs). I know I need to be using arrays and so therefore I ask for help =). Please take a moment to look at my script and maybe even run it so you get a better idea of what it does. expandcollapse popup$message = "Choose the image file to be uploaded." $title = "" $filepath = "" #include <Process.au3> #include <GUIConstants.au3> ; == GUI generated with Koda == $Form1 = GUICreate("Page Wizard: Picture Sheet", 1114, 697, 100, 100, -1, $WS_EX_ACCEPTFILES) GUICtrlCreateLabel("File or URL Location and Comment:", 16, 16, 237, 21) $Input1 = GUICtrlCreateInput("", 16, 48, 217, 27, -1, $WS_EX_CLIENTEDGE) GUICtrlSetState(-1,$GUI_DROPACCEPTED) $Edit1 = GUICtrlCreateEdit("", 16, 80, 321, 81, $ES_AUTOVSCROLL+$WS_VSCROLL, $WS_EX_CLIENTEDGE) $Input2 = GUICtrlCreateInput("", 16, 168, 217, 27, -1, $WS_EX_CLIENTEDGE) GUICtrlSetState(-1,$GUI_DROPACCEPTED) $Edit2 = GUICtrlCreateEdit("", 16, 200, 321, 81, $ES_AUTOVSCROLL+$WS_VSCROLL, $WS_EX_CLIENTEDGE) $Input3 = GUICtrlCreateInput("", 16, 288, 217, 27, -1, $WS_EX_CLIENTEDGE) GUICtrlSetState(-1,$GUI_DROPACCEPTED) $Edit3 = GUICtrlCreateEdit("", 16, 320, 321, 81, $ES_AUTOVSCROLL+$WS_VSCROLL, $WS_EX_CLIENTEDGE) $Input4 = GUICtrlCreateInput("", 16, 408, 217, 27, -1, $WS_EX_CLIENTEDGE) GUICtrlSetState(-1,$GUI_DROPACCEPTED) $Edit4 = GUICtrlCreateEdit("", 16, 440, 321, 81, $ES_AUTOVSCROLL+$WS_VSCROLL, $WS_EX_CLIENTEDGE) $Input5 = GUICtrlCreateInput("", 360, 48, 217, 27, -1, $WS_EX_CLIENTEDGE) GUICtrlSetState(-1,$GUI_DROPACCEPTED) $Edit5 = GUICtrlCreateEdit("", 360, 80, 321, 81, $ES_AUTOVSCROLL+$WS_VSCROLL, $WS_EX_CLIENTEDGE) $Input6 = GUICtrlCreateInput("", 360, 168, 217, 27, -1, $WS_EX_CLIENTEDGE) GUICtrlSetState(-1,$GUI_DROPACCEPTED) $Edit6 = GUICtrlCreateEdit("", 360, 200, 321, 81, $ES_AUTOVSCROLL+$WS_VSCROLL, $WS_EX_CLIENTEDGE) $Input7 = GUICtrlCreateInput("", 360, 288, 217, 27, -1, $WS_EX_CLIENTEDGE) GUICtrlSetState(-1,$GUI_DROPACCEPTED) $Edit7 = GUICtrlCreateEdit("", 360, 320, 321, 81, $ES_AUTOVSCROLL+$WS_VSCROLL, $WS_EX_CLIENTEDGE) $Input8 = GUICtrlCreateInput("", 360, 408, 217, 27, -1, $WS_EX_CLIENTEDGE) GUICtrlSetState(-1,$GUI_DROPACCEPTED) $Edit8 = GUICtrlCreateEdit("", 360, 440, 321, 81, $ES_AUTOVSCROLL+$WS_VSCROLL, $WS_EX_CLIENTEDGE) $Button1 = GUICtrlCreateButton("Browse...", 248, 48, 89, 25) $Button2 = GUICtrlCreateButton("Browse...", 248, 168, 89, 25) $Button3 = GUICtrlCreateButton("Browse...", 248, 288, 89, 25) $Button4 = GUICtrlCreateButton("Browse...", 248, 408, 89, 25) $Button5 = GUICtrlCreateButton("Browse...", 592, 48, 89, 25) $Button6 = GUICtrlCreateButton("Browse...", 592, 168, 89, 25) $Button7 = GUICtrlCreateButton("Browse...", 592, 288, 89, 25) $Button8 = GUICtrlCreateButton("Browse...", 592, 408, 89, 25) GUICtrlCreateLabel("Extra Options:", 16, 536, 86, 20) $Input9 = GUICtrlCreateInput("Page Title", 16, 568, 241, 24, -1, $WS_EX_CLIENTEDGE) $Checkbox1 = GUICtrlCreateCheckbox("Enable", 264, 568, 73, 25) $Input10 = GUICtrlCreateInput("Page Header", 16, 600, 241, 24, -1, $WS_EX_CLIENTEDGE) $Checkbox2 = GUICtrlCreateCheckbox("Enable", 264, 600, 73, 25) GUICtrlCreateLabel("Actions:", 360, 536, 59, 20) $Button10 = GUICtrlCreateButton("Save", 360, 568, 81, 25) $Button11 = GUICtrlCreateButton("Preview", 600, 568, 91, 25) $Button12 = GUICtrlCreateButton("Open Last Saved", 460, 568, 121, 25) GUISetState(@SW_SHOW) $pic1 = GUICtrlRead($input1) $pic2 = GUICtrlRead($input2) $pic3 = GUICtrlRead($input3) $pic4 = GUICtrlRead($input4) $pic5 = GUICtrlRead($input5) $pic6 = GUICtrlRead($input6) $pic7 = GUICtrlRead($input7) $pic8 = GUICtrlRead($input8) $noimg = "noimg.jpg" $comment1 = GUICtrlRead($Edit1) $comment2 = GUICtrlRead($Edit2) $comment3 = GUICtrlRead($Edit3) $comment4 = GUICtrlRead($Edit4) $comment5 = GUICtrlRead($Edit5) $comment6 = GUICtrlRead($Edit6) $comment7 = GUICtrlRead($Edit7) $comment8 = GUICtrlRead($Edit8) $height = 697 $previewTitle = "" $2Group1 = GUICtrlCreateGroup($previewTitle, 697, 8, 401, ($height-16)) ;;;;header;;;;; $header = "" $2label1 = GUICtrlCreateLabel($header, 840, 20, 300, 19) ;;;;left side pictures;;;; $2Pic1 = GUICtrlCreatePic($noimg, 729, 40, 161, 129) $2Pic2 = GUICtrlCreatePic($noimg, 729, 200, 161, 129) $2Pic3 = GUICtrlCreatePic($noimg, 729, 360, 161, 129) $2Pic4 = GUICtrlCreatePic($noimg, 729, 520, 161, 129) ;;;;right side pictures;;;; $2Pic5 = GUICtrlCreatePic($noimg, 905, 40, 161, 129) $2Pic6 = GUICtrlCreatePic($noimg, 905, 200, 161, 129) $2Pic7 = GUICtrlCreatePic($noimg, 905, 360, 161, 129) $2Pic8 = GUICtrlCreatePic($noimg, 905, 520, 161, 129) ;;;;comment labels: left side;;;; $comLabel1 = GUICtrlCreateLabel("", 729, 176, '', 19) $comLabel2 = GUICtrlCreateLabel("", 729, 336, '', 19) $comLabel3 = GUICtrlCreateLabel("", 729, 496, '', 19) $comLabel4 = GUICtrlCreateLabel("", 729, 656, '', 19) ;;;;comment labels: right side;;;; $comLabel5 = GUICtrlCreateLabel("", 905, 176, '', 19) $comLabel6 = GUICtrlCreateLabel("", 905, 336, '', 19) $comLabel7 = GUICtrlCreateLabel("", 905, 496, '', 19) $comLabel8 = GUICtrlCreateLabel("", 905, 656, '', 19) Func preview() $pic1 = GUICtrlRead($input1) $pic2 = GUICtrlRead($input2) $pic3 = GUICtrlRead($input3) $pic4 = GUICtrlRead($input4) $pic5 = GUICtrlRead($input5) $pic6 = GUICtrlRead($input6) $pic7 = GUICtrlRead($input7) $pic8 = GUICtrlRead($input8) $noimg = "noimg.jpg" If $pic1 = "" Then $pic1 = $noimg EndIf If $pic2 = "" Then $pic2 = $noimg EndIf If $pic3 = "" Then $pic3 = $noimg EndIf If $pic4 = "" Then $pic4 = $noimg EndIf If $pic5 = "" Then $pic5 = $noimg EndIf If $pic6 = "" Then $pic6 = $noimg EndIf If $pic7 = "" Then $pic7 = $noimg EndIf If $pic8 = "" Then $pic8 = $noimg EndIf $comment1 = GUICtrlRead($Edit1) $comment2 = GUICtrlRead($Edit2) $comment3 = GUICtrlRead($Edit3) $comment4 = GUICtrlRead($Edit4) $comment5 = GUICtrlRead($Edit5) $comment6 = GUICtrlRead($Edit6) $comment7 = GUICtrlRead($Edit7) $comment8 = GUICtrlRead($Edit8) $height = 697 ;;$Form2 = GUICreate("Preview", 417, $height, 349, 135) If GUICtrlRead($Checkbox1) = 1 Then $previewTitle = GUICtrlRead($input9) Else $previewTitle = "" EndIf ;;;;title;;;; GUICtrlSetData($2Group1, $previewTitle) ;;;;header;;;;; $header = GUICtrlRead($Input10) If GUICtrlRead($Checkbox2) = 1 Then GUICtrlSetData($2label1, $header) EndIf ;;;;left side;;;; GUICtrlSetImage($2Pic1, $pic1) GUICtrlSetImage($2Pic2, $pic2) GUICtrlSetImage($2Pic3, $pic3) GUICtrlSetImage($2Pic4, $pic4) ;;;;right side;;;; GUICtrlSetImage($2Pic5, $pic5) GUICtrlSetImage($2Pic6, $pic6) GUICtrlSetImage($2Pic7, $pic7) GUICtrlSetImage($2Pic8, $pic8) If GUICtrlRead($Edit1) <> "" Then $length1 = StringLen(GUICtrlRead($Edit1)) If $length1 > 20 Then $com1 = StringTrimRight(GUICtrlRead($Edit1), ($length1-20)) Else $com1 = GUICtrlRead($Edit1) EndIf GUICtrlSetData($comLabel1, $com1&"...") EndIf If GUICtrlRead($Edit2) <> "" Then $length2 = StringLen(GUICtrlRead($Edit2)) If $length2 > 20 Then $com2 = StringTrimRight(GUICtrlRead($Edit2), ($length2-20)) Else $com2 = GUICtrlRead($Edit2) EndIf GUICtrlSetData($comLabel2, $com2&"...") EndIf If GUICtrlRead($Edit3) <> "" Then $length3 = StringLen(GUICtrlRead($Edit3)) If $length3 > 20 Then $com3 = StringTrimRight(GUICtrlRead($Edit3), ($length3-20)) Else $com3 = GUICtrlRead($Edit3) EndIf GUICtrlSetData($comLabel3, $com3&"...") EndIf If GUICtrlRead($Edit4) <> "" Then $length4 = StringLen(GUICtrlRead($Edit4)) If $length4 > 20 Then $com4 = StringTrimRight(GUICtrlRead($Edit4), ($length4-20)) Else $com4 = GUICtrlRead($Edit4) EndIf GUICtrlSetData($comLabel4, $com4&"...") EndIf If GUICtrlRead($Edit8) <> "" Then $length8 = StringLen(GUICtrlRead($Edit8)) If $length8 > 20 Then $com8 = StringTrimRight(GUICtrlRead($Edit8), ($length8-20)) Else $com8 = GUICtrlRead($Edit8) EndIf GUICtrlSetData($comLabel8, $com8&"...") EndIf If GUICtrlRead($Edit7) <> "" Then $length7 = StringLen(GUICtrlRead($Edit7)) If $length7 > 20 Then $com7 = StringTrimRight(GUICtrlRead($Edit7), ($length7-20)) Else $com7 = GUICtrlRead($Edit7) EndIf GUICtrlSetData($comLabel7, $com7&"...") EndIf If GUICtrlRead($Edit6) <> "" Then $length6 = StringLen(GUICtrlRead($Edit6)) If $length6 > 20 Then $com6 = StringTrimRight(GUICtrlRead($Edit6), ($length6-20)) Else $com6 = GUICtrlRead($Edit6) EndIf GUICtrlSetData($comLabel6, $com6&"...") EndIf If GUICtrlRead($Edit5) <> "" Then $length5 = StringLen(GUICtrlRead($Edit5)) If $length5 > 20 Then $com5 = StringTrimRight(GUICtrlRead($Edit5), ($length5-20)) Else $com5 = GUICtrlRead($Edit5) EndIf GUICtrlSetData($comLabel5, $com5&"...") EndIf Return '' EndFunc While 1 $msg = GuiGetMsg() Select Case $msg = $Button1 Call("pic1Browse") Case $msg = $Button2 Call("pic2Browse") Case $msg = $Button3 Call("pic3Browse") Case $msg = $Button4 Call("pic4Browse") Case $msg = $Button5 Call("pic5Browse") Case $msg = $Button6 Call("pic6Browse") Case $msg = $Button7 Call("pic7Browse") Case $msg = $Button8 Call("pic8Browse") Case $msg = $Button10 Call("save") Case $msg = $Button11 Call("preview") Case $msg = $Button12 Call("showLastSaved") Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;;;;;; EndSelect WEnd Exit Func pic1Browse() $pic1 = FileOpenDialog($message, @WorkingDir & "\", "Images (*.jpg;*.bmp)", 1 + 4 ) If @error Then Else $lastDir = $pic1 $pic1 = StringReplace($pic1, "|", @CRLF) GUICtrlSetData($input1, $pic1) EndIf EndFunc Func pic2Browse() $pic2 = FileOpenDialog($message, @WorkingDir & "\", "Images (*.jpg;*.bmp)", 1 + 4 ) If @error Then Else $pic2 = StringReplace($pic2, "|", @CRLF) GUICtrlSetData($input2, $pic2) EndIf EndFunc Func pic3Browse() $pic3 = FileOpenDialog($message, @WorkingDir & "\", "Images (*.jpg;*.bmp)", 1 + 4 ) If @error Then Else $pic3 = StringReplace($pic3, "|", @CRLF) GUICtrlSetData($input3, $pic3) EndIf EndFunc Func pic4Browse() $pic4 = FileOpenDialog($message, @WorkingDir & "\", "Images (*.jpg;*.bmp)", 1 + 4 ) If @error Then Else $pic4 = StringReplace($pic4, "|", @CRLF) GUICtrlSetData($input4, $pic4) EndIf EndFunc Func pic5Browse() $pic5 = FileOpenDialog($message, @WorkingDir & "\", "Images (*.jpg;*.bmp)", 1 + 4 ) If @error Then Else $pic5 = StringReplace($pic5, "|", @CRLF) GUICtrlSetData($input5, $pic5) EndIf EndFunc Func pic6Browse() $pic6 = FileOpenDialog($message, @WorkingDir & "\", "Images (*.jpg;*.bmp)", 1 + 4 ) If @error Then Else $pic6 = StringReplace($pic6, "|", @CRLF) GUICtrlSetData($input6, $pic6) EndIf EndFunc Func pic7Browse() $pic7 = FileOpenDialog($message, @WorkingDir & "\", "Images (*.jpg;*.bmp)", 1 + 4 ) If @error Then Else $pic7 = StringReplace($pic7, "|", @CRLF) GUICtrlSetData($input7, $pic7) EndIf EndFunc Func pic8Browse() $pic8 = FileOpenDialog($message, @WorkingDir & "\", "Images (*.jpg;*.bmp)", 1 + 4 ) If @error Then Else $pic8 = StringReplace($pic8, "|", @CRLF) GUICtrlSetData($input8, $pic8) EndIf EndFunc Func save() $comment1 = GUICtrlRead($Edit1) $comment2 = GUICtrlRead($Edit2) $comment3 = GUICtrlRead($Edit3) $comment4 = GUICtrlRead($Edit4) $comment5 = GUICtrlRead($Edit5) $comment6 = GUICtrlRead($Edit6) $comment7 = GUICtrlRead($Edit7) $comment8 = GUICtrlRead($Edit8) $pic1 = GUICtrlRead($input1) $pic2 = GUICtrlRead($input2) $pic3 = GUICtrlRead($input3) $pic4 = GUICtrlRead($input4) $pic5 = GUICtrlRead($input5) $pic6 = GUICtrlRead($input6) $pic7 = GUICtrlRead($input7) $pic8 = GUICtrlRead($input8) $header = GUICtrlRead($input10) $noDisplay = "noimg.jpg" If StringInStr($pic1, "\") Then $pic1 = "file:\\\" & $pic1 If StringInStr($pic1, "#") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic1, "!") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic1, "$") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic1, "@") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic1, "^") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic1, "*") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic1, ")") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic1, "(") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic1, "&") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' Else ;;nothing EndIf ElseIf StringInStr($pic1, "/") Then ;;$pic1 is all good ElseIf $pic1 = "" Then $pic1 = $noDisplay Else MsgBox(0,"Error","There was an error processing the first image.") Return '' EndIf If StringInStr($pic2, "\") Then $pic2 = "file:\\\" & $pic2 If StringInStr($pic2, "#") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic2, "!") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic2, "$") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic2, "@") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic2, "^") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic2, "*") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic2, ")") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic2, "(") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic2, "&") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' Else ;;nothing EndIf ElseIf StringInStr($pic2, "/") Then ;;$pic1 is all good ElseIf $pic2 = "" Then $pic2 = $noDisplay Else MsgBox(0,"Error","There was an error processing the second image.") Return '' EndIf If StringInStr($pic3, "\") Then $pic3 = "file:\\\" & $pic3 If StringInStr($pic3, "#") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic3, "!") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic3, "$") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic3, "@") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic3, "^") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic3, "*") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic3, ")") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic3, "(") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic3, "&") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' Else ;;nothing EndIf ElseIf StringInStr($pic3, "/") Then ;;$pic1 is all good ElseIf $pic3 = "" Then $pic3 = $noDisplay Else MsgBox(0,"Error","There was an error processing the third image.") Return '' EndIf If StringInStr($pic4, "\") Then $pic4 = "file:\\\" & $pic4 If StringInStr($pic4, "#") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic4, "!") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic4, "$") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic4, "@") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic4, "^") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic4, "*") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic4, ")") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic4, "(") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic4, "&") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' Else ;;nothing EndIf ElseIf StringInStr($pic4, "/") Then ;;$pic1 is all good ElseIf $pic4 = "" Then $pic4 = $noDisplay Else MsgBox(0,"Error","There was an error processing the fourth image.") Return '' EndIf If StringInStr($pic5, "\") Then $pic5 = "file:\\\" & $pic5 If StringInStr($pic5, "#") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic5, "!") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic5, "$") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic5, "@") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic5, "^") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic5, "*") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic5, ")") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic5, "(") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic5, "&") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' Else ;;nothing EndIf ElseIf StringInStr($pic5, "/") Then ;;$pic1 is all good ElseIf $pic5 = "" Then $pic5 = $noDisplay Else MsgBox(0,"Error","There was an error processing the fifth image.") Return '' EndIf If StringInStr($pic6, "\") Then $pic6 = "file:\\\" & $pic6 If StringInStr($pic6, "#") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic6, "!") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic6, "$") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic6, "@") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic6, "^") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic6, "*") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic6, ")") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic6, "(") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic6, "&") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' Else ;;nothing EndIf ElseIf StringInStr($pic6, "/") Then ;;$pic1 is all good ElseIf $pic6 = "" Then $pic6 = $noDisplay Else MsgBox(0,"Error","There was an error processing the sixth image.") Return '' EndIf If StringInStr($pic7, "\") Then $pic7 = "file:\\\" & $pic7 If StringInStr($pic7, "#") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic7, "!") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic7, "$") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic7, "@") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic7, "^") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic7, "*") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic7, ")") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic7, "(") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic7, "&") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' Else ;;nothing EndIf ElseIf StringInStr($pic7, "/") Then ;;$pic1 is all good ElseIf $pic7 = "" Then $pic7 = $noDisplay Else MsgBox(0,"Error","There was an error processing the seventh image.") Return '' EndIf If StringInStr($pic8, "\") Then $pic8 = "file:\\\" & $pic8 If StringInStr($pic8, "#") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic8, "!") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic8, "$") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic8, "@") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic8, "^") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic8, "*") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic8, ")") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic8, "(") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' ElseIf StringInStr($pic8, "&") Then MsgBox(0,"Error","Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return '' Else ;;nothing EndIf ElseIf StringInStr($pic8, "/") Then ;;$pic1 is all good ElseIf $pic8 = "" Then $pic8 = $noDisplay Else MsgBox(0,"Error","There was an error processing the eigth image.") Return '' EndIf If GUICtrlRead($Checkbox1) = 1 Then $title = GUICtrlRead($input9) Else $title = "" EndIf $MyDocsFolder = "::{450D8FBA-AD25-11D0-98A8-0800361B1103}" $filepath = FileSaveDialog( "Choose a name.", $MyDocsFolder, "HTML (*.htm;*.html)", 2, "") If @error Then ;;MsgBox(4096,"","Save cancelled.") Else ;;MsgBox(4096,"","You chose " & $filepath) $file1 = FileOpen($filepath & ".html", 2) If $file1 = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ;;start code... FileWriteLine($file1, "<HTML>") FileWriteLine($file1, "<HEAD><TITLE>" & $title & "</TITLE>") FileWriteLine($file1, "<style>p.header{ color:maroon; } p.textColor{ color:green; width:500px; } td.picture{ border:1px solid black; } td.comment{ background-color:#B2C0D8; } table.main{ background-color:#E4EAF2; border-color:#C2CFDF; }</style>") FileWriteLine($file1, "</HEAD>") FileWriteLine($file1, "<BODY>") FileWriteLine($file1, "<TABLE CLASS='main' ALIGN='CENTER'>") ;;header If GUICtrlRead($Checkbox2) = 1 Then FileWriteLine($file1, "<TR>") FileWriteLine($file1, "<TD COLSPAN='2' ALIGN='CENTER' CLASS='headerTd'>") FileWriteLine($file1, "<P CLASS='header'>" & $header & "</P>") FileWriteLine($file1, "</TD>") FileWriteLine($file1, "</TR>") EndIf ;;first image row If $pic1 <> $noDisplay OR $pic5 <> $noDisplay Then FileWriteLine($file1, "<TR>") FileWriteLine($file1, "<TD ALIGN='CENTER' CLASS='picture'>") If $pic1 <> $noDisplay Then FileWriteLine($file1, "<A HREF='" & $pic1 & "'><IMG SRC='" & $pic1 & "' WIDTH='' HEIGHT='400' BORDER='0' BORDER='0'></A>") EndIf FileWriteLine($file1, "</TD>") FileWriteLine($file1, "<TD ALIGN='CENTER' CLASS='picture'>") If $pic5 <> $noDisplay Then FileWriteLine($file1, "<A HREF='" & $pic5 & "'><IMG SRC='" & $pic5 & "' WIDTH='' HEIGHT='400' BORDER='0'></A>") EndIf FileWriteLine($file1, "</TD>") FileWriteLine($file1, "</TR>") EndIf ;;first comment row If $comment1 <> "" OR $comment5 <> "" Then FileWriteLine($file1, "<TR>") FileWriteLine($file1, "<TD ALIGN='CENTER' CLASS='comment'>") FileWriteLine($file1, "<P CLASS='textColor'>" & $comment1 & "</P>") FileWriteLine($file1, "</TD>") FileWriteLine($file1, "<TD ALIGN='CENTER' CLASS='comment'>") FileWriteLine($file1, "<P CLASS='textColor'>" & $comment5 & "</P>") FileWriteLine($file1, "</TD>") FileWriteLine($file1, "</TR>") EndIf ;;second image row If $pic2 <> $noDisplay OR $pic6 <> $noDisplay Then FileWriteLine($file1, "<TR>") FileWriteLine($file1, "<TD ALIGN='CENTER' CLASS='picture'>") If $pic2 <> $noDisplay Then FileWriteLine($file1, "<A HREF='" & $pic2 & "'><IMG SRC='" & $pic2 & "' WIDTH='' HEIGHT='400' BORDER='0'></A>") EndIf FileWriteLine($file1, "</TD>") FileWriteLine($file1, "<TD ALIGN='CENTER' CLASS='picture'>") If $pic6 <> $noDisplay Then FileWriteLine($file1, "<A HREF='" & $pic6 & "'><IMG SRC='" & $pic6 & "' WIDTH='' HEIGHT='400' BORDER='0'></A>") EndIf FileWriteLine($file1, "</TD>") FileWriteLine($file1, "</TR>") EndIf ;;second comment row If $comment2 <> "" OR $comment6 <> "" Then FileWriteLine($file1, "<TR>") FileWriteLine($file1, "<TD ALIGN='CENTER' CLASS='comment'>") FileWriteLine($file1, "<P CLASS='textColor'>" & $comment2 & "</P>") FileWriteLine($file1, "</TD>") FileWriteLine($file1, "<TD ALIGN='CENTER' CLASS='comment'>") FileWriteLine($file1, "<P CLASS='textColor'>" & $comment6 & "</P>") FileWriteLine($file1, "</TD>") FileWriteLine($file1, "</TR>") EndIf ;;third image row If $pic3 <> $noDisplay OR $pic7 <> $noDisplay Then FileWriteLine($file1, "<TR>") FileWriteLine($file1, "<TD ALIGN='CENTER' CLASS='picture'>") If $pic3 <> $noDisplay Then FileWriteLine($file1, "<A HREF='" & $pic3 & "'><IMG SRC='" & $pic3 & "' WIDTH='' HEIGHT='400' BORDER='0'></A>") EndIf FileWriteLine($file1, "</TD>") FileWriteLine($file1, "<TD ALIGN='CENTER' CLASS='picture'>") If $pic7 <> $noDisplay Then FileWriteLine($file1, "<A HREF='" & $pic7 & "'><IMG SRC='" & $pic7 & "' WIDTH='' HEIGHT='400' BORDER='0'></A>") EndIf FileWriteLine($file1, "</TD>") FileWriteLine($file1, "</TR>") EndIf ;;third comment row If $comment3 <> "" OR $comment7 <> "" Then FileWriteLine($file1, "<TR>") FileWriteLine($file1, "<TD ALIGN='CENTER' CLASS='comment'>") FileWriteLine($file1, "<P CLASS='textColor'>" & $comment3 & "</P>") FileWriteLine($file1, "</TD>") FileWriteLine($file1, "<TD ALIGN='CENTER' CLASS='comment'>") FileWriteLine($file1, "<P CLASS='textColor'>" & $comment7 & "</P>") FileWriteLine($file1, "</TD>") FileWriteLine($file1, "</TR>") EndIf ;;fourth image row If $pic4 <> $noDisplay OR $pic8 <> $noDisplay Then FileWriteLine($file1, "<TR>") FileWriteLine($file1, "<TD ALIGN='CENTER' CLASS='picture'>") If $pic4 <> $noDisplay Then FileWriteLine($file1, "<A HREF='" & $pic4 & "'><IMG SRC='" & $pic4 & "' WIDTH='' HEIGHT='400' BORDER='0'></A>") EndIf FileWriteLine($file1, "</TD>") FileWriteLine($file1, "<TD ALIGN='CENTER' CLASS='picture'>") If $pic8 <> $noDisplay Then FileWriteLine($file1, "<A HREF='" & $pic8 & "'><IMG SRC='" & $pic8 & "' WIDTH='' HEIGHT='400' BORDER='0'></A>") EndIf FileWriteLine($file1, "</TD>") FileWriteLine($file1, "</TR>") EndIf ;;fourth comment row If $comment4 <> "" OR $comment8 <> "" Then FileWriteLine($file1, "<TR>") FileWriteLine($file1, "<TD ALIGN='CENTER' CLASS='comment'>") FileWriteLine($file1, "<P CLASS='textColor'>" & $comment4 & "</P>") FileWriteLine($file1, "</TD>") FileWriteLine($file1, "<TD ALIGN='CENTER' CLASS='comment'>") FileWriteLine($file1, "<P CLASS='textColor'>" & $comment8 & "</P>") FileWriteLine($file1, "</TD>") FileWriteLine($file1, "</TR>") EndIf ;;end code... FileWriteLine($file1, "</TABLE>") FileWriteLine($file1, "</BODY>") FileWriteLine($file1, "<HTML>") FileClose($file1) EndIf EndFunc Func showLastSaved() $checkpath = $filepath & ".html" If $checkpath = ".html" Then MsgBox(0,"Error", "You have not saved yet.") Else ;;MsgBox(0,"Your last save location was", $filepath & ".html") ShellExecute($filepath & ".html") EndIf ;;Run($filepath & ".html") ;$rc = _RunDos("run " & $filepath & ".html") EndFunc Thanks for any help. Link to comment Share on other sites More sharing options...
Leoj Posted June 6, 2007 Author Share Posted June 6, 2007 --Could I even have it write the HTML using array'd $var's? ~Thanks Link to comment Share on other sites More sharing options...
smashly Posted June 7, 2007 Share Posted June 7, 2007 (edited) Hi, To shorten the length of the Input, Edit and Browse button creation I just put it in an Array via a loop. It turns 30 lines of code into 10 lines of code. You can also do the same for the browse functions you've written and this turns 65 lines into 9 lines of code. Can have just 1 browse function that accommodates all the browse buttons. Lots of ways to loop controls into arrays to shorten your script. Also the string functions you've written could be done in much the same manner. expandcollapse popup#include <Process.au3> #include <GUIConstants.au3> Global $Input[9], $Edit[9], $Browse[9] $Form1 = GUICreate("Page Wizard: Picture Sheet", 1114, 697, 100, 100, -1, $WS_EX_ACCEPTFILES) GUICtrlCreateLabel("File or URL Location and Comment:", 16, 16, 237, 21) $x = 16 $y = 48 For $i = 1 To 8 If $i = 5 Then $x = 360 $y = 48 EndIf $Input[$i] = GUICtrlCreateInput("", $x, $y, 217, 27, -1, $WS_EX_CLIENTEDGE) GUICtrlSetState(-1,$GUI_DROPACCEPTED) $Browse[$i] = GUICtrlCreateButton("Browse...", $x + 232, $y, 89, 25) $Edit[$i] = GUICtrlCreateEdit("", $x, $y + 32, 321, 81, $ES_AUTOVSCROLL+$WS_VSCROLL, $WS_EX_CLIENTEDGE) $y = $y + 120 Next GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect For $c = 1 To 8 Select Case $msg = $Browse[$c] PicBrowse($c) EndSelect Next WEnd Func PicBrowse($p) Dim $Pic[9] $Pic[$p] = FileOpenDialog("Choose the image file to be uploaded.", @WorkingDir & "\", "Images (*.jpg;*.bmp)", 1 + 4 ) If @error Then Else $lastDir = $Pic[$p] $Pic[$p] = StringReplace($Pic[$p], "|", @CRLF) GUICtrlSetData($Input[$p], $Pic[$p]) EndIf EndFunc Will post back more a bit later if you like.. Cheers Edited June 7, 2007 by smashly Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 7, 2007 Share Posted June 7, 2007 Here's a start, it Tidy's and compiles without errors, but you're on your own for testing. All I did was take every repeated operation I saw and put it in a loop with arrays. I know you at least were reading the condition of the CheckBoxes wrong, so I put a tweak in for that: expandcollapse popup$title = "" $filepath = "" $noimg = "noimg.jpg" #include <Process.au3> #include <GUIConstants.au3> ; Create GUI $GUI_Title = "Page Wizard: Picture Sheet" $Form1 = GUICreate($GUI_Title, 1114, 697, 100, 100, -1, $WS_EX_ACCEPTFILES) GUICtrlCreateLabel("File or URL Location and Comment:", 16, 16, 237, 21) ; Create Arrays $PictureCount = 8 $ArraySize = $PictureCount + 1 ; Array indexes are [1] thru [$PictureCount] Global $Inputs[$ArraySize] ; Was Input1 thru 8 Global $Edits[$ArraySize] ; Was Edit1 thru 8 Global $BrowseButtons[$ArraySize] ; Was Button1 thru 8 Global $FileURLs[$ArraySize] ; Was Pic1 thru 8 Global $Comments[$ArraySize] ; Was Comment1 thru 8 Global $Pictures[$ArraySize] ; Was 2Pic1 thru 8 ; Create picture controls, 4 per column $CtrlX = 16 $ButtnX = 248 $Row = 0 For $i = 1 To $PictureCount $Inputs[$i] = GUICtrlCreateInput("", $CtrlX, 48 + (120 * $Row), 217, 27, -1, $WS_EX_CLIENTEDGE) $Edits[$i] = GUICtrlCreateEdit("", $CtrlX, 80 + (120 * $Row), 321, 81, $ES_AUTOVSCROLL + $WS_VSCROLL, $WS_EX_CLIENTEDGE) $BrowseButtons[$i] = GUICtrlCreateButton("Browse...", $ButtnX, 48 + (120 * $Row), 89, 25) $Row += 1 If $Row = 4 Then ; New column $Row = 0 $CtrlX += 344 $ButtnX += 344 EndIf Next GUICtrlCreateLabel("Extra Options:", 16, 536, 86, 20) $Input_Title = GUICtrlCreateInput("Page Title", 16, 568, 241, 24, -1, $WS_EX_CLIENTEDGE) $Chkbox_TitleEnable = GUICtrlCreateCheckbox("Enable", 264, 568, 73, 25) $Input_Header = GUICtrlCreateInput("Page Header", 16, 600, 241, 24, -1, $WS_EX_CLIENTEDGE) $Chkbox_HeaderEnable = GUICtrlCreateCheckbox("Enable", 264, 600, 73, 25) GUICtrlCreateLabel("Actions:", 360, 536, 59, 20) $Button_Save = GUICtrlCreateButton("Save", 360, 568, 81, 25) $Button_Preview = GUICtrlCreateButton("Preview", 600, 568, 91, 25) $Button_OpenLast = GUICtrlCreateButton("Open Last Saved", 460, 568, 121, 25) ; Create group box $height = 697 $previewTitle = "" $2Group1 = GUICtrlCreateGroup($previewTitle, 697, 8, 401, ($height - 16)) ; Create header $header = "" $2label1 = GUICtrlCreateLabel($header, 840, 20, 300, 19) ; Create picture controls, 4 per column $PictX = 729 $Row = 0 For $i = 1 To $PictureCount $Pictures[$i] = GUICtrlCreatePic($noimg, $PictX, 40 + (160 * $Row), 161, 129) $Comments[$i] = GUICtrlCreateLabel("", $PictX, 176 + (160 * $Row), 161, 19) $Row += 1 If $Row = 4 Then ; New column $Row = 0 $PictX += 176 EndIf Next ; Show GUI GUISetState(@SW_SHOW) ; Main program loop While 1 $msg = GUIGetMsg() Switch $msg Case $msg = $Button_Save _Save() Case $msg = $Button_Preview _Preview() Case $msg = $Button_OpenLast _ShowLastSaved() Case $msg = $GUI_EVENT_CLOSE Exit Case Else For $i = 1 To $PictureCount If $msg = $BrowseButtons[$i] Then _PicBrowse($i) ExitLoop EndIf Next EndSwitch WEnd Func _Save() Local $i Local $noDisplay = "noimg.jpg" For $i = 1 To $PictureCount $Comments[$i] = GUICtrlRead($Edits[$i]) $FileURLs[$i] = GUICtrlRead($Inputs[$i]) If StringRegExp($FileURLs[$i], "[#!$@\^*)(&]") Then MsgBox(16, "Error", "Please rename all directories that contain #, !, $, @, ^, *, ), ( or & signs and try again.") Return 0 ElseIf StringInStr($FileURLs[$i], "/") Then ; File URL is all good ElseIf $FileURLs[$i] = "" Then $FileURLs[$i] = $noDisplay Else MsgBox(16, "Error", "There was an error processing image number: " & $i) EndIf Next $header = GUICtrlRead($Input_Header) If ControlCommand($GUI_Title, "", $Chkbox_TitleEnable, "IsChecked") = 1 Then $title = GUICtrlRead($Input_Title) Else $title = "" EndIf $MyDocsFolder = "::{450D8FBA-AD25-11D0-98A8-0800361B1103}" $filepath = FileSaveDialog("Choose a name.", $MyDocsFolder, "HTML (*.htm;*.html)", 2, "") If @error Then ;;MsgBox(4096,"","Save cancelled.") Else ;;MsgBox(4096,"","You chose " & $filepath) $file1 = FileOpen($filepath & ".html", 2) If $file1 = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ;;start code... FileWriteLine($file1, "<HTML>") FileWriteLine($file1, "<HEAD><TITLE>" & $title & "</TITLE>") FileWriteLine($file1, "<style>p.header{ color:maroon; } p.textColor{ color:green; width:500px; } td.picture{ border:1px solid black; } td.comment{ background-color:#B2C0D8; } table.main{ background-color:#E4EAF2; border-color:#C2CFDF; }</style>") FileWriteLine($file1, "</HEAD>") FileWriteLine($file1, "<BODY>") FileWriteLine($file1, "<TABLE CLASS='main' ALIGN='CENTER'>") ;;header If ControlCommand($GUI_Title, "", $Chkbox_HeaderEnable, "IsChecked") = 1 Then FileWriteLine($file1, "<TR>") FileWriteLine($file1, "<TD COLSPAN='2' ALIGN='CENTER' CLASS='headerTd'>") FileWriteLine($file1, "<P CLASS='header'>" & $header & "</P>") FileWriteLine($file1, "</TD>") FileWriteLine($file1, "</TR>") EndIf Local $Row = 0 For $i = 1 To 4 ; Picture row If $FileURLs[$i] <> $noDisplay Or (($PictureCount >= ($i + 4)) And ($FileURLs[$i + 4] <> $noDisplay)) Then FileWriteLine($file1, "<TR>") FileWriteLine($file1, "<TD ALIGN='CENTER' CLASS='picture'>") If $FileURLs[$i] <> $noDisplay Then FileWriteLine($file1, "<A HREF='" & $FileURLs[$i] & "'><IMG SRC='" & $FileURLs[$i] & "' WIDTH='' HEIGHT='400' BORDER='0' BORDER='0'></A>") EndIf FileWriteLine($file1, "</TD>") FileWriteLine($file1, "<TD ALIGN='CENTER' CLASS='picture'>") If (($PictureCount >= ($i + 4)) And ($FileURLs[$i + 4] <> $noDisplay)) Then FileWriteLine($file1, "<A HREF='" & $FileURLs[$i + 4] & "'><IMG SRC='" & $FileURLs[$i + 4] & "' WIDTH='' HEIGHT='400' BORDER='0'></A>") EndIf FileWriteLine($file1, "</TD>") FileWriteLine($file1, "</TR>") EndIf ; Comment row If $Comments[$i] <> "" Or (($PictureCount >= ($i + 4)) And ($Comments[$i + 4] <> "")) Then FileWriteLine($file1, "<TR>") FileWriteLine($file1, "<TD ALIGN='CENTER' CLASS='comment'>") FileWriteLine($file1, "<P CLASS='textColor'>" & $Comments[$i] & "</P>") FileWriteLine($file1, "</TD>") If (($PictureCount >= ($i + 4)) And ($Comments[$i + 4] <> "")) Then FileWriteLine($file1, "<TD ALIGN='CENTER' CLASS='comment'>") FileWriteLine($file1, "<P CLASS='textColor'>" & $Comments[$i + 4] & "</P>") FileWriteLine($file1, "</TD>") EndIf FileWriteLine($file1, "</TR>") EndIf Next EndIf EndFunc ;==>_Save Func _Preview() Local $i For $i = 1 To $PictureCount $FileURLs[$i] = GUICtrlRead($Inputs[$i]) If $FileURLs[$i] = "" Then $FileURLs[$i] = $noimg $Comments[$i] = GUICtrlRead($Edits[$i]) Next $height = 697 ;;$Form2 = GUICreate("Preview", 417, $height, 349, 135) If ControlCommand($GUI_Title, "", $Chkbox_TitleEnable, "IsChecked") = 1 Then $previewTitle = GUICtrlRead($Input_Title) Else $previewTitle = "" EndIf ;;;;title;;;; GUICtrlSetData($2Group1, $previewTitle) ;;;;header;;;;; $header = GUICtrlRead($Input_Header) If ControlCommand($GUI_Title, "", $Chkbox_HeaderEnable, "IsChecked") = 1 Then GUICtrlSetData($2label1, $header) EndIf For $i = 1 To $PictureCount GUICtrlSetImage($Pictures[$i], $FileURLs[$i]) If GUICtrlRead($Edits[$i]) <> "" Then $Comment = StringLeft(GUICtrlRead($Edits[$i]), 20) GUICtrlSetData($Comments[$i], $Comment & "...") EndIf Next Return EndFunc ;==>_Preview Func _ShowLastSaved() $checkpath = $filepath & ".html" If $checkpath = ".html" Then MsgBox(0, "Error", "You have not saved yet.") Else ;;MsgBox(0,"Your last save location was", $filepath & ".html") ShellExecute($filepath & ".html") EndIf ;;Run($filepath & ".html") ;$rc = _RunDos("run " & $filepath & ".html") EndFunc ;==>_ShowLastSaved Func _PicBrowse($PicNum) Local $message = "Choose the image file to be uploaded." Local $Selection = FileOpenDialog($message, @WorkingDir & "\", "Images (*.jpg;*.bmp)", 1) If @error Then Return 0 Else $lastDir = $Selection $FileURLs[$PicNum] = $Selection GUICtrlSetData($Inputs[$PicNum], $Selection) EndIf EndFunc ;==>_PicBrowse Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Leoj Posted June 7, 2007 Author Share Posted June 7, 2007 Thanks so much for the fast replies. I can't wait to start changing how I program, right now I don't tell anyone I am a programmer of any sort but once I learn to code like you guys I think I will =P. @Smashly I love you, haha. Thanks for another great response (and sorry for my many questions!). @PSalty you are doin' me a real service, thanks =D. Link to comment Share on other sites More sharing options...
Leoj Posted June 7, 2007 Author Share Posted June 7, 2007 (edited) Func PicBrowse($p) Dim $Pic[9] $Pic[$p] = FileOpenDialog("Choose the image file to be uploaded.", @WorkingDir & "\", "Images (*.jpg;*.bmp)", 1 + 4 ) If @error Then Else $lastDir = $Pic[$p] $Pic[$p] = StringReplace($Pic[$p], "|", @CRLF) GUICtrlSetData($Input[$p], $Pic[$p]) EndIf EndFunc This is cool, gives me an idea to maybe right to a .ini file so the next time they open the program they are in their last @workingdir. Thanks Smashly Edited June 7, 2007 by Leoj Link to comment Share on other sites More sharing options...
Leoj Posted June 7, 2007 Author Share Posted June 7, 2007 @PSalty ; Create Arrays $PictureCount = 8 $ArraySize = $PictureCount + 1 ; Array indexes are [1] thru [$PictureCount] Global $Inputs[$ArraySize] ; Was Input1 thru 8 Global $Edits[$ArraySize] ; Was Edit1 thru 8 Global $BrowseButtons[$ArraySize] ; Was Button1 thru 8 Global $FileURLs[$ArraySize] ; Was Pic1 thru 8 Global $Comments[$ArraySize] ; Was Comment1 thru 8 Global $Pictures[$ArraySize] ; Was 2Pic1 thru 8 oÝ÷ Ùhrv'gßÛr¢çh¶¬)²®¶s`¢b33c´'&6¦RÒ¤vÆö&Âb33c´çWG5²b33c´'&6¦UФvÆö&Âb33c´VFG5²b33c´'&6¦UФvÆö&Âb33c´'&÷w6T'WGFöç5²b33c´'&6¦UФvÆö&Âb33c´fÆUU$Ç5²b33c´'&6¦UФvÆö&Âb33c´6öÖÖVçG5²b33c´'&6¦UФvÆö&Âb33cµ7GW&W5²b33c´'&6¦UÐ Link to comment Share on other sites More sharing options...
Leoj Posted June 7, 2007 Author Share Posted June 7, 2007 Ohhh, I get it. If i ever want to have the user be able to add more pictures I would increase that number. Good deal. Link to comment Share on other sites More sharing options...
Leoj Posted June 7, 2007 Author Share Posted June 7, 2007 This is really sexy: $CtrlX += 344 $ButtnX += 344 I always do $CtrlX = $CtrlX + 344.... Such a better way to do it PSalty! Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 7, 2007 Share Posted June 7, 2007 Func PicBrowse($p) Dim $Pic[9] $Pic[$p] = FileOpenDialog("Choose the image file to be uploaded.", @WorkingDir & "\", "Images (*.jpg;*.bmp)", 1 + 4 ) If @error Then Else $lastDir = $Pic[$p] $Pic[$p] = StringReplace($Pic[$p], "|", @CRLF) GUICtrlSetData($Input[$p], $Pic[$p]) EndIf EndFunc On that FileOpenDialog(), since this is to open a picture for a single control instance on the GUI, I don't think you need the complexity of the multi-file selection. Just use option = 1, vice 1+4, and don't bother screwing around with the StringReplace(). (I had made that change in my version.) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Leoj Posted June 7, 2007 Author Share Posted June 7, 2007 Ahh, thanks for the tip!! I had just copy+pasted that from the AutoIt Help file =P... Didn't take the time to read why the | was stuck in there, haha. @Smashly: Just re-read what your post said... Do you still have anything to add? I would love to see it! 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