Martin_Bauer Posted January 21, 2021 Share Posted January 21, 2021 Hi again. this is my second time standing in front of a wall needing someone to push my brain in a different direction. To my Problem. At work before shipping an item, we scan the Tracking # as well as the Serial# of the device. I was thinking about creating a $Edit window. which will look like this Tracking#1 Serial#1 Tracking#2 Serial#2 Tracking#3 Serial#3 and so on (doing it in an edit window, allows for continues scanning , without looking at the pc , as the scanner makes a new line after each scan) i want to StringSplit the Edit which returns an 1DArray. and now comes the part where i simply have no idea any more. With the created Array, i would like to save it in an INI file like this: iniwrite ("Filename.ini" _nowdate, Tracking#1, Serial#1) iniwrite ("Filename.ini" _nowdate, Tracking#2, Serial#2) the Help file makes it even more less understandable for me. maybe someone can push my toughs in a direction. i am sure there must be an easy solution i simply do not see. expandcollapse popup#Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 544, 437, 192, 124) $Button1 = GUICtrlCreateButton("Button1", 360, 24, 75, 25) $Button2 = GUICtrlCreateButton("Button2", 360, 64, 75, 25) $Button3 = GUICtrlCreateButton("Button3", 360, 104, 75, 25) $Edit1 = GUICtrlCreateEdit("", 40, 24, 297, 369) GUICtrlSetData(-1, "Edit1") $Date1 = GUICtrlCreateDate("2021/01/21 10:07:25", 344, 192, 186, 21) GUISetState(@SW_SHOW) Opt("GUICoordMode",2) Opt("GUIOnEventMode",1) #EndRegion ### END Koda GUI section ### GuiCtrlSetOnEvent($Button1,"test") ; Start Add Stock While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _Close() GUIDelete() Exit EndFunc Func Test () $sText = GUICtrlRead($Edit1) Local $sText1 = StringSplit($sText, @CRLF ) For $i = 1 To $sText1 For $j = 2 To $sText1 IniWrite("Test.ini", "Variables", $i, $j) Next Next endfunc i did thinks like this: as well. but i don't know ... i might should take a brake.. $sText = GUICtrlRead($Edit1) ;$sText = StringReplace($sText, @CRLF, @tab) Local $sText1 = StringSplit($sText, @CRLF) Global $aArray_2D[100][2] ; Set these dimensions as required For $i = 0 To UBound($sText1) - 1 ; $aTemp = StringSplit($sText1[$i], @tab) For $j = 0 To UBound($aArray_2D, 2) - 1 $aArray_2D[$i][$j] = $sText1[$j + 1] ; Get the elements into the 2D array Next Next _ArrayDisplay($aArray_2D) Don't take the code to serious. as its just a Test. I Appreciate your / any thoughts on this. Link to comment Share on other sites More sharing options...
Subz Posted January 21, 2021 Share Posted January 21, 2021 (edited) You should be able to program the scanner to add a character for example a pipe "|" when scanning, if not try something like: Func Test () ;~ Read the Editbox Local $sText = GUICtrlRead($Edit1) ;~ Split the Editbox text into an array by using @CRLF, note flag option 1 splits by the entire delimiter, 0 or blank would split by @CR and @LF creating additional lines Local $aText = StringSplit($sText, @CRLF, 1) ;~ Loop through the array, step by 2 i.e. 1, 3, 5, etc... until $aText[0] (which is the last row number) For $i = 1 To $aText[0] - 1 Step 2 ;~ $aText[$i] = Tracking# ;~ $aText[$i+1] = Serial# ;~ Ternary expression "($i+1 > $aText[0] ? "" : $aText[$i+1])" is used just in cast [$i+1] is greater than $aText[0] which would cause an error, if it is we default to "" rather than $aText[$i+1] ;~ Following line is for debug purposes only ConsoleWrite($aText[$i] & " = " & ($i+1 > $aText[0] ? "" : $aText[$i+1]) & @CRLF) ;~ Write to the ini file IniWrite("Filename.ini", _NowDate(), $aText[$i], ($i+1 > $aText[0] ? "" : $aText[$i+1])) Next EndFunc Edited January 21, 2021 by Subz Link to comment Share on other sites More sharing options...
Nine Posted January 21, 2021 Share Posted January 21, 2021 Could you give us an example of the content of the edit box ? So we understand more your issue. Thanks. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Martin_Bauer Posted January 21, 2021 Author Share Posted January 21, 2021 Thank you Subz. I am still trying to figure this code out, on what makes it work. but so far it does work. i am fairly new when it comes to arrays 😅 thank you guys Link to comment Share on other sites More sharing options...
Subz Posted January 21, 2021 Share Posted January 21, 2021 Updated the code above along with comments, hopefully it makes sense. 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