Tasmania Posted October 3, 2007 Share Posted October 3, 2007 Originally I used FileWriteLine and FileReadLine to do this, however I have discovered the wonderfulness of IniWrite, with the exception of one problem, I have two multi-line edit boxes inside of my application where having two lines is very common, and using IniWriteSection to store all of this text works, however I cannot read from the section. I want to read all of the section and store it in the edt box just as it is. I am going to post up the section that writes and reads the "INI" file, and also attach a copy of the script for those of you who would like to run it and see what is happening. As long as you only use the GUI and you do not hit "Run", it will not fail on your computer, so you can experiment and play around with File > Open and File > Save all you like. To access the two fields that allow multi-line storage they are under: Edit > Extra Notes and Type > Heat Seal Tool. expandcollapse popup; Upon execution - Create a directory, ask the user where/how they want to save the item, and create the file Func save() DirCreate(@MyDocumentsDir & "\Syte Line Automation\") $filesaveloc = FileSaveDialog("Save...", @MyDocumentsDir & "\Syte Line Automation\", "Syte Line Automation Files (*.sla)", 16, @MON & @MDAY & @YEAR & @HOUR & @MIN & @SEC & ".sla") If Not @error Then IniWrite($filesaveloc, "PRIMARY DATA", "Attn", GUICtrlRead($txtAttn)) IniWrite($filesaveloc, "PRIMARY DATA", "Email", GUICtrlRead($txtEmail)) IniWrite($filesaveloc, "PRIMARY DATA", "PWO", GUICtrlRead($txtPwo)) IniWrite($filesaveloc, "PRIMARY DATA", "SCA", GUICtrlRead($txtSca)) IniWrite($filesaveloc, "PRIMARY DATA", "Desc", GUICtrlRead($txtDesc)) IniWrite($filesaveloc, "PRIMARY DATA", "RqstDte", GUICtrlRead($dteRstdate)) IniWrite($filesaveloc, "PRIMARY DATA", "PE", GUICtrlRead($txtPE)) IniWrite($filesaveloc, "PRIMARY DATA", "PM", GUICtrlRead($txtPM)) IniWrite($filesaveloc, "PRIMARY DATA", "Charge", GUICtrlRead($txtCharge)) IniWrite($filesaveloc, "PO INFORMATION", "PONum", $ponum) IniWrite($filesaveloc, "PO INFORMATION", "POAmt", $poamt) IniWrite($filesaveloc, "PO INFORMATION", "PODisc", $podisc) IniWrite($filesaveloc, "SECONDARY INFORMATION", "QTY", $qty) IniWrite($filesaveloc, "ITEM INFORMATION", "Type", $type) IniWrite($filesaveloc, "ITEM INFORMATION", "ProdCode", $pcode) IniWrite($filesaveloc, "BFT INFORMATION", "Material", $material) IniWrite($filesaveloc, "BFT INFORMATION", "Gauge", $gauge) IniWrite($filesaveloc, "SECONDARY INFORMATION", "BICNotes", $bicnotes) IniWrite($filesaveloc, "SECONDARY INFORMATION", "BICNotesChecked", $bicnoteschecked) IniWrite($filesaveloc, "HST INFORMATION", "DupOF", $dupof) IniWrite($filesaveloc, "HST INFORMATION", "ComTO", $comto) IniWrite($filesaveloc, "HST INFORMATION", "Item", $comdup) IniWrite($filesaveloc, "HST INFORMATION", "CustItmDesc", $cid) IniWriteSection($filesaveloc, "CONSISTING OF", $consisting) IniWriteSection($filesaveloc, "EXTRA NOTES", $exnotes) MsgBox(64, "Save Complete", "File has been saved.") EndIf EndFunc ; Upon exection - Ask the user where the file is located, open it, read through the lines, and set the fields Func open() $fileopenloc = FileOpenDialog("Open...", @MyDocumentsDir & "\Syte Line Automation\", "Syte Line Automation Files (*.sla)") If Not @error Then $edtcnts = "" GUICtrlSetData($txtAttn, IniRead($fileopenloc, "PRIMARY DATA", "Attn", "Unknown")) GUICtrlSetData($txtEmail, IniRead($fileopenloc, "PRIMARY DATA", "Email", "Unknown")) GUICtrlSetData($txtPwo, IniRead($fileopenloc, "PRIMARY DATA", "PWO", "Unknown")) GUICtrlSetData($txtSca, IniRead($fileopenloc, "PRIMARY DATA", "SCA", "Unknown")) GUICtrlSetData($txtDesc, IniRead($fileopenloc, "PRIMARY DATA", "Desc", "Unknown")) $filedate = IniRead($fileopenloc, "PRIMARY DATA", "RqstDate", "1955/1/1") $filedatearr = StringSplit($filedate, "/") $newdate = $filedatearr[3] & "/" & $filedatearr[1] & "/" & $filedatearr[2] GUICtrlSetData($dteRstdate, $newdate) GUICtrlSetData($txtPE, IniRead($fileopenloc, "PRIMARY DATA", "PE", "Unknown")) GUICtrlSetData($txtPM, IniRead($fileopenloc, "PRIMARY DATA", "PM", "Unknown")) GUICtrlSetData($txtCharge, IniRead($fileopenloc, "PRIMARY DATA", "Charge", "Unknown")) $ponum = IniRead($fileopenloc, "PO INFORMATION", "PONum", "Unknown") $poamt = IniRead($fileopenloc, "PO INFORMATION", "POAmt", "Unknown") $podisc = IniRead($fileopenloc, "PO INFORMATION", "PODisc", "Unknown") $qty = IniRead($fileopenloc, "SECONDARY INFORMATION", "QTY", "Unknown") $type = IniRead($fileopenloc, "ITEM INFORMATION", "Type", "CONCEPT") $pcode = IniRead($fileopenloc, "ITEM INFORMATION", "ProdCode", "SAM-CONCPT") $material = IniRead($fileopenloc, "BFT INFORMATION", "Material", "Unknown") $gauge = IniRead($fileopenloc, "BFT INFORMATION", "Gauge", "Unknown") $bicnotes = IniRead($fileopenloc, "SECONDARY INFORMATION", "BICNotes", "0") $bicnoteschecked = IniRead($fileopenloc, "SECONDARY INFORMATION", "BICNotesChecked", "0") $dupof = IniRead($fileopenloc, "HST INFORMATION", "DupOF", "Unknown") $comto = IniRead($fileopenloc, "HST INFORMATION", "ComTO", "Unknown") $comdup = IniRead($fileopenloc, "HST INFORMATION", "Item", "Unknown") $cid = IniRead($fileopenloc, "HST INFORMATION", "CustItmDesc", "Unknown") $consisting = IniReadSection($fileopenloc, "CONSISTING OF") $exnotes = IniReadSection($fileopenloc, "EXTRA NOTES") $pcodedefset = 1 $firsthst = 0 $firstbft = 0 Switch $type Case StringUpper("Concept") GUICtrlSetState($mnuConcept, $GUI_CHECKED) GUICtrlSetState($mnuReconcept, $GUI_UNCHECKED) GUICtrlSetState($mnuSample, $GUI_UNCHECKED) GUICtrlSetState($mnuResample, $GUI_UNCHECKED) GUICtrlSetState($mnuAddSam, $GUI_UNCHECKED) GUICtrlSetState($mnuHST, $GUI_UNCHECKED) GUICtrlSetState($mnuBFT, $GUI_UNCHECKED) Case StringUpper("Reconcept") GUICtrlSetState($mnuConcept, $GUI_UNCHECKED) GUICtrlSetState($mnuReconcept, $GUI_CHECKED) GUICtrlSetState($mnuSample, $GUI_UNCHECKED) GUICtrlSetState($mnuResample, $GUI_UNCHECKED) GUICtrlSetState($mnuAddSam, $GUI_UNCHECKED) GUICtrlSetState($mnuHST, $GUI_UNCHECKED) GUICtrlSetState($mnuBFT, $GUI_UNCHECKED) Case StringUpper("Sample") GUICtrlSetState($mnuConcept, $GUI_UNCHECKED) GUICtrlSetState($mnuReconcept, $GUI_UNCHECKED) GUICtrlSetState($mnuSample, $GUI_CHECKED) GUICtrlSetState($mnuResample, $GUI_UNCHECKED) GUICtrlSetState($mnuAddSam, $GUI_UNCHECKED) GUICtrlSetState($mnuHST, $GUI_UNCHECKED) GUICtrlSetState($mnuBFT, $GUI_UNCHECKED) Case StringUpper("Resample") GUICtrlSetState($mnuConcept, $GUI_UNCHECKED) GUICtrlSetState($mnuReconcept, $GUI_UNCHECKED) GUICtrlSetState($mnuSample, $GUI_UNCHECKED) GUICtrlSetState($mnuResample, $GUI_CHECKED) GUICtrlSetState($mnuAddSam, $GUI_UNCHECKED) GUICtrlSetState($mnuHST, $GUI_UNCHECKED) GUICtrlSetState($mnuBFT, $GUI_UNCHECKED) Case StringUpper("Additional Sample") GUICtrlSetState($mnuConcept, $GUI_UNCHECKED) GUICtrlSetState($mnuReconcept, $GUI_UNCHECKED) GUICtrlSetState($mnuSample, $GUI_UNCHECKED) GUICtrlSetState($mnuResample, $GUI_UNCHECKED) GUICtrlSetState($mnuAddSam, $GUI_CHECKED) GUICtrlSetState($mnuHST, $GUI_UNCHECKED) GUICtrlSetState($mnuBFT, $GUI_UNCHECKED) Case StringUpper("Heat Seal Tool") GUICtrlSetState($mnuConcept, $GUI_UNCHECKED) GUICtrlSetState($mnuReconcept, $GUI_UNCHECKED) GUICtrlSetState($mnuSample, $GUI_UNCHECKED) GUICtrlSetState($mnuResample, $GUI_UNCHECKED) GUICtrlSetState($mnuAddSam, $GUI_UNCHECKED) GUICtrlSetState($mnuHST, $GUI_CHECKED) GUICtrlSetState($mnuBFT, $GUI_UNCHECKED) Case StringUpper("Blister Form Tool") GUICtrlSetState($mnuConcept, $GUI_UNCHECKED) GUICtrlSetState($mnuReconcept, $GUI_UNCHECKED) GUICtrlSetState($mnuSample, $GUI_UNCHECKED) GUICtrlSetState($mnuResample, $GUI_UNCHECKED) GUICtrlSetState($mnuAddSam, $GUI_UNCHECKED) GUICtrlSetState($mnuHST, $GUI_UNCHECKED) GUICtrlSetState($mnuBFT, $GUI_CHECKED) GUICtrlSetState($mnuAddMG, $GUI_ENABLE) EndSwitch If Not Mod($bicnoteschecked, 2) Then GUICtrlSetState($mnuBicNotes, $GUI_CHECKED) Else GUICtrlSetState($mnuBicNotes, $GUI_UNCHECKED) EndIf EndIf EndFunc Link to comment Share on other sites More sharing options...
Tiger Posted October 3, 2007 Share Posted October 3, 2007 (edited) Try this #include <Array.au3> $var1 = IniReadSection($fileopenloc, "CONSISTING OF") _ArrayDisplay($var1) $var2 = IniReadSection($fileopenloc, "EXTRA NOTES") _ArrayDisplay($var2) Edited October 3, 2007 by Tiger My UDFs:- _RegEnumKey Link to comment Share on other sites More sharing options...
Tasmania Posted October 3, 2007 Author Share Posted October 3, 2007 Thanks for the reply, tried it out and was unsuccessful. It displayed nothing, and when I redefined _ArrayDisplay to $consisting after the first define (I had to try to explain that, basically $cosisting = this, then $consisting = that, essentially replacing the values) it input 0 into the edit fields. Link to comment Share on other sites More sharing options...
Siao Posted October 3, 2007 Share Posted October 3, 2007 INI doesn't work with multiline data. So you have to parse your multiline strings into single line before writing to INI, and change back to multiline after you read from INI. Something like this... $StrToIni = StringReplace($str, @CRLF, "\r\n") and $str = StringReplace($StrFromIni, "\r\n", @CRLF) "be smart, drink your wine" Link to comment Share on other sites More sharing options...
Tasmania Posted October 3, 2007 Author Share Posted October 3, 2007 W00t, thanks Siao. I thought I was doomed for a few minutes there... I should have known that you can pick out @CRLF via StringReplace, but I didn't even think about it! Thanks 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