Sign in to follow this  
Followers 0
lilx

havin problems with iniread

12 posts in this topic

hello,

just like the topic says, my script use the iniread function to read some settings used in the script. But I keep getting not found and so far I know everything works correctly so if someone can explain or show me what I am doing wrong

here is the part where it get the information from the ini

;Load Config
If FileExists ( @ScriptDir & "\Settings.ini" ) Then
$Path1 = IniRead ( @ScriptDir & "\Settings.ini", "Settings", "Dir1= ", "No Data Found")
$Path2 = IniRead ( @ScriptDir & "\Settings.ini", "Settings", "Dir2= ", "No Data Found")

$lijst1 = _FileListToArray($Path1)
$lijst2 = _FileListToArray($path2)
MsgBox ( 48, "X-sync", "Config Found And Loaded", 3 )
MsgBox ( 48, "X-sync", "Path1= " & $Path1 & @CRLF & "Path2= " & $Path2, 6 )
Else
    Config()
EndIfoÝ÷ ٩ݶ¬ÈhÂl¢)h¢K%G¡×½Õ'­¶)à³Ýý

Share this post


Link to post
Share on other sites



hello,

did change my script to the following, and still not working... really not understanding what i am doing wrong :)

make ini script

$sIni = @DesktopDir & "\Settings.ini"
$sData = "Dir1" & $Path1 & @CRLF & "Dir2" & $Path2 & @CRLF & "Autostart" & $aap
IniWriteSection($sIni, "Settings", $sData)oÝ÷ Ù©Ý*Þiا+-çèZ0x'£®¶­sc´ÆöB6öæfp¤bfÆTW7G267&DF"fײgV÷C²b3#µ6WGFæw2æægV÷C²FVà¢b33cµFÒæ&VB67&DF"fײgV÷C²b3#µ6WGFæw2æægV÷C²ÂgV÷Cµ6WGFæw2gV÷C²ÂgV÷C´F#gV÷C²ÂgV÷C´æòFFf÷VæBgV÷C²¢b33cµF"Òæ&VB67&DF"fײgV÷C²b3#µ6WGFæw2æægV÷C²ÂgV÷Cµ6WGFæw2gV÷C²ÂgV÷C´F#"gV÷C²ÂgV÷C´æòFFf÷VæBgV÷C² ¢b33c¶Æ§7CÒôfÆTÆ7EFô'&b33cµF¢b33c¶Æ§7C"ÒôfÆTÆ7EFô'&b33c·F"¤×6t&÷CÂgV÷Cµ×7æ2gV÷C²ÂgV÷C´6öæfrf÷VæBæBÆöFVBgV÷C²Â2¤×6t&÷CÂgV÷Cµ×7æ2gV÷C²ÂgV÷CµFÒgV÷C²fײb33cµFfײ5$ÄbfײgV÷CµF#ÒgV÷C²fײb33cµF"Âb¤VÇ6P 6öæfr¤VæD

and my ini looks like this.

[Settings]
Dir1C:\Documents and Settings\lilx\Bureaublad\Test1
Dir2C:\Documents and Settings\lilx\Bureaublad\Test2
Autostart0

Share this post


Link to post
Share on other sites

Try this:

;Load Config
If FileExists (@ScriptDir & "\Settings.ini" ) Then
$READ = IniReadSection(@ScriptDir & "\Settings.ini","Settings")
$lijst1 = _FileListToArray($READ[1][1])
$lijst2 = _FileListToArray($READ[2][1])
MsgBox ( 48, "X-sync", "Config Found And Loaded", 3 )
MsgBox ( 48, "X-sync", "Path1= " & $Path1 & @CRLF & "Path2= " & $Path2, 6 )
Else
    Config()
EndIf

When the words fail... music speaks

Share this post


Link to post
Share on other sites

You just needed to remove the = from the keyname in the IniRead function, not from the INI File contents.

INI Files follow this format

[section]

KeyName=KeyValue

When you perform INI Read, you would do it like so IniRead(INIFileName, "Section", "KeyName", Default)

And NOT KeyName= while reading.

Share this post


Link to post
Share on other sites

ok now i have this problem

C:\Documents and Settings\lilx\Bureaublad\X-syncGUI.au3 (30) : ==> Subscript used with non-Array variable.:

$lijst1 = _FileListToArray($READ[1][1])

$lijst1 = _FileListToArray($READ^ ERROR

Share this post


Link to post
Share on other sites

ok now i have this problem

C:\Documents and Settings\lilx\Bureaublad\X-syncGUI.au3 (30) : ==> Subscript used with non-Array variable.:

$lijst1 = _FileListToArray($READ[1][1])

$lijst1 = _FileListToArray($READ^ ERROR

Don't change content of ini. :)

When the words fail... music speaks

Share this post


Link to post
Share on other sites

ok i am really confused.. and that is just making all worse >_<, so i will try to look patient at it and i hope i find to solution.. will give i response once it worked or still not working :)

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

ok solved the problem, just was getting confused of what to change/do after so much tryin. but i got it working now thanks.. but now i got a other question

what i'm trying to make is a program that sync my files between two folders. well this is my code. (not pro work.)

#Include <File.au3>
#Include <Array.au3>

$Path1 = "C:\Documents and Settings\lilx\Bureaublad\Test2"
$Path2 = "C:\Documents and Settings\lilx\Bureaublad\Test1"
$lijst1 = _FileListToArray($Path1)
$lijst2 = _FileListToArray($path2)

If $lijst1[0] > $lijst2[0] Then
    $Aantal = $lijst1[0]
Else
    $Aantal = $lijst2[0]
EndIf

For $i = 1 to $Aantal Step 1
$Bestand1 = $lijst1[$i]
If @error = 2 Then
    $Bestand1 = ""
EndIf
$Bestand2 = $lijst2[$i]
If @error = 2 Then
    $Bestand2 = ""
EndIf
    If $Bestand1 = $Bestand2 Then
    Else
        FileCopy($path2 & "\" & $Bestand2,$path1 & "\" & $Bestand2)
        $lijst1 = _FileListToArray($Path1)
        $lijst2 = _FileListToArray($path2)
    EndIf
    If $Bestand2 = $Bestand1 Then
    Else
        FileCopy($path1 & "\" & $Bestand1,$path2 & "\" & $Bestand1)
        $lijst1 = _FileListToArray($Path1)
        $lijst2 = _FileListToArray($path2)
    EndIf
Next

from this code i keep getting this error

G:\sync.au3 (32) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$Bestand1 = $lijst1[$i]
$Bestand1 = ^ ERROR

the strange thing i got this code working earlyer, maybe tryin to make the code more better (more functionalty) but looking on the help. i am not really seeing a @error code for this error, so how can i solve this

Return Value
@Error: 1 = Path not found or invalid
        2 = Invalid $sFilter
        3 = Invalid $iFlag
        4 = No File(s) Found
Edited by lilx

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I write an example for you:

#include <File.au3>
$GUI = GUICreate("Dir Sync",400,400)
$EDIT1 = GUICtrlCreateEdit("",0,0,200,300,BitOR(0x00100000,0x00200000))
$EDIT2 = GUICtrlCreateEdit("",200,0,200,300,BitOR(0x00100000,0x00200000))
$SYNC1 = GUICtrlCreateButton("-->>",50,320,100,20)
$SYNC2 = GUICtrlCreateButton("<<--",250,315,100,20)
$PATH1 = GUICtrlCreateInput("",5,345,300,20)
$BROWSE1 = GUICtrlCreateButton("BROWSE",310,345,85,20)
$PATH2 = GUICtrlCreateInput("",5,370,300,20)
$BROWSE2 = GUICtrlCreateButton("BROWSE",310,370,85,20)
GUISetState()

While 1
    $MSG = GUIGetMsg()
    Switch $MSG
        Case $BROWSE1
            $DIR = FileSelectFolder("SELECT","")
            If Not @error Then 
                GUICtrlSetData($PATH1,$DIR)
                $FILE = _FileListToArray($DIR)
                If IsArray($FILE) Then
                $TEMP = ""
                For $INDEX = 1 To $FILE[0]
                    $TEMP &= $FILE[$INDEX] & @CRLF
                Next
                GUICtrlSetData($EDIT1,$TEMP)
                EndIf
            EndIf
        Case $BROWSE2
            $DIR = FileSelectFolder("SELECT","")
            If Not @error Then 
                GUICtrlSetData($PATH2,$DIR)
                $FILE = _FileListToArray($DIR)
                If IsArray($FILE) Then
                $TEMP = ""
                For $INDEX = 1 To $FILE[0]
                    $TEMP &= $FILE[$INDEX] & @CRLF
                Next
                GUICtrlSetData($EDIT2,$TEMP)
                EndIf
            EndIf
        Case $SYNC1
            $FILE = _FileListToArray(GUICtrlRead($PATH1))
            If IsArray($FILE) Then
            For $INDEX = 1 To $FILE[0]
                FileCopy(GUICtrlRead($PATH1) & "\" & $FILE[$INDEX],GUICtrlRead($PATH2) & "\" & $FILE[$INDEX],0)
            Next
            Refresh()
            EndIf
        Case $SYNC2
            If IsArray($FILE) Then
            $FILE = _FileListToArray(GUICtrlRead($PATH2))
            For $INDEX = 1 To $FILE[0]
                FileCopy(GUICtrlRead($PATH2) & "\" & $FILE[$INDEX],GUICtrlRead($PATH1) & "\" & $FILE[$INDEX],0)
            Next
            Refresh()
            EndIf
        Case -3
            Exit
    EndSwitch
    Sleep(25)
WEnd

Func Refresh()
$FILE = _FileListToArray(GUICtrlRead($PATH1))
$TEMP = ""
For $INDEX = 1 To $FILE[0]
    $TEMP &= $FILE[$INDEX] & @CRLF
Next
GUICtrlSetData($EDIT1,$TEMP)    
$FILE = _FileListToArray(GUICtrlRead($PATH2))
$TEMP = ""
For $INDEX = 1 To $FILE[0]
    $TEMP &= $FILE[$INDEX] & @CRLF
Next
GUICtrlSetData($EDIT2,$TEMP)
EndFunc
Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites

I write an example for you:

#include <File.au3>
$GUI = GUICreate("Dir Sync",400,400)
$EDIT1 = GUICtrlCreateEdit("",0,0,200,300,BitOR(0x00100000,0x00200000))
$EDIT2 = GUICtrlCreateEdit("",200,0,200,300,BitOR(0x00100000,0x00200000))
$SYNC1 = GUICtrlCreateButton("-->>",50,320,100,20)
$SYNC2 = GUICtrlCreateButton("<<--",250,315,100,20)
$PATH1 = GUICtrlCreateInput("",5,345,300,20)
$BROWSE1 = GUICtrlCreateButton("BROWSE",310,345,85,20)
$PATH2 = GUICtrlCreateInput("",5,370,300,20)
$BROWSE2 = GUICtrlCreateButton("BROWSE",310,370,85,20)
GUISetState()

While 1
    $MSG = GUIGetMsg()
    Switch $MSG
        Case $BROWSE1
            $DIR = FileSelectFolder("SELECT","")
            If Not @error Then 
                GUICtrlSetData($PATH1,$DIR)
                $FILE = _FileListToArray($DIR)
                $TEMP = ""
                For $INDEX = 1 To $FILE[0]
                    $TEMP &= $FILE[$INDEX] & @CRLF
                Next
                GUICtrlSetData($EDIT1,$TEMP)
            EndIf
        Case $BROWSE2
            $DIR = FileSelectFolder("SELECT","")
            If Not @error Then 
                GUICtrlSetData($PATH2,$DIR)
                $FILE = _FileListToArray($DIR)
                $TEMP = ""
                For $INDEX = 1 To $FILE[0]
                    $TEMP &= $FILE[$INDEX] & @CRLF
                Next
                GUICtrlSetData($EDIT2,$TEMP)
            EndIf
        Case $SYNC1
            $FILE = _FileListToArray(GUICtrlRead($PATH1))
            For $INDEX = 1 To $FILE[0]
                FileCopy(GUICtrlRead($PATH1) & "\" & $FILE[$INDEX],GUICtrlRead($PATH2) & "\" & $FILE[$INDEX],0)
            Next
            Refresh()
        Case $SYNC2
            $FILE = _FileListToArray(GUICtrlRead($PATH2))
            For $INDEX = 1 To $FILE[0]
                FileCopy(GUICtrlRead($PATH2) & "\" & $FILE[$INDEX],GUICtrlRead($PATH1) & "\" & $FILE[$INDEX],0)
            Next
            Refresh()
        Case -3
            Exit
    EndSwitch
    Sleep(25)
WEnd

Func Refresh()
$FILE = _FileListToArray(GUICtrlRead($PATH1))
$TEMP = ""
For $INDEX = 1 To $FILE[0]
    $TEMP &= $FILE[$INDEX] & @CRLF
Next
GUICtrlSetData($EDIT1,$TEMP)    
$FILE = _FileListToArray(GUICtrlRead($PATH2))
$TEMP = ""
For $INDEX = 1 To $FILE[0]
    $TEMP &= $FILE[$INDEX] & @CRLF
Next
GUICtrlSetData($EDIT2,$TEMP)
EndFunc
hi,

you didn't have to make a example for me :), but thank you for make it..atleast i can learn from a working example now and go from this path to my final result.

thank you very much. and will post my final result into example scripts. >_<

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

One thing you should fix. If the folder doesn't have any files give an error. Put the condition that $FILE to be an array. :)

EDIT:

I edited the post above.

Edited by Andreik

When the words fail... music speaks

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
Sign in to follow this  
Followers 0