abdulrahmanok Posted October 29, 2016 Share Posted October 29, 2016 Welcome to all , I'm trying read 2 text file to array and then show it to listbox gui like this: line 1 from text file 1 line 1 from text file 2 this is my try : $aArray2 = FileReadToArray(@ScriptDir & "\DaysArray.qu") If @error Then Else For $ok = 0 To UBound($aArray2) - 1 ; Loop through the array. _GUICtrlListBox_AddString($idListBox, $aArray2[$ok]) ; should look more like this Next EndIf $aArray = FileReadToArray(@ScriptDir & "\Calc.qu") If @error Then Else For $y = 0 To UBound($aArray) - 1 ; Loop through the array. _GUICtrlListBox_AddString($idListBox, StringFormat($aArray[$y])) ; should look more like this ; Read File To Array is Done ;~ ExitLoop Dont exit loop unless there is an error handler Next EndIf Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 29, 2016 Moderators Share Posted October 29, 2016 abdulrahmanok, Quote this is my try And what about that script does not work as you wish? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 29, 2016 Author Share Posted October 29, 2016 (edited) yes,sorry i didn't explained it clearly :Calc.qu contains : 5 1.5 DaysArray.qu contains : Your Hours For 26/10/2016 Is : Your Hours For 27/10/2016 Is : Your Hours For 29/10/2016 Is : The script Show this in listbox : Your Hours For 26/10/2016 Is : Your Hours For 27/10/2016 Is : Your Hours For 29/10/2016 Is : 5 1.5 And what is want is : Your Hours For 26/10/2016 Is : 5 Your Hours For 27/10/2016 Is : 1.5 Edited October 29, 2016 by abdulrahmanok Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 29, 2016 Moderators Share Posted October 29, 2016 abdulrahmanok, And what should happen if, as in this case, the arrays do not have the same number of elements? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 29, 2016 Author Share Posted October 29, 2016 (edited) I just want to recognize them if array doesn't equal just add available lines Edited October 29, 2016 by abdulrahmanok Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 29, 2016 Moderators Share Posted October 29, 2016 abdulrahmanok, How about this? expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListBox.au3> $hGUI = GUICreate("Test", 500, 500) $idListBox = GUICtrlCreateList("", 10, 10, 400, 400, BitOr($WS_BORDER, $WS_VSCROLL)) ; Ensure no auto sort style GUISetState() ;$aArray = FileReadToArray(@ScriptDir & "\Calc.qu") Global $aArray[] = [5, 1.5] If @error Then Else ;$aArray2 = FileReadToArray(@ScriptDir & "\DaysArray.qu") Global $aArray2[] = ["Your Hours For 26/10/2016 Is :", "Your Hours For 27/10/2016 Is :", "Your Hours For 29/10/2016 Is :"] If @error Then Else For $ok = 0 To UBound($aArray2) - 1 ; Loop through the array. _GUICtrlListBox_AddString($idListBox, $aArray2[$ok]) If $ok <= UBound($aArray) - 1 Then _GUICtrlListBox_AddString($idListBox, $aArray[$ok]) Else _GUICtrlListBox_AddString($idListBox, "-") EndIf Next EndIf EndIf While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 29, 2016 Author Share Posted October 29, 2016 (edited) That good but the can't read from text file in this case .. I tried to add txtfile in you code : $try = FileReadToArray(@ScriptDir & "\Calc.qu") Global $aArray[] = [$try] If @error Then Else $try2 = FileReadToArray(@ScriptDir & "\DaysArray.qu") Global $aArray2[] = [$try2] If @error Then Else For $ok = 0 To UBound($aArray2) - 1 ; Loop through the array. _GUICtrlListBox_AddString($idListBox, $aArray2[$ok]) If $ok <= UBound($aArray) - 1 Then _GUICtrlListBox_AddString($idListBox, $aArray[$ok]) Else _GUICtrlListBox_AddString($idListBox, "-") EndIf Next EndIf EndIf but it gives me nothing Edit: I need to read from text because this date and this calc are created by another variable and it changes to much Edited October 29, 2016 by abdulrahmanok Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 29, 2016 Moderators Share Posted October 29, 2016 abdulrahmanok, Comment out the 2 Global lines - they were just to simulate reading the files. M23 P.S. When you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unnecessarily. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 29, 2016 Author Share Posted October 29, 2016 (edited) ok I will ... but is there is any way to read both of text files one by one ? Edit: all extra Quote are removed now Edited October 29, 2016 by abdulrahmanok Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 29, 2016 Author Share Posted October 29, 2016 omg You already solved this Thank you very much for your code $aArray = FileReadToArray(@ScriptDir & "\Calc.qu") ;Global $aArray[] = [5, 1.5] If @error Then Else $aArray2 = FileReadToArray(@ScriptDir & "\DaysArray.qu") ; Global $aArray2[] = ["Your Hours For 26/10/2016 Is :", "Your Hours For 27/10/2016 Is :", "Your Hours For 29/10/2016 Is :"] If @error Then Else For $ok = 0 To UBound($aArray2) - 1 ; Loop through the array. _GUICtrlListBox_AddString($idListBox, $aArray2[$ok]) If $ok <= UBound($aArray) - 1 Then _GUICtrlListBox_AddString($idListBox, $aArray[$ok]) Else _GUICtrlListBox_AddString($idListBox, "-") EndIf Next EndIf EndIf Appreciate this to you Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 29, 2016 Author Share Posted October 29, 2016 Solved , I understood all code except this : If $ok <= UBound($aArray) - 1 Then Can you Explain to me what the job of this code ? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 29, 2016 Moderators Share Posted October 29, 2016 abdulrahmanok, If the "calc" array is smaller than the "DaysArray" array (as in your example above) you will get an error if you try to access a non-existent element - this just makes sure that there is an element to write to the list and to just print a dash if not. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 29, 2016 Author Share Posted October 29, 2016 (edited) Thaaaaaanks for this I was already getting this Error and tried to solve it for days but nothing thank you again Full Solved Edited October 29, 2016 by abdulrahmanok Delete Quote :) 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