Sign in to follow this  
Followers 0
dazza

#include functions

6 posts in this topic

Wise People,

I have a script, let's call it 'BOSS'. This is a gui that detects other scripts. It puts these in a ListView.

These other scripts have many functions in them, for example:

script 'alpha' has:

Func alpha_step_1

Func alpha_step_3

Func alpha_step_4

How do I call these functions from BOSS without having to use the actual function name ie alpha_step_1()?

Ideally, I want to:

1) grab the other script name (alpha) - easy. I get this from the _FileListToArray or the Listview

2) check there is a Func step 3 - easy. StringinStr

3) Call the Func step 3 in alpha ???

I don't think you can call a function by variable? ie $func_name = "alpha_step_3" Call $func_name

Any help is much appreciated.

Share this post


Link to post
Share on other sites



First of all, it would be possible using Call, but why do you want to do that?

Why not included the file and using the normal function name?


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

First of all, it would be possible using Call, but why do you want to do that?

Why not included the file and using the normal function name?

I may have 50 alpha files; each having 40 functions. Thats 2000 function calls - all hardcoded. I need to somehow use another method.

Edited by dazza

Share this post


Link to post
Share on other sites

Just add those include files with #include<bla.au3> ...

and then use

For $i = 1 To 4
    Call('_Step_' & $i)
Next

Func _Step_1()
    ConsoleWrite(1 & @CRLF)
EndFunc ;==>_Step_1
Func _Step_2()
    ConsoleWrite(2 & @CRLF)
EndFunc ;==>_Step_2
Func _Step_3()
    ConsoleWrite(3 & @CRLF)
EndFunc ;==>_Step_3
Func _Step_4()
    ConsoleWrite(4 & @CRLF)
EndFunc ;==>_Step_4

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Just add those include files with #include<bla.au3> ...

and then use

For $i = 1 To 4
    Call('_Step_' & $i)
Next

Func _Step_1()
    ConsoleWrite(1 & @CRLF)
EndFunc ;==>_Step_1
Func _Step_2()
    ConsoleWrite(2 & @CRLF)
EndFunc ;==>_Step_2
Func _Step_3()
    ConsoleWrite(3 & @CRLF)
EndFunc ;==>_Step_3
Func _Step_4()
    ConsoleWrite(4 & @CRLF)
EndFunc ;==>_Step_4

Mega

BRILLIANT!

And simple... like me.

Many thanks :(

Share this post


Link to post
Share on other sites

No problem. Glad that I could help.


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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