Jump to content

Executing commands from a text file


BALA
 Share

Recommended Posts

Is it possible to have a program execute commands written in a text file?

Edited by BALA
[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Link to comment
Share on other sites

Valuater's example reads a text file. The text file has nothing in it but this:

RunNote

The script that he has reads that text file's first line which is RunNote and from there it then calls the function RunNote() that is located in the script. You could have it call any function in the script this way.

Another way you can do this is by using the /AutoIt3ExecuteScript method. Check out my External Excute UDF in my signature. It is a UDF that will allow a compiled script to execute other scripts that are in au3 or a3x format. This allows for a dynamic functionality, similar to dll files.

Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

Another example:

script:

$read = IniRead("script.ini", "Section1", "1", "error")
If $read = "error" Then
    MsgBox(0, "ERROR", "An unknown error has occured.")
EndIf
$split = StringSplit($read, ",")
Select
    Case $split[0] = 0
        Call("MBox", 0, "ERROR", "Undefined Parameters")
    Case $split[0] = 1
        Call($split[1], 0, "ERROR", "Undefined Parameters")
    Case $split[0] = 2
        Call($split[1], 0, "ERROR", "Undefined Parameters")
    Case $split[0] = 3
        Call($split[1], 0, "ERROR", "Undefined Parameters")
    Case $split[0] = 4
        Call($split[1], $split[2], $split[3], $split[4])
    Case $split[0] = 5
        Call($split[1], $split[2], $split[3], $split[4], $split[5])
EndSelect

Func MBox($flag, $title, $text, $timeout)
    MsgBox($flag, $title, $text, $timeout)
EndFunc

script.ini file:

[section1]

1 = MBox, 0, Testing My Function, Did it work right?, 3

Doesn't have to be .ini file, but i prefer to use .ini files in my scripting. Just another example to maybe help you understand.

- Dan [Website]

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...