
ViktorB
Members-
Posts
6 -
Joined
-
Last visited
Everything posted by ViktorB
-
Just found it. OKAY NEXT ISSUE: How can i make the script after filling and submitting the form to do the same with the next cells like A2, B2, C2 and so on?
-
Hello, I just spen the last 30 minutes searching for a way to solve my issues but with no luck... I am trying to create a script that will: 1. Open a website (YES) 2. Read Column A1 Cell1 and Fill it in an internet object via setobjectvalue function. 3. do the same with the others ( Column A1 Cell2 and fill it in, Colum A1 Cell3 and so on ) In green color i have put the things i can do already i just need help with the excel part. Went through the Helpfile and Search fucntion on forum but didn't find a satisfying answer. Thank you for your time
-
#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #Include <Array.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 1408, 904, 413, 13) $Tab1 = GUICtrlCreateTab(0, 0, 1345, 881) $Home = GUICtrlCreateTabItem("Начало") $RecipeListBox = GUICtrlCreateList("", 16, 80, 305, 656) $Label1 = GUICtrlCreateLabel("Казуси", 128, 40, 72, 28, BitOR($SS_CENTER,$WS_CLIPSIBLINGS)) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $NewRecipeButton = GUICtrlCreateButton("Изчисти полетата", 1112, 32, 163, 25) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $SaveButton = GUICtrlCreateButton("Добавяне на нов казус", 736, 800, 211, 41) GUICtrlSetFont(-1, 10, 800, 2, "MS Sans Serif") $DiscardButton = GUICtrlCreateButton("Изтриване на избрания казус", 48, 752, 251, 41) GUICtrlSetFont(-1, 10, 800, 2, "MS Sans Serif") $Group1 = GUICtrlCreateGroup("Информация за килента", 344, 160, 313, 321) $Label2 = GUICtrlCreateLabel("Име:", 352, 192, 29, 17) $Label3 = GUICtrlCreateLabel("Презиме:", 352, 224, 53, 17) $Label4 = GUICtrlCreateLabel("Фамилия:", 352, 256, 56, 17) ;$Input1 = GUICtrlCreateInput("Име", 416, 192, 121, 21) ;$Input2 = GUICtrlCreateInput("Презиме", 416, 224, 121, 21) ;$Input3 = GUICtrlCreateInput("Фамилия", 416, 256, 121, 21) $Label5 = GUICtrlCreateLabel("Телефон:", 352, 288, 52, 17) ;$Input4 = GUICtrlCreateInput("Телефон", 416, 288, 121, 21) $Label6 = GUICtrlCreateLabel("Адрес:", 352, 320, 38, 17) ;$Input5 = GUICtrlCreateInput("Адрес", 416, 320, 121, 21) ;$InstructionBox = GUICtrlCreateEdit("", 352, 376, 297, 89) ;GUICtrlSetData(-1, "Допълнителна информация за клиента") $Label7 = GUICtrlCreateLabel("Допълнителна информация", 416, 352, 169, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateGroup("", -99, -99, 1, 1) $cDblClk = GUICtrlCreateDummy() $TitleInput = GUICtrlCreateInput("Казус:", 472, 88, 489, 24) GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") Dim $Ing[7] ;Dim $Q[11] ;Dim $QT[11] $Ing[1] = GUICtrlCreateInput("Име", 416, 192, 121, 21) ;$Q[1] = GUICtrlCreateInput("Qty.", 315, 45, 30, 21) ;$QT[1] = GUICtrlCreateInput("Qty. type", 345, 45, 120, 21) $Ing[2] = GUICtrlCreateInput("Презиме", 416, 224, 121, 21) ;$Q[2] = GUICtrlCreateInput("Qty.", 315, 69, 30, 21) ;$QT[2] = GUICtrlCreateInput("Qty. type", 345, 69, 120, 21) $Ing[3] = GUICtrlCreateInput("Фамилия", 416, 256, 121, 21) ;$Q[3] = GUICtrlCreateInput("Qty.", 315, 93, 30, 21) ;$QT[3] = GUICtrlCreateInput("Qty. type", 345, 93, 120, 21) $Ing[4] = GUICtrlCreateInput("Телефон", 416, 288, 121, 21) ;$Q[4] = GUICtrlCreateInput("Qty.", 315, 117, 30, 21) ;$QT[4] = GUICtrlCreateInput("Qty. type", 345, 117, 120, 21) $Ing[5] = GUICtrlCreateInput("Адрес", 416, 320, 121, 21) ;$Q[5] = GUICtrlCreateInput("Qty.", 315, 141, 30, 21) ;$QT[5] = GUICtrlCreateInput("Qty. type", 345, 141, 120, 21) $Ing[6] = GUICtrlCreateEdit("Допълнителна информация за клиента", 352, 376, 297, 89) ;$InstructionBox = GUICtrlCreateEdit("Instructions", 130, 290, 335, 330, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL)) ;$SaveButton = GUICtrlCreateButton("Save", 130, 625, 165, 25, $WS_GROUP) ;GUICtrlSetFont(-1, 8, 800, 2, "Lucida Handwriting") ;$DiscardButton = GUICtrlCreateButton("Discard", 295, 625, 165, 25, $WS_GROUP) ;GUICtrlSetFont(-1, 8, 800, 2, "Lucida Handwriting") LoadFirstRecipe() RecipeListBoxRefresh() GUISetState(@SW_SHOW) $Matters = GUICtrlCreateTabItem("Казуси") $Button1 = GUICtrlCreateButton("Button1", 280, 264, 75, 25) $Button2 = GUICtrlCreateButton("Button2", 512, 320, 75, 25) $TabSheet3 = GUICtrlCreateTabItem("TabSheet3") $TabSheet4 = GUICtrlCreateTabItem("TabSheet4") $TabSheet5 = GUICtrlCreateTabItem("TabSheet5") #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit ;Case $RecipeListBox ;LoadRecipe() Case $NewRecipeButton NewRecipe() Case $SaveButton SaveRecipe() Case $DiscardButton Discard() Case $cDblClk ; Dummy control fired <<<<<<<<<<<<<<<<<<<<<< $sText = GUICtrlRead($cDblClk) ; Get text <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< LoadRecipe() ; Display it <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndSwitch WEnd Func NewRecipe() $SaveTitleData = GUICtrlRead($TitleInput) If FileExists(@ScriptDir & "\PB-" & $SaveTitleData & ".txt") Then ResetInputs() Else $ForgotSaveMsgBox = MsgBox(4, "Save?", "Before you go on, do you want to save this " & $SaveTitleData & " recipe?") If $ForgotSaveMsgBox = 6 then WriteSaveFile() ResetInputs() Else ResetInputs() EndIf EndIf EndFunc Func ResetInputs() GUICtrlSetData($TitleInput, "Казус:") For $Number = 1 to 6 GUICtrlSetData($Ing[$Number], "Данни") Next ;GUICtrlSetData($InstructionBox, "Допълнителна информация за клиента") EndFunc Func SaveRecipe() $SaveTitleData = GUICtrlRead($TitleInput) If FileExists(@ScriptDir & "\PB-" & $SaveTitleData & ".txt") Then $OverwriteMsgBox = MsgBox(4, "Overwrite?", "Do you want to overwrite your other " & $SaveTitleData & " recipe?") If $OverwriteMsgBox = 6 then FileDelete(@ScriptDir & "\PB-" & $SaveTitleData & ".txt") WriteSaveFile() EndIf Else WriteSaveFile() EndIf EndFunc Func WriteSaveFile() $SaveTitleData = GUICtrlRead($TitleInput) FileWrite(@ScriptDir & "\PB-" & $SaveTitleData & ".txt", $SaveTitleData & @TAB) For $Number = 1 to 6 $SaveIngData = GUICtrlRead($Ing[$Number]) FileWrite(@ScriptDir & "\PB-" & $SaveTitleData & ".txt", $SaveIngData & @TAB) ;$SaveQData = GUICtrlRead($Q[$Number]) ;FileWrite(@ScriptDir & "\PB-" & $SaveTitleData & ".txt", $SaveQData & @TAB) ;$SaveQTData = GUICtrlRead($QT[$Number]) ;FileWrite(@ScriptDir & "\PB-" & $SaveTitleData & ".txt", $SaveQTData & @TAB) Next ;$SaveInstructionData = GUICtrlRead($InstructionBox) ;FileWrite(@ScriptDir & "\PB-" & $SaveTitleData & ".txt", $SaveInstructionData) If FileExists(@ScriptDir & "\PB-" & $SaveTitleData & ".txt") Then MsgBox(0, "Успешно!", "Вашият казус: " & $SaveTitleData & " беше запазен успешно.") RecipeListBoxRefresh() EndIf EndFunc Func RecipeListBoxRefresh() GUICtrlSetData($RecipeListBox, "") $FileSearch = FileFindFirstFile("PB-*.*") While 1 $RecipeFile = FileFindNextFile($FileSearch) If @Error Then ExitLoop GUICtrlSetData($RecipeListBox, $RecipeFile & "|") WEnd FileClose($FileSearch) EndFunc Func LoadFirstRecipe() GUICtrlSetData($RecipeListBox, "") $FileSearch = FileFindFirstFile("PB-*.*") $RecipeFile = FileFindNextFile($FileSearch) If @Error Then MsgBox(0, "Няма казуси!", "Все още нямате казуси.") Else $LoadData=FileRead(@ScriptDir & "\" & $RecipeFile ) $LoadData = StringSplit($LoadData, @TAB) If Not IsArray($LoadData) Then Msgbox(0,'','Error, variable isnt array tupe') GUICtrlSetData($TitleInput, $LoadData[1]) If IsArray($LoadData) Then For $Number= 1 to $LoadData[0] ConsoleWrite("$LoadData"&$Number&" ["&$LoadData[0]&"]: "&$LoadData[$Number]&@CRLF) ;rest of your code ;$ArrayNumber= 3 * $Number - 1 ;GUICtrlSetData($Ing[$Number], $LoadData[$ArrayNumber]) ;$ArrayNumber=3 * $Number ;GUICtrlSetData($Q[$Number], $LoadData[$ArrayNumber]) ;$ArrayNumber=3 * $Number + 1 ;GUICtrlSetData($QT[$Number], $LoadData[$ArrayNumber]) Next ;GUICtrlSetData($InstructionBox, $LoadData[6]) EndIf EndIf EndFunc Func LoadRecipe() $SaveTitleData = GUICtrlRead($TitleInput) If FileExists(@ScriptDir & "\PB-" & $SaveTitleData & ".txt") Then LoadSaveFile() Else $ForgotSaveMsgBox = MsgBox(4, "Запазване?", "Бихте ли желали да запазите вашия казус: " & $SaveTitleData & " , преди да излезете?") If $ForgotSaveMsgBox = 6 then SaveRecipe() LoadSaveFile() Else LoadSaveFile() EndIf EndIf EndFunc Func LoadSaveFile() $RecipePressed = GUICtrlRead($RecipeListBox) $LoadData=FileRead(@ScriptDir & "\" & $RecipePressed ) $LoadData = StringSplit($LoadData, @TAB) If Not IsArray($LoadData) Then Msgbox(0,'','Error, variable isnt array tupe') GUICtrlSetData($TitleInput, $LoadData[1]) If IsArray($LoadData) Then For $Number= 1 to $LoadData[0] ConsoleWrite("$LoadData"&$Number&" ["&$LoadData[0]&"]: "&$LoadData[$Number]&@CRLF) ;For $Number = 1 to 5 ; $ArrayNumber= 3 * $Number - 1 ; GUICtrlSetData($Ing[$Number], $LoadData[$ArrayNumber]) ;$ArrayNumber=3 * $Number ;GUICtrlSetData($Q[$Number], $LoadData[$ArrayNumber]) ;$ArrayNumber=3 * $Number + 1 ;GUICtrlSetData($QT[$Number], $LoadData[$ArrayNumber]) Next ;GUICtrlSetData($InstructionBox, $LoadData[6]) EndIf EndFunc Func Discard() $SaveTitleData = GUICtrlRead($TitleInput) $DeleteMsgBox = MsgBox(4, "Изтриване?", "Сигурни ли сте, че искате да изтриете вашия казус: " & $SaveTitleData & " ?") If $DeleteMsgBox = 6 Then ResetInputs() If FileExists(@ScriptDir & "\PB-" & $SaveTitleData & ".txt") then FileDelete(@ScriptDir & "\PB-" & $SaveTitleData & ".txt") RecipeListBoxRefresh() EndIf EndFunc Func _WM_COMMAND($hWnd, $msg, $wParam, $lParam) Local $nCode = BitShift($wParam, 16) ; HiWord Local $nIDFrom = BitAND($wParam, 0xFFFF) ; LoWord Switch $nIDFrom Case $RecipeListBox Switch $nCode Case $LBN_DBLCLK $sListItem = GUICtrlRead($RecipeListBox) ; Read selected item <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlSendToDummy($cDblClk, $sListItem) ; Send the text to the dummy control and fire it <<<<<<<<<<<<<<<<<<< EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMAND This is how it looks now. Enabled the doubleclick detection, its working great. $LoadData has 7 elements (6 inputs and an edit box). The next issue is: All input boxes, for every item from the list gets populated with the same data as the first one viewed. It doesnt seperate each item from the list.
-
#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #Include <Array.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 1408, 904, 413, 13) $Tab1 = GUICtrlCreateTab(0, 0, 1345, 881) $Home = GUICtrlCreateTabItem("Начало") $RecipeListBox = GUICtrlCreateList("", 16, 80, 305, 656) $Label1 = GUICtrlCreateLabel("Казуси", 128, 40, 72, 28, BitOR($SS_CENTER,$WS_CLIPSIBLINGS)) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $NewRecipeButton = GUICtrlCreateButton("Изчисти полетата", 1112, 32, 163, 25) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $SaveButton = GUICtrlCreateButton("Добавяне на нов казус", 736, 800, 211, 41) GUICtrlSetFont(-1, 10, 800, 2, "MS Sans Serif") $DiscardButton = GUICtrlCreateButton("Изтриване на избрания казус", 48, 752, 251, 41) GUICtrlSetFont(-1, 10, 800, 2, "MS Sans Serif") $Group1 = GUICtrlCreateGroup("Информация за килента", 344, 160, 313, 321) $Label2 = GUICtrlCreateLabel("Име:", 352, 192, 29, 17) $Label3 = GUICtrlCreateLabel("Презиме:", 352, 224, 53, 17) $Label4 = GUICtrlCreateLabel("Фамилия:", 352, 256, 56, 17) ;$Input1 = GUICtrlCreateInput("Име", 416, 192, 121, 21) ;$Input2 = GUICtrlCreateInput("Презиме", 416, 224, 121, 21) ;$Input3 = GUICtrlCreateInput("Фамилия", 416, 256, 121, 21) $Label5 = GUICtrlCreateLabel("Телефон:", 352, 288, 52, 17) ;$Input4 = GUICtrlCreateInput("Телефон", 416, 288, 121, 21) $Label6 = GUICtrlCreateLabel("Адрес:", 352, 320, 38, 17) ;$Input5 = GUICtrlCreateInput("Адрес", 416, 320, 121, 21) $InstructionBox = GUICtrlCreateEdit("", 352, 376, 297, 89) ;GUICtrlSetData(-1, "Допълнителна информация за клиента") $Label7 = GUICtrlCreateLabel("Допълнителна информация", 416, 352, 169, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateGroup("", -99, -99, 1, 1) $TitleInput = GUICtrlCreateInput("Казус:", 472, 88, 489, 24) Dim $Ing[6] ;Dim $Q[11] ;Dim $QT[11] $Ing[1] = GUICtrlCreateInput("Име", 416, 192, 121, 21) ;$Q[1] = GUICtrlCreateInput("Qty.", 315, 45, 30, 21) ;$QT[1] = GUICtrlCreateInput("Qty. type", 345, 45, 120, 21) $Ing[2] = GUICtrlCreateInput("Презиме", 416, 224, 121, 21) ;$Q[2] = GUICtrlCreateInput("Qty.", 315, 69, 30, 21) ;$QT[2] = GUICtrlCreateInput("Qty. type", 345, 69, 120, 21) $Ing[3] = GUICtrlCreateInput("Фамилия", 416, 256, 121, 21) ;$Q[3] = GUICtrlCreateInput("Qty.", 315, 93, 30, 21) ;$QT[3] = GUICtrlCreateInput("Qty. type", 345, 93, 120, 21) $Ing[4] = GUICtrlCreateInput("Телефон", 416, 288, 121, 21) ;$Q[4] = GUICtrlCreateInput("Qty.", 315, 117, 30, 21) ;$QT[4] = GUICtrlCreateInput("Qty. type", 345, 117, 120, 21) $Ing[5] = GUICtrlCreateInput("Адрес", 416, 320, 121, 21) ;$Q[5] = GUICtrlCreateInput("Qty.", 315, 141, 30, 21) ;$QT[5] = GUICtrlCreateInput("Qty. type", 345, 141, 120, 21) ;$InstructionBox = GUICtrlCreateEdit("Instructions", 130, 290, 335, 330, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL)) ;$SaveButton = GUICtrlCreateButton("Save", 130, 625, 165, 25, $WS_GROUP) ;GUICtrlSetFont(-1, 8, 800, 2, "Lucida Handwriting") ;$DiscardButton = GUICtrlCreateButton("Discard", 295, 625, 165, 25, $WS_GROUP) ;GUICtrlSetFont(-1, 8, 800, 2, "Lucida Handwriting") LoadFirstRecipe() RecipeListBoxRefresh() GUISetState(@SW_SHOW) $Matters = GUICtrlCreateTabItem("Казуси") $Button1 = GUICtrlCreateButton("Button1", 280, 264, 75, 25) $Button2 = GUICtrlCreateButton("Button2", 512, 320, 75, 25) $TabSheet3 = GUICtrlCreateTabItem("TabSheet3") $TabSheet4 = GUICtrlCreateTabItem("TabSheet4") $TabSheet5 = GUICtrlCreateTabItem("TabSheet5") GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $RecipeListBox LoadRecipe() Case $NewRecipeButton NewRecipe() Case $SaveButton SaveRecipe() Case $DiscardButton Discard() EndSwitch WEnd Func NewRecipe() $SaveTitleData = GUICtrlRead($TitleInput) If FileExists(@ScriptDir & "\PB-" & $SaveTitleData & ".txt") Then ResetInputs() Else $ForgotSaveMsgBox = MsgBox(4, "Save?", "Before you go on, do you want to save this " & $SaveTitleData & " recipe?") If $ForgotSaveMsgBox = 6 then WriteSaveFile() ResetInputs() Else ResetInputs() EndIf EndIf EndFunc Func ResetInputs() GUICtrlSetData($TitleInput, "Казус:") For $Number = 1 to 5 GUICtrlSetData($Ing[$Number], "Данни") Next GUICtrlSetData($InstructionBox, "Допълнителна информация за клиента") EndFunc Func SaveRecipe() $SaveTitleData = GUICtrlRead($TitleInput) If FileExists(@ScriptDir & "\PB-" & $SaveTitleData & ".txt") Then $OverwriteMsgBox = MsgBox(4, "Overwrite?", "Do you want to overwrite your other " & $SaveTitleData & " recipe?") If $OverwriteMsgBox = 6 then FileDelete(@ScriptDir & "\PB-" & $SaveTitleData & ".txt") WriteSaveFile() EndIf Else WriteSaveFile() EndIf EndFunc Func WriteSaveFile() $SaveTitleData = GUICtrlRead($TitleInput) FileWrite(@ScriptDir & "\PB-" & $SaveTitleData & ".txt", $SaveTitleData & @TAB) For $Number = 1 to 5 $SaveIngData = GUICtrlRead($Ing[$Number]) FileWrite(@ScriptDir & "\PB-" & $SaveTitleData & ".txt", $SaveIngData & @TAB) ;$SaveQData = GUICtrlRead($Q[$Number]) ;FileWrite(@ScriptDir & "\PB-" & $SaveTitleData & ".txt", $SaveQData & @TAB) ;$SaveQTData = GUICtrlRead($QT[$Number]) ;FileWrite(@ScriptDir & "\PB-" & $SaveTitleData & ".txt", $SaveQTData & @TAB) Next $SaveInstructionData = GUICtrlRead($InstructionBox) FileWrite(@ScriptDir & "\PB-" & $SaveTitleData & ".txt", $SaveInstructionData) If FileExists(@ScriptDir & "\PB-" & $SaveTitleData & ".txt") Then MsgBox(0, "Успешно!", "Вашият казус: " & $SaveTitleData & " беше запазен успешно.") RecipeListBoxRefresh() EndIf EndFunc Func RecipeListBoxRefresh() GUICtrlSetData($RecipeListBox, "") $FileSearch = FileFindFirstFile("PB-*.*") While 1 $RecipeFile = FileFindNextFile($FileSearch) If @Error Then ExitLoop GUICtrlSetData($RecipeListBox, $RecipeFile & "|") WEnd FileClose($FileSearch) EndFunc Func LoadFirstRecipe() GUICtrlSetData($RecipeListBox, "") $FileSearch = FileFindFirstFile("PB-*.*") $RecipeFile = FileFindNextFile($FileSearch) If @Error Then MsgBox(0, "Няма казуси!", "Все още нямате казуси.") Else $LoadData=FileRead(@ScriptDir & "\" & $RecipeFile ) $LoadData = StringSplit($LoadData, @TAB) If Not IsArray($LoadData) Then Msgbox(0,'','Error, variable isnt array tupe') GUICtrlSetData($TitleInput, $LoadData[1]) If IsArray($LoadData) Then For $Number= 1 to $LoadData[0] ConsoleWrite("$LoadData"&$Number&" ["&$LoadData[0]&"]: "&$LoadData[$Number]&@CRLF) ;rest of your code ;$ArrayNumber= 3 * $Number - 1 ;GUICtrlSetData($Ing[$Number], $LoadData[$ArrayNumber]) ;$ArrayNumber=3 * $Number ;GUICtrlSetData($Q[$Number], $LoadData[$ArrayNumber]) ;$ArrayNumber=3 * $Number + 1 ;GUICtrlSetData($QT[$Number], $LoadData[$ArrayNumber]) Next GUICtrlSetData($InstructionBox, $LoadData[0]) EndIf EndIf EndFunc Func LoadRecipe() $SaveTitleData = GUICtrlRead($TitleInput) If FileExists(@ScriptDir & "\PB-" & $SaveTitleData & ".txt") Then LoadSaveFile() Else $ForgotSaveMsgBox = MsgBox(4, "Запазване?", "Бихте ли желали да запазите вашия казус: " & $SaveTitleData & " , преди да излезете?") If $ForgotSaveMsgBox = 6 then SaveRecipe() LoadSaveFile() Else LoadSaveFile() EndIf EndIf EndFunc Func LoadSaveFile() $RecipePressed = GUICtrlRead($RecipeListBox) $LoadData=FileRead(@ScriptDir & "\" & $RecipePressed ) $LoadData = StringSplit($LoadData, @TAB) If Not IsArray($LoadData) Then Msgbox(0,'','Error, variable isnt array tupe') GUICtrlSetData($TitleInput, $LoadData[1]) If IsArray($LoadData) Then For $Number= 1 to $LoadData[0] ConsoleWrite("$LoadData"&$Number&" ["&$LoadData[0]&"]: "&$LoadData[$Number]&@CRLF) ;For $Number = 1 to 5 ; $ArrayNumber= 3 * $Number - 1 ; GUICtrlSetData($Ing[$Number], $LoadData[$ArrayNumber]) ;$ArrayNumber=3 * $Number ;GUICtrlSetData($Q[$Number], $LoadData[$ArrayNumber]) ;$ArrayNumber=3 * $Number + 1 ;GUICtrlSetData($QT[$Number], $LoadData[$ArrayNumber]) Next GUICtrlSetData($InstructionBox, $LoadData[0]) EndIf EndFunc Func Discard() $SaveTitleData = GUICtrlRead($TitleInput) $DeleteMsgBox = MsgBox(4, "Изтриване?", "Сигурни ли сте, че искате да изтриете вашия казус: " & $SaveTitleData & " ?") If $DeleteMsgBox = 6 Then ResetInputs() If FileExists(@ScriptDir & "\PB-" & $SaveTitleData & ".txt") then FileDelete(@ScriptDir & "\PB-" & $SaveTitleData & ".txt") RecipeListBoxRefresh() EndIf EndFunc OK, thank you bogQ now its working, except for the $InstructionBox, it loads some random data, and not the data it should. And now it keeps asking me whether i want to save, even though i haven't made any changes.
-
@M23 Im sorry for not explaining what errors im getting. I get that error only after the filed has been saved. Error: Line 188 (file "..........."); GUICtrlSetData($Ing[$Number], $LoadData[$ArrayNumber]) GUICtrlSetData($Ing[$Number], ^ERROR Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded. @bogQ i've put that after StringSplit, still not working It hold 5 elements, not 10 my mistake, fixed that still not working, even for $number= 1 to 5
-
Hello, when i execute my script i get some unecpected errors with the array variables. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #Include <Array.au3> #include <StaticConstants.au3> #include <TabConstants.au3> $Form1 = GUICreate("Form1", 1408, 904, 413, 13) $Tab1 = GUICtrlCreateTab(0, 0, 1345, 881) $Home = GUICtrlCreateTabItem("Начало") $RecipeListBox = GUICtrlCreateList("", 16, 80, 305, 656) $Label1 = GUICtrlCreateLabel("Казуси", 128, 40, 72, 28, BitOR($SS_CENTER,$WS_CLIPSIBLINGS)) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $NewRecipeButton = GUICtrlCreateButton("Изчисти полетата", 1112, 32, 163, 25) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $SaveButton = GUICtrlCreateButton("Добавяне на нов казус", 736, 800, 211, 41) GUICtrlSetFont(-1, 10, 800, 2, "MS Sans Serif") $DiscardButton = GUICtrlCreateButton("Изтриване на избрания казус", 48, 752, 251, 41) GUICtrlSetFont(-1, 10, 800, 2, "MS Sans Serif") $Group1 = GUICtrlCreateGroup("Информация за килента", 344, 160, 313, 321) $Label2 = GUICtrlCreateLabel("Име:", 352, 192, 29, 17) $Label3 = GUICtrlCreateLabel("Презиме:", 352, 224, 53, 17) $Label4 = GUICtrlCreateLabel("Фамилия:", 352, 256, 56, 17) ;$Input1 = GUICtrlCreateInput("Име", 416, 192, 121, 21) ;$Input2 = GUICtrlCreateInput("Презиме", 416, 224, 121, 21) ;$Input3 = GUICtrlCreateInput("Фамилия", 416, 256, 121, 21) $Label5 = GUICtrlCreateLabel("Телефон:", 352, 288, 52, 17) ;$Input4 = GUICtrlCreateInput("Телефон", 416, 288, 121, 21) $Label6 = GUICtrlCreateLabel("Адрес:", 352, 320, 38, 17) ;$Input5 = GUICtrlCreateInput("Адрес", 416, 320, 121, 21) $InstructionBox = GUICtrlCreateEdit("", 352, 376, 297, 89) GUICtrlSetData(-1, "Допълнителна информация за клиента") $Label7 = GUICtrlCreateLabel("Допълнителна информация", 416, 352, 169, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateGroup("", -99, -99, 1, 1) $TitleInput = GUICtrlCreateInput("Казус:", 472, 88, 489, 24) Dim $Ing[11] Dim $Q[11] Dim $QT[11] $Ing[1] = GUICtrlCreateInput("Име", 416, 192, 121, 21) ;$Q[1] = GUICtrlCreateInput("Qty.", 315, 45, 30, 21) ;$QT[1] = GUICtrlCreateInput("Qty. type", 345, 45, 120, 21) $Ing[2] = GUICtrlCreateInput("Презиме", 416, 224, 121, 21) ;$Q[2] = GUICtrlCreateInput("Qty.", 315, 69, 30, 21) ;$QT[2] = GUICtrlCreateInput("Qty. type", 345, 69, 120, 21) $Ing[3] = GUICtrlCreateInput("Фамилия", 416, 256, 121, 21) ;$Q[3] = GUICtrlCreateInput("Qty.", 315, 93, 30, 21) ;$QT[3] = GUICtrlCreateInput("Qty. type", 345, 93, 120, 21) $Ing[4] = GUICtrlCreateInput("Телефон", 416, 288, 121, 21) ;$Q[4] = GUICtrlCreateInput("Qty.", 315, 117, 30, 21) ;$QT[4] = GUICtrlCreateInput("Qty. type", 345, 117, 120, 21) $Ing[5] = GUICtrlCreateInput("Адрес", 416, 320, 121, 21) ;$Q[5] = GUICtrlCreateInput("Qty.", 315, 141, 30, 21) ;$QT[5] = GUICtrlCreateInput("Qty. type", 345, 141, 120, 21) ;$InstructionBox = GUICtrlCreateEdit("Instructions", 130, 290, 335, 330, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL)) ;$SaveButton = GUICtrlCreateButton("Save", 130, 625, 165, 25, $WS_GROUP) ;GUICtrlSetFont(-1, 8, 800, 2, "Lucida Handwriting") ;$DiscardButton = GUICtrlCreateButton("Discard", 295, 625, 165, 25, $WS_GROUP) ;GUICtrlSetFont(-1, 8, 800, 2, "Lucida Handwriting") LoadFirstRecipe() RecipeListBoxRefresh() GUISetState(@SW_SHOW) $Matters = GUICtrlCreateTabItem("Казуси") $Button1 = GUICtrlCreateButton("Button1", 280, 264, 75, 25) $Button2 = GUICtrlCreateButton("Button2", 512, 320, 75, 25) $TabSheet3 = GUICtrlCreateTabItem("TabSheet3") $TabSheet4 = GUICtrlCreateTabItem("TabSheet4") $TabSheet5 = GUICtrlCreateTabItem("TabSheet5") GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $RecipeListBox LoadRecipe() Case $NewRecipeButton NewRecipe() Case $SaveButton SaveRecipe() Case $DiscardButton Discard() EndSwitch WEnd Func NewRecipe() $SaveTitleData = GUICtrlRead($TitleInput) If FileExists(@ScriptDir & "\PB-" & $SaveTitleData & ".txt") Then ResetInputs() Else $ForgotSaveMsgBox = MsgBox(4, "Save?", "Before you go on, do you want to save this " & $SaveTitleData & " recipe?") If $ForgotSaveMsgBox = 6 then WriteSaveFile() ResetInputs() Else ResetInputs() EndIf EndIf EndFunc Func ResetInputs() GUICtrlSetData($TitleInput, "Казус:") For $Number = 1 to 10 GUICtrlSetData($Ing[$Number], "Данни") Next GUICtrlSetData($InstructionBox, "Допълнителна информация за клиента") EndFunc Func SaveRecipe() $SaveTitleData = GUICtrlRead($TitleInput) If FileExists(@ScriptDir & "\PB-" & $SaveTitleData & ".txt") Then $OverwriteMsgBox = MsgBox(4, "Overwrite?", "Do you want to overwrite your other " & $SaveTitleData & " recipe?") If $OverwriteMsgBox = 6 then FileDelete(@ScriptDir & "\PB-" & $SaveTitleData & ".txt") WriteSaveFile() EndIf Else WriteSaveFile() EndIf EndFunc Func WriteSaveFile() $SaveTitleData = GUICtrlRead($TitleInput) FileWrite(@ScriptDir & "\PB-" & $SaveTitleData & ".txt", $SaveTitleData & @TAB) For $Number = 1 to 10 $SaveIngData = GUICtrlRead($Ing[$Number]) FileWrite(@ScriptDir & "\PB-" & $SaveTitleData & ".txt", $SaveIngData & @TAB) ;$SaveQData = GUICtrlRead($Q[$Number]) ;FileWrite(@ScriptDir & "\PB-" & $SaveTitleData & ".txt", $SaveQData & @TAB) ;$SaveQTData = GUICtrlRead($QT[$Number]) ;FileWrite(@ScriptDir & "\PB-" & $SaveTitleData & ".txt", $SaveQTData & @TAB) Next $SaveInstructionData = GUICtrlRead($InstructionBox) FileWrite(@ScriptDir & "\PB-" & $SaveTitleData & ".txt", $SaveInstructionData) If FileExists(@ScriptDir & "\PB-" & $SaveTitleData & ".txt") Then MsgBox(0, "Успешно!", "Вашият казус: " & $SaveTitleData & " беше запазен успешно.") RecipeListBoxRefresh() EndIf EndFunc Func RecipeListBoxRefresh() GUICtrlSetData($RecipeListBox, "") $FileSearch = FileFindFirstFile("PB-*.*") While 1 $RecipeFile = FileFindNextFile($FileSearch) If @Error Then ExitLoop GUICtrlSetData($RecipeListBox, $RecipeFile & "|") WEnd FileClose($FileSearch) EndFunc Func LoadFirstRecipe() GUICtrlSetData($RecipeListBox, "") $FileSearch = FileFindFirstFile("PB-*.*") $RecipeFile = FileFindNextFile($FileSearch) If @Error Then MsgBox(0, "Няма казуси!", "Все още нямате казуси.") Else $LoadData=FileRead(@ScriptDir & "\" & $RecipeFile ) $LoadData = StringSplit($LoadData, @TAB) GUICtrlSetData($TitleInput, $LoadData[1]) For $Number = 1 to 10 $ArrayNumber=1 * $Number - 1 GUICtrlSetData($Ing[$Number], $LoadData[$ArrayNumber]) ;$ArrayNumber=3 * $Number ;GUICtrlSetData($Q[$Number], $LoadData[$ArrayNumber]) ;$ArrayNumber=3 * $Number + 1 ;GUICtrlSetData($QT[$Number], $LoadData[$ArrayNumber]) Next GUICtrlSetData($InstructionBox, $LoadData[32]) EndIf EndFunc Func LoadRecipe() $SaveTitleData = GUICtrlRead($TitleInput) If FileExists(@ScriptDir & "\PB-" & $SaveTitleData & ".txt") Then LoadSaveFile() Else $ForgotSaveMsgBox = MsgBox(4, "Запазване?", "Бихте ли желали да запазите вашия казус: " & $SaveTitleData & " , преди да излезете?") If $ForgotSaveMsgBox = 6 then SaveRecipe() LoadSaveFile() Else LoadSaveFile() EndIf EndIf EndFunc Func LoadSaveFile() $RecipePressed = GUICtrlRead($RecipeListBox) $LoadData=FileRead(@ScriptDir & "\" & $RecipePressed ) $LoadData = StringSplit($LoadData, @TAB) GUICtrlSetData($TitleInput, $LoadData[1]) For $Number = 1 to 10 $ArrayNumber=1 * $Number - 1 GUICtrlSetData($Ing[$Number], $LoadData[$ArrayNumber]) ;$ArrayNumber=3 * $Number ;GUICtrlSetData($Q[$Number], $LoadData[$ArrayNumber]) ;$ArrayNumber=3 * $Number + 1 ;GUICtrlSetData($QT[$Number], $LoadData[$ArrayNumber]) Next GUICtrlSetData($InstructionBox, $LoadData[32]) EndFunc Func Discard() $SaveTitleData = GUICtrlRead($TitleInput) $DeleteMsgBox = MsgBox(4, "Изтриване?", "Сигурни ли сте, че искате да изтриете вашия казус: " & $SaveTitleData & " ?") If $DeleteMsgBox = 6 Then ResetInputs() If FileExists(@ScriptDir & "\PB-" & $SaveTitleData & ".txt") then FileDelete(@ScriptDir & "\PB-" & $SaveTitleData & ".txt") RecipeListBoxRefresh() EndIf EndFunc Would be great if anyone could help me eradicate those errors and continue working. Thank you in advance