Jump to content

Calling a function from a file


DoctorX
 Share

Recommended Posts

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...