Sign in to follow this  
Followers 0
uplink477

Ini Read Functions

3 posts in this topic

Ok guys so basically i need help trying to get my Autoit script to define functions from an ini file. here is what i have so far

:config.ini

[functions]
_get()=inetget("http://www.google.com/index.html","C:\index.html",1,0)

:Script.au3

$var = IniReadSection("config.ini", "functions")
    For $i = 1 To $var[0][0]
        MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF & "Value: " & $var[$i][1])
        $Name = $var[$i][0]
        $func = $var[$i][1]
        
        func $name
            $func
        EndFunc     
    Next
_get()

Any help would be greatly appreciated.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You cannot "call" a function from an ini file, however, you can have functions in the script that can be "called" and that function can use parameters from the ini file

;[functions]
;_get()="http://www.google.com/index.html,C:\index.html,1,0"



Dim $Name, $Func

$var = IniReadSection("config.ini", "functions")

For $i = 1 To $var[0][0]
    MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF & "Value: " & $var[$i][1])
    $Name = $var[$i][0]
    $Func = $var[$i][1]
    
    Call($Name)

Next


Func _Get()
    
    $Split = StringSplit($Func, ",")
    If $Split[0] <> 4 Then
        MsgBox(0x0, "error", "The ini file has an incorrect number of parameters    ", 5)
        Return
    EndIf
    InetGet($Split[1], $Split[2], $Split[3], $Split[4])
    
EndFunc   ;==>_Get

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

i see what you mean. but i was more looking for a way to sort of store functions for later look up and use? wow i think my head is going explode if i think about this anymore

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