aa2zz6 Posted December 17, 2016 Posted December 17, 2016 (edited) I'm pulling data from our service line work orders forums using OCR software and I'm trying to place the data inside an .ini file so I can later insert it into our mapping system database. I can't figure out how to get an array to list 10 rows and 1 column that holds the data. I would like to scan multiple fields without the script closing and/or replacing previous text. The first post writes an .ini file, lists one row [0], and then the program closes.. not allowing me to select more fields. I tried using a while loop but no success. [Service Orders] IGNORE_ERRORS=0 0=FL-3375 #include <MsgBoxConstants.au3> ServiceOrders() Func ServiceOrders() For $n = 0 To 100 Local $sData = ClipGet() Local Const $aPath = @ScriptDir & "\OCR\Scan Service Orders\" & "SLO.ini" Local $Filewrite = 'IGNORE_ERRORS=' & IniWrite($aPath, "Service Orders", 'IGNORE_ERRORS', 0 & @CRLF & $n & "=" & $sData) Next EndFunc ;==>SLO Array ~ Not sure how to set the array to write to .ini serviceOrders() Func serviceOrders() Local $aArray[10][1] Local $iRows = UBound($aArray, $UBOUND_ROWS) ; Total number of rows 10 Local $iCols = UBound($aArray, $UBOUND_COLUMNS) ; Total number of columns 1 Local $iDimension = UBound($aArray, $UBOUND_DIMENSIONS) ; The dimension of the array e.g. 1/2/3 dimensional. Local $sData = ClipGet() ; grabs current text from clip board Local Const $aPath = @ScriptDir & "\OCR\Scan Service Orders\" & "SLO.ini" ; Fill the array with data. For $i = 0 To $iRows - 1 For $j = 0 To $iCols - 1 Local $Filewrite = 'IGNORE_ERRORS=' & IniWrite($aPath, "Service Orders", 'IGNORE_ERRORS', 0 & @CRLF & $n & "=" & $sData) $aArray[$i][$j] = "Row: " & $i & " - Col: " & $j Next Next Edited December 17, 2016 by aa2zz6
aa2zz6 Posted December 17, 2016 Author Posted December 17, 2016 I found a piece of code kylomas had wrote and revised it for my project. I'll post a working script below. Whatever is copied by ctrl c will be recorded inside the ini file. Hope this helps someone. ;---------------------------------------------------------------------------------------- ; Create a test INI file ;---------------------------------------------------------------------------------------- Local $inifile = @ScriptDir & '\test.ini', $str $rowCount = 1 $pgm = ClipGet() If Not FileExists($inifile) Then For $1 = 1 To $rowCount IniWrite($inifile, "Service Orders", "IGNORE_ERRORS" , 0) $str = '' Next EndIf ;---------------------------------------------------------------------------------------- ; ADD INI Entry ;---------------------------------------------------------------------------------------- If FileExists($inifile) Then Local $aPrograms = IniReadSection($inifile, "Service Orders") Local $EntryKey = "" & StringFormat('%02s', $aPrograms[0][0] +0) IniWrite($inifile, "Service Orders", $EntryKey, $pgm) EndIf Credit: kylomas [https://www.autoitscript.com/forum/topic/148812-write-new-line-in-existing-ini-section/]
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