Skyrimfus

Execute a script in a variable

4 posts in this topic

Hello.

This is my code so far

$command = FileRead("command.txt")
Execute($command)

When i type a code into command.txt and its a 1-line, without spaces command like

MsgBox(0,"Test","It Works")

then the box pops up like expected, but if i were to use multiple lines of code, it would just send me an error

 

Any way of executing a multi-line code from a variable?

Share this post


Link to post
Share on other sites



Skyrimfus,

Welcome to the AutoIt forums.


Look in the Help file under <Using AutoIt - Command Line Parameters - AutoIt specific command Line Switches> - that shows you how to run an entire script from within another.

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites
3 hours ago, Melba23 said:

Skyrimfus,

Welcome to the AutoIt forums.


Look in the Help file under <Using AutoIt - Command Line Parameters - AutoIt specific command Line Switches> - that shows you how to run an entire script from within another.

M23

Thanks.
I read the file and managed to "get it working", but that isn't what i really wanted.
For example if i were to write a new script in command.txt

 

MsgBox(0,"test","Changing the variables")
$variable = 2

it would change the $variable for that specific script, I want it to work between 2 scripts.
Also if my main script is

#include <Misc.au3>
;MY CODE HERE

RunWait(@AutoItExe & ' /AutoIt3ExecuteScript ' & $executePath

;REST OF THE CODE

If the executed code were to use function such as _Ispressed(), I would have to put #include <Misc.au3> again on the begining of the executed script, and thats not really my goal.

Share this post


Link to post
Share on other sites

Skyrimfus,

Now you are making things much more difficult - why not just have all these "scriptlets" within the main script as separate functions?

Perhaps if you explained what the end result is supposed to be we might be able to offer some more focused advice rather then make a series of tentative suggestions which finally prove not to be suitable as you move the goalposts in every new revelation.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

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