zemkor

IniWrite/iniRead multiple lines of text

8 posts in this topic

#1 ·  Posted (edited)

Hello, i have question. How to save and read data from "GUICtrlCreateEdit" to ini file ?. Problem is: IniWrite write only first line of text and IniRead read only first line text.

How to do it?

Thanks for answer.

$text = GUICtrlCreateEdit("Text", 20, 165, 120, 50)
Func save()
    Local $ini_file, $workingdir
    ; save workingdir
    $workingdir = @WorkingDir
    ; save file dialog
    $ini_file = FileSaveDialog('Save', @ScriptDir, 'Ini (*.ini)|All (*.*)', 10, 'Config.ini', $Form1)
    ; check if return is valid
    If @error Or $ini_file == '' Then
        FileChangeDir($workingdir)
        Return SetError(1, 0, '')
    EndIf
    ; write to ini file
    IniWrite($ini_file, "Data", "Text", GUICtrlRead($Text))
EndFunc
$text = GUICtrlCreateEdit("Text", 20, 165, 120, 50)
Func load() ;natiahne nastavenia z .ini
    Local $ini_file, $workingdir
    ; save workingdir
    $workingdir = @WorkingDir
    ; open file dialog
    $ini_file = FileOpenDialog('Open', @ScriptDir, 'Ini (*.ini)|All (*.*)', 1, 'Config.ini', $Form1)
    ; check if return is valid
    If @error Or $ini_file == '' Then
        FileChangeDir($workingdir)
        Return SetError(1, 0, '')
    EndIf
    ; read from ini file
    GUICtrlSetData($text, IniRead($ini_file, "Data", "Text", ""))
EndFunc

This not working, read and write only firt line

Edited by zemkor

Share this post


Link to post
Share on other sites



zemkor,

Replace the EOL with a suitable dummy string (I tend to use "{ENTER}")before saving the string and then replace these dummies with @CRLF when re-reading it from the ini.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Melba23

Sorry but i dont understand you. Please can you explain ?

Share this post


Link to post
Share on other sites

zemkor,

Does this make it clearer?

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

$sText = "Line 1" & @CRLF & "Line 2" & @CRLF & "Line 3"
$sIniPath = @ScriptDir & "\test.ini"

$hGUI = GUICreate("Test", 500, 500)

$cEdit = GUICtrlCreateEdit($sText, 10, 10, 200, 200)

$cSave = GUICtrlCreateButton("Save", 10, 300, 80, 30)
GUICtrlSetState($cSave, $GUI_FOCUS)

$cRead = GUICtrlCreateButton("Read", 100, 300, 80, 30)

$cCheck = GUICtrlCreateButton("Check", 400, 300, 80, 30)
GUICtrlSetState($cCheck, $GUI_DISABLE)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cSave

            ; Read multiple lines
            $sOriginal = GUICtrlRead($cEdit)
            ; Clear edit
            GUICtrlSetData($cEdit, "")
            ; Convert EOLs into dummy strings
            $sConverted = StringReplace($sOriginal, @CRLF, "{ENTER}")
            ; This is the result
            MsgBox($MB_SYSTEMMODAL, "Converted before write", $sConverted)
            ; Which is written tot he ini

            IniWrite($sIniPath, "Multiline", "Text", $sConverted)
            ; Allow us to peek inside the ini

            GUICtrlSetState($cCheck, $GUI_ENABLE)
        Case $cRead

            ; Read the strign from the ini

            $sOriginal = IniRead($sIniPath, "Multiline", "Text", "Houston, we have a problem")
            ; Convert the dummies back into EOLs
            $sConverted = StringReplace($sOriginal, "{ENTER}", @CRLF)
            ; And we get this
            MsgBox($MB_SYSTEMMODAL, "Converted after read", $sConverted)
            ; Which we replace in the edit
            GUICtrlSetData($cEdit, $sConverted)
        Case $cCheck

            ; Read the ini content directly
            $sContent = FileRead($sIniPath)
            ; See it is all one string with dummies replacing the EOLs
            MsgBox($MB_SYSTEMMODAL, "Read from ini", $sContent)
    EndSwitch

WEnd

Please ask if anything is still not understood.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Huh, your solution working but is much difficult for me. Im newbie . I dont know how used your script for my problem. Can you show me please on my example?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>

$Form1 = GUICreate("TEST read and write", 301, 500, 224, 170)
$text = GUICtrlCreateEdit("Text", 20, 165, 200, 300)
$load = GUICtrlCreateButton("Load", 170, 41, 121, 33)
$save = GUICtrlCreateButton("Save", 170, 89, 121, 33)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $save
            save()
        Case $load
            load()

    EndSwitch
WEnd



Func load() ;natiahne nastavenia z .ini
    Local $ini_file, $workingdir
    ; save workingdir
    $workingdir = @WorkingDir
    ; open file dialog
    $ini_file = FileOpenDialog('Open', @ScriptDir, 'Ini (*.ini)|All (*.*)', 1, 'Config.ini', $Form1)
    ; check if return is valid
    If @error Or $ini_file == '' Then
        FileChangeDir($workingdir)
        Return SetError(1, 0, '')
    EndIf
    ; read from ini file

    GUICtrlSetData($text,IniRead($ini_file, "Data", "Text", ""))

; restore workingdir
    FileChangeDir($workingdir)
EndFunc

Func save()
    Local $ini_file, $workingdir
    ; save workingdir
    $workingdir = @WorkingDir
    ; save file dialog
    $ini_file = FileSaveDialog('Save', @ScriptDir, 'Ini (*.ini)|All (*.*)', 10, 'Config.ini', $Form1)
    ; check if return is valid
    If @error Or $ini_file == '' Then
        FileChangeDir($workingdir)
        Return SetError(1, 0, '')
    EndIf
    IniWrite($ini_file, "Data", "Text", GUICtrlRead($text))

    FileChangeDir($workingdir)
EndFunc

 

Share this post


Link to post
Share on other sites

zemkor,

Only 2 lines need changing - is the concept that hard to grasp?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>

$Form1 = GUICreate("TEST read and write", 301, 500, 224, 170)
$text = GUICtrlCreateEdit("Text", 20, 165, 200, 300)
$load = GUICtrlCreateButton("Load", 170, 41, 121, 33)
$save = GUICtrlCreateButton("Save", 170, 89, 121, 33)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg

        Case $GUI_EVENT_CLOSE
            Exit
        Case $save
            save()
        Case $load
            load()

    EndSwitch

WEnd



Func load() ;natiahne nastavenia z .ini

    Local $ini_file, $workingdir

    ; save workingdir

    $workingdir = @WorkingDir

    ; open file dialog
    $ini_file = FileOpenDialog('Open', @ScriptDir, 'Ini (*.ini)|All (*.*)', 1, 'Config.ini', $Form1)
    ; check if return is valid
    If @error Or $ini_file == '' Then
        FileChangeDir($workingdir)
        Return SetError(1, 0, '')
    EndIf

    ; read from ini file
    GUICtrlSetData($text, StringReplace(IniRead($ini_file, "Data", "Text", ""), "{ENTER}", @CRLF)) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    ; restore workingdir

    FileChangeDir($workingdir)
EndFunc   ;==>load

Func save()
    Local $ini_file, $workingdir

    ; save workingdir

    $workingdir = @WorkingDir

    ; save file dialog
    $ini_file = FileSaveDialog('Save', @ScriptDir, 'Ini (*.ini)|All (*.*)', 10, 'Config.ini', $Form1)
    ; check if return is valid
    If @error Or $ini_file == '' Then
        FileChangeDir($workingdir)
        Return SetError(1, 0, '')
    EndIf

    IniWrite($ini_file, "Data", "Text", StringReplace(GUICtrlRead($text), @CRLF, "{ENTER}")) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    FileChangeDir($workingdir)
EndFunc   ;==>save

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Melba23

Now I understand :)  Thanks you much.

Share this post


Link to post
Share on other sites

zemkor,

Glad I could help.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • damon
      By damon
      @JLogan3o13 I apologize, I did not think of it that way.  I have attached all the code and the Ini File information.  Please let me know if I need to add anything else to help understand what is happening.  thank you.
       
       
       
      Guys, I apologize in advance as I did not search for my answer before posting.  I just could not figure out a way to search that made since so I decided to go ahead and post my question.
       
      Getting to it.
      Background: this is being used to validate file names before moving to a new location.  though i have not included all the code, below is what i am having a problem with.
       I have an ini file that i am reading values from. Func ConfigDefineVars() -- I read the value of $ValidationRDA and everything is good then I set 
      $CaseRDALocationCheck = '$SplitFile[$ValidationRDALocation]' <> $ValidationRDA
      the code that will be used in the select case in Func FileSplitCount().  The problem i have is that even though the numbers = each other they are not recognizing as =.  
      This is what i am getting in my log file i create.
      2017-12-04 14:09:53 : RDA was 2403 should have been 2403:
      If I move $SplitFile[$ValidationRDALocation] <> $ValidationRDA to the Case line under the function it works correctly.
       
      I think this has to do with my use of ' ' around the '$SplitFile[$ValidationRDALocation]' but  i don't know what option i have in Func ConfigDefineVars I am not ready to define $SplitFile.  I have tried adding it to my Global Vars at the top of my script but that did not seem to help.
      There will be more fail this is just the first one in the select case.
       
      Any help or ideas would be greatly appreciated.
       
      thanks,
      Damon
      Example of a filename used.
      DWRSSD-37087-95-026.%-064.00-Tatum Family %-%-1230 Academy Rd-%-PERM-TRUE-2403.pdf
      This file will fail on the 95, it should be 095.  The problem i am getting is with the 2403 it fails even though the ini file value ValidationRDA = 2403 
       
       
      Ini File:
      [SSD_FolderPaths]
      pendingFolder=C:\Users\bg01152\Desktop\SSD Test\pending
      reviewFolder=C:\Users\bg01152\Desktop\SSD Test\review
      completedFolder=C:\Users\bg01152\Desktop\SSD Test\Completed
      FileNetProperties=DocumentTitle,ZipCode,County,MapAndGroupID,ParcelID,PropertyOwner,Subdivision,StreetAddress,LotNumber,DocumentType,Approved,RDANumber
      ValidationDocumentTitle=DWRSSD
      ValidationDocumentTitleLocation=1
      ValidationCountyCodeLocation=3
      ValidationRDA=2403
      ValidationRDALocation=12
      Validation3=TRUE
      Validation3Location=11
      Validation4=PERM
      Validation4Location=10
       
       
      #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> ;------------Global Vars --------------------- Global $SplitFile, $aFileList, $FileLog, $dFolder, $sFolder, $cFolder, $ConfigFile, $t Global $ValidationDocumentTitle, $ValidationDocumentTitleLocation, $ValidationCountyCodeLocation, $ValidationRDA Global $ValidationRDALocation, $Validation3, $Validation3Location, $Validation4, $Validation4Location, $FileNetPropertiesSplit Global $CaseCountyCheck, $CaseRDALocationCheck, $CaseValidation3LocationCheck, $CaseValidation4LocationCheck, $SplitFile ;;--------------------------------Check and Read Config files-------------------------------- $SysConfigFile = @ScriptDir & "\SysConfig.ini" ;----------------PreCheck for Config File-------------- If FileExists ($SysConfigFile) <> 1 Then Exit EndIf ;----------------End PreCheck-------------------------- $FileNetEXE = @ScriptDir & "\" & IniRead ($SysConfigFile, "FileNetUploader","FileName","") $delimiter = IniRead ($SysConfigFile, "FileInformation", "Delimiter","") $Filter = IniRead ($SysConfigFile, "FileInformation", "Filter", "") $ConfigFile = @ScriptDir & "\Config.ini" ;----------------PreCheck for Config File-------------- If FileExists ($ConfigFile) <> 1 Then Exit EndIf ;----------------End PreCheck-------------------------- ;;-------------------------------------------------------------------------------------------- $Sections = IniReadSectionNames ($ConfigFile) ;MsgBox (0,"test", $Sections[0] & @CRLF & $Sections[1] & @CRLF & $Sections[2] & @CRLF & $Sections[3] & @CRLF & $Sections[4]);TESTING ONLY - DELETE WHEN DONE $p = 0 Do $t = 0 ;used for precheck $p = $p + 1 ConfigDefineVars($Sections[$p]) ;MsgBox(0,"ConfigDefineVars", $sFolder & @CRLF & $dFolder & @CRLF & $cFolder);TESTING ONLY - DELETE WHEN DONE PreCheck($dFolder, $sFolder, $cFolder) ;Runs a Pre-check to make sure folder structure exists before running the program If $t = 0 Then ;MsgBox(0,"PreCheck Run", "Running next functions");TESTING ONLY - DELETE WHEN DONE ListArray($sFolder, $Filter) ;Puts File Names in String Array ;_ArrayDisplay ($aFileList, $Sections[$p]) If $t = 0 Then FileSplitCount($dFolder, $aFileList) ;Takes filename String Array and splits by $delimiter ;MsgBox(0,"PreCheck Run2", "Running split function");TESTING ONLY - DELETE WHEN DONE Else ;MsgBox(0,"PreCheck Run2", "Skipping split function");TESTING ONLY - DELETE WHEN DONE EndIf Else ;MsgBox(0,"PreCheck Run", "Skipping next functions");TESTING ONLY - DELETE WHEN DONE EndIf Until $p = $Sections[0] ExitScript() ;Exit script Function Func ConfigDefineVars($SectionsNum);Defines Variables from config file Sections $sFolder = IniRead ($ConfigFile, $SectionsNum, "pendingFolder","") ;Pending Folder, Folder that is awaiting the process $dFolder = IniRead ($ConfigFile, $SectionsNum, "reviewFolder","") ;Review Folder, Files that did not pass validation check and division needs to review $cFolder = IniRead ($ConfigFile, $SectionsNum, "completedFolder","") ;Completed Folder, Once process is completed this would be location files get moved to $FileNetProperties = IniRead ($ConfigFile, $SectionsNum, "FileNetProperties","") $FileNetPropertiesSplit = StringSplit ($FileNetProperties,",") $ValidationDocumentTitle = IniRead ($ConfigFile, $SectionsNum, "ValidationDocumentTitle","") $ValidationDocumentTitleLocation = IniRead ($ConfigFile, $SectionsNum, "ValidationDocumentTitleLocation","") $ValidationCountyCodeLocation = IniRead ($ConfigFile, $SectionsNum, "ValidationCountyCodeLocation","") $ValidationRDA = IniRead ($ConfigFile, $SectionsNum, "ValidationRDA","") $ValidationRDALocation = IniRead ($ConfigFile, $SectionsNum, "ValidationRDALocation","") $Validation3 = IniRead ($ConfigFile, $SectionsNum, "Validation3","") $Validation3Location = IniRead ($ConfigFile, $SectionsNum, "Validation3Location","") $Validation4 = IniRead ($ConfigFile, $SectionsNum, "Validation4","") $Validation4Location = IniRead ($ConfigFile, $SectionsNum, "Validation4Location","") If $ValidationCountyCodeLocation = 999 Then $CaseCountyCheck = 1 <> 1 Else ;MsgBox (0,"test of county code", "location = " &$ValidationCountyCodeLocation) $CaseCountyCheck = StringLen('$SplitFile[$ValidationCountyCodeLocation]') <> 3 ; Checks for 3 digit County Code EndIf If $ValidationRDALocation = 999 Then $CaseRDALocationCheck = 1 <> 1 Else $CaseRDALocationCheck = '$SplitFile[$ValidationRDALocation]' <> $ValidationRDA ; Checks for 4 Digit RDA EndIf If $Validation3Location = 999 Then $CaseValidation3LocationCheck = 1 <> 1 Else $CaseValidation3LocationCheck = '$SplitFile[$Validation3Location]' <> $Validation3 ; Checks that Approved = True EndIf If $Validation4Location = 999 Then $CaseValidation4LocationCheck = 1 <> 1 Else $CaseValidation3LocationCheck = '$SplitFile[$Validation4Location]' <> $Validation4 ; Checks that Document Type = PERM EndIf EndFunc Func ValidationCheck ($check1) $blank = StringLen ($check1) If $check1 Then EndIf EndFunc Func PreCheck($dFolder, $sFolder, $cFolder) ;----------------PreCheck for Destination Folder-------------- If FileExists ($dFolder) <> 1 Then $t = 1 Return Else $FileLog = FileOpen($dFolder & "\FileLog.log", 1) EndIf ;----------------End PreCheck-------------------------- ;----------------PreCheck for Source Folder-------------- If FileExists ($sFolder) <> 1 Then _FileWriteLog($FileLog, "Path to Pending Folder -- " & $sFolder & " -- does not exist") $t = 1 Return EndIf ;----------------End PreCheck-------------------------- ;----------------PreCheck for Completed Folder--------- If FileExists ($cFolder) <> 1 Then _FileWriteLog($FileLog, "Path to Completed Folder -- " & $cFolder & " -- does not exist") $t = 1 Return EndIf ;----------------End PreCheck-------------------------- EndFunc Func ListArray($sFolder, $Filter) $aFileList = _FileListToArray($sFolder, $Filter, 1) ;Create an array of files from the source folder filtering by filetype ;in the config.ini files for the specified section If @error = 1 Then ;MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.") _FileWriteLog($FileLog, "Path to File(s) is Invalid") $t = 1 Return EndIf If @error = 4 Then ;MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.") _FileWriteLog($FileLog, "No File(s) were found, exiting.") $t = 1 Return EndIf EndFunc ;==>ListArray  
       
       
       
    • ercicttech
      By ercicttech
      Hello, all..

      My AutoIT is pretty terrible - but I get by with trawling here
      I came across an issue where i had to parse a large key in a large ini file, and found that I was victim of inireadsection's limit of "Only the first 32767 chars are read for legacy reasons."
       
      I've attempted to put together some terrible code that parses an ini section.
      It's absolutely nowhere near good, but I figured I'd put it here so that folk who know what they're doing can laugh at improve it.
      $Ini = @ScriptDir & "\bigini.ini" Dim $IniArray[0][2] $KeyName = "Person" $R = FileOpen($Ini, 0) $IniStr = FileRead($R) FileClose($R) $Start = StringInStr($iniStr, "[" & $KeyName & "]") If $Start = 0 then Msgbox(16, "Error", "String not found") Exit EndIf $Stop = StringInStr($IniStr, @CRLF & "[", 0, 1, ($Start + 1)) If $Stop = 0 then $Stop = StringLen($IniStr) EndIf $String = StringMid($IniStr, $Start, ($Stop - $Start)) $Split = StringSplit($String, @CRLF, 1) $KeyCount = 0 Dim $IniArray[65535][2] For $Loop = 1 to $Split[0] $Add = "Y" $Str = $Split[$Loop] $EQBreak = StringInStr($Str, "=") Select Case StringMid($Str, 1, 1) = ";" $Add = "N" Case $EQBreak = 0 $Add = "N" Case Else $Add = "Y" EndSelect If $Add = "Y" then $KeyCount = $KeyCount + 1 $Key = StringMid($Str, 1, ($EQBreak - 1)) $Val = StringMid($Str, ($EQBreak + 1)) $IniArray[$KeyCount][0] = $Key $IniArray[$KeyCount][1] = $Val EndIf Next Redim $IniArray[$KeyCount +1][2] ; Add the number of hits to 00 to match inireadsection $IniArray[0][0] = $KeyCount _ArrayDisplay($IniArray) ; Do stuff with the Array like you would inireadsection  
    • CodeName_SexBobomb
      By CodeName_SexBobomb
      #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Test () Func Test() $Form1 = GUICreate("Form1", 414, 212, 1449, 1197) $Group1 = GUICtrlCreateGroup("Group1", 0, 0, 201, 161) Global $Combo1 = GUICtrlCreateCombo("", 0, 16, 201, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $Data = GUICtrlSetData($Combo1, "Combo 1|Combo 2|Combo 3") Global $Input1 = GUICtrlCreateInput("", 0, 48, 201, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("Group2", 210, 0, 200, 160) Dim $LABELS[20] Local $DIRECTORY = @ScriptDir & "\Test.ini" Local $SECTION = IniReadSection($DIRECTORY, "Section 1") Local $RESULTS = "" For $r = 1 To $SECTION[0][0] $RESULTS &= $SECTION[$r][1] & @CRLF Next $RESULTS = StringTrimRight($RESULTS, 1) For $N = 0 To 10 $LABELS[$N] = GUICtrlCreateLabel($RESULTS, 220, 15, 200, 100) Next GUICtrlCreateGroup("", -99, -99, 1, 1) $Button1 = GUICtrlCreateButton("Save", 80, 170, 121, 33) $Button2 = GUICtrlCreateButton("Exit", 210, 170, 121, 33) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _WriteData () Case $Button2 Exit EndSwitch WEnd EndFunc _WriteData () Func _WriteData () Local $TestData = GUICtrlRead($Combo1) Local $TestInput = GUICtrlRead($Input1) Local $Directory = @ScriptDir & "\Test.ini" IniWrite ($Directory, "Section 1", "", "" & $TestData & " " & $TestInput & @CRLF & "") EndFunc Hello Friends,
        Perhaps one of you can assist me. Currently I have a semi-working script. The goal of this script is to write the values of the combo box into an INI file and read said INI files. So far it does this.. but the issue is, It writes over line 1. The goal is to write on a new line each time to create a continuous log of submitted data.
    • GordonFreeman
      By GordonFreeman
      Hi, i'm trying to save data in an ini key that contains @LF and @CRLF (to use in an edit control). But @LF and @CRLF cause error in ini files (because it breaks the line). Then im trying to find a workaround. Here's the script thanks in advance:
       
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 438, 192, 124) $hEDIT = GUICtrlCreateEdit("",11,11,600,400) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### IniWrite("JustATest.ini","TestSec","TestKey","TestValue " & @CRLF & "Testing" & @LF & "test") $sData = IniRead("JustATest.ini","TestSec","TestKey","") GUICtrlSetData($hEDIT,$sData) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd  
    • RC86
      By RC86
      Afternoon, I could very well be doing this wrong so feel free to totally advise otherwise - I'm wanting to use a GUI to first display a key from within an INI file, then secondly change the INI file by using a FileSelectFolder command but then I want to see the GUI change to reflect the change I've just made.
      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 437, 192, 124) $Input1 = GUICtrlCreateInput(Iniread(@WorkingDir & "\test.ini","Path","FilePath",""), 64, 80, 121, 21) $Button1 = GUICtrlCreateButton("Change", 200, 80, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $selectedFolder = FileSelectFolder("Select Log Path Directory",@WorkingDir,0) If NOT $selectedFolder = "" Then $newLogPath = IniWrite(@WorkingDir & "\test.ini","Path","FilePath",$selectedFolder) EndIf EndSwitch WEnd So 2 part question really: (1) Should I be using GUICtrlCreateInput to display my INI read from within the GUI? (2) How can I refresh the GUI to update that to read the new information I've just written to the GUI?
      Thanks!