Sign in to follow this  
Followers 0
DoctorX

Calling a function from a file

3 posts in this topic

Is it possible to call a function from an external file that contains the name of the function? For example, say I have a file called "ExternalFile.txt" and the first line of the file contains the text "MyFunction".

Now, what I want to do is to call a function named "MyFunction" in the script. I could do so like this...

$file = FileOpen ("ExternalFile.txt", 0)
    $function = FileReadLine ($file, 1)
    FileClose $file

            If $function = "MyFunction" Then
                MyFunction ()
            EndIf


    Func MyFunction ()
        MsgBox (0, "", "MyFunction Entered")
    EndFunc

But that seems rather redundant, and would get to be impractical when the actual external file contains many function names. What I would rather do is something like this:

$file = FileOpen ("ExternalFile.txt", 0)
    $function = FileReadLine ($file, 1)
    FileClose $file

        $function ()

    Func MyFunction ()
        MsgBox (0, "", "MyFunction Entered")
    EndFunc

Which of course, will not work but hopefully gives you an idea of what I'm trying to do. Is this possible at all?


-DRX

Share this post


Link to post
Share on other sites



Is the Call() function what you're after?

Share this post


Link to post
Share on other sites

Ah, yes. That'll do it. Don't know how I missed that in the help file. Thanks again Alex.


-DRX

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