Jump to content

Recommended Posts

Posted

i use autoit to run the same script with all my pc but i don't use the same functions in all of them so i try do do something like that

#include "function_for all_pc.au3"
if $pc="pc1" then
 #include "function_for pc1.au3"
elseif $pc="pc2" then
 #include "function_for pc2.au3"
endif

but it seem that #include can't be conditionnel
could you help me ?
(of course i can put all the functions in "function_for all_pc.au3" but it's not what i want (some functions in pc1 have the same name in pc2 but have not the same code )

  • Developers
Posted

The #include is performed at the time the script is read into memory, before execution, so that will not work. Why did you need this anyways as you can do those ifs at execution performing only the required code?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted
1 hour ago, michelb2 said:

of course i can put all the functions in "function_for all_pc.au3" but it's not what i want

I believe you will need to rethink your design.  You could add a suffix to your function name and use something like this to execute them :

Call ("DoThis_" & $PC, $param1, $param2)

Also in terms of maintainability, it should be easier to put all the functions into a single include as you do not have to open multiple files to make a modification...

Posted

the call is a good idea. 

$pc="pc1"
Call ("func1_" & $PC, "", "")
func func1_pc1($p1,$p2)
    msgbox(0,"","pc1")
EndFunc

if $pc ="pc2" then there is no error and the script does not abort. great !

i'll try to integrate that in my scripts

 

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
  • Recently Browsing   0 members

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