ViktorB Posted December 10, 2013 Posted December 10, 2013 Hello, when i execute my script i get some unecpected errors with the array variables. expandcollapse popup#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
Moderators Melba23 Posted December 10, 2013 Moderators Posted December 10, 2013 ViktorB,Welcome to the AutoIt forum. What sort of errors are you getting? It would be helpful if you could explain what is going wrong with your script rather then just leaving us to guess - particularly as there are no comments to guide us as to what is supposed to happen, and not many of us read Cyrillic script. 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
bogQ Posted December 10, 2013 Posted December 10, 2013 (edited) put after StringSplit If Not IsArray($LoadData) Then Msgbox(0,'','Error, variable isnt array tupe') after that check do $LoadData = StringSplit($LoadData, @TAB) holds 10 + 1 elements?, coz you do use For $Number = 1 to 10. So, are you shure stringsplit array holds 10 + 1 elements? what does $LoadData[0] holds after StringSplit ? Edited December 10, 2013 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
ViktorB Posted December 10, 2013 Author Posted December 10, 2013 (edited) @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 Edited December 10, 2013 by ViktorB
bogQ Posted December 10, 2013 Posted December 10, 2013 (edited) ok so do the loop like this If IsArray($LoadData) Then For $number= 1 to $LoadData[0] ConsoleWrite("$LoadData "&$number&" ["&$LoadData[0]&"]: "&$LoadData[$number]&@CRLF) ;rest of your code Next EndIf instead of your For $number= 1 to 5 Next and see what will happend Edited December 10, 2013 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
ViktorB Posted December 10, 2013 Author Posted December 10, 2013 expandcollapse popup#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.
bogQ Posted December 10, 2013 Posted December 10, 2013 (edited) well do your $LoadData have 32 elements? and you do have Case $RecipeListBox so that is equal to if anything happend to it it`l trigger that func to detect doubleclick instead you can search forum for some example code like in this post >#2 Edited December 10, 2013 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
ViktorB Posted December 10, 2013 Author Posted December 10, 2013 expandcollapse popup#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.
bogQ Posted December 10, 2013 Posted December 10, 2013 can you explaind where did you write update for inputs? and from what file do they need to read inputs to update themself? i presume you need to update inputs from PB-.txt with stringsplit command? TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
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