Sign in to follow this  
Followers 0
fmen

#include vs run

5 posts in this topic

I am trying to run an au3 script from inside of another script without success:

If $msg = $bphone Then #include ("D:\HK\Phone.au3")

or

If $msg = $bphone Then run ("D:\HK\Phone.au3")

Both do not work...

Run works only when I make Phone.au3 an executable file.

Any suggestions how to run a script inside a script? Thanks.

Share this post


Link to post
Share on other sites



I am trying to run an au3 script from inside of another script without success:

If $msg = $bphone Then #include ("D:\HK\Phone.au3")

                                or

If $msg = $bphone Then run ("D:\HK\Phone.au3")

Both do not work...

Run works only when I make Phone.au3 an executable file.

Any suggestions how to run a script inside a script? Thanks.

<{POST_SNAPBACK}>

Instead of trying to run the file

Have a function in the file that you call

For Example:

#include "D:\HK\Phone.au3"

If $msg = $bphone Then Phone()

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Instead of trying to run the file

Have a function in the file that you call

For Example:

#include "D:\HK\Phone.au3"

If $msg = $bphone Then Phone()

<{POST_SNAPBACK}>

===========================================

Thanks but....

Error on loading file:

If $msg = $bphone Then Phone()

If $msg = $bphone Then ^ERROR

Share this post


Link to post
Share on other sites

Both of the things you are trying to do are using the wrong syntax.

The #include is a preprocessor instruction, so that entire file is dumped into the script without regard to the if statement.

Also, there are only 4 types of files that can be natively executed in Run(): EXE, BAT, COM, or PIF. Other files need an interpreter or another program to execute them (msi files need msiexec.exe, etc)

gafrost's method should work fine for what you want to do, just make a function around the entire include file, and call the function if it matches the statement


Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites

I would say that is a dirty method. It may be his only choice. He can always use Run() in conjunction with AutoIt3.exe. If I am not mistaken you can run a script using the command line. So that would be the cleanest option if he absolutly must not turn his script into an exe.

My thoughts,

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

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