LordF Posted July 19, 2005 Posted July 19, 2005 Hi folks I'm trying to find a solution for a little problem with an overlaid function: Const $Maschine = StringMid ( @ComputerName, 6, 1 ) While 1 ; Desktop If $Maschine == "D" OR $Maschine == "d" Then #include "Desktop.au3" ExitLoop Endif ; Laptop If $Maschine == "L" OR $Maschine == "l" Then #include "Laptop.au3" ExitLoop Endif ; Drucker If $Maschine == "P" OR $Maschine == "p" Then #include "Drucker.au3" ExitLoop Endif ; Router If $Maschine == "R" OR $Maschine == "r" Then #include "Router.au3" ExitLoop Endif ; Server If $Maschine == "S" OR $Maschine == "s" Then #include "Server.au3" ExitLoop Endif ; Unknown MsgBox ( 48, "Fehler", "Der Name dieser Maschine entspricht nicht " & _ "der Namenskonventionen" ) Exit WEnd RunTests () This is the main function. The following is an example for the "header" file which I want to include: #include-once Func RunTests ( ) MsgBox ( 48, "title", "SERVER" ) EndFunc Each include file has the same function: RunTests () Is this construct possible? I allways get the Error message that the WEnd of the While statement is missing. Or do you have a similar idea? The included files will be big so that I want to save performance. I want to put it all into one file to make the usage easier. Thanks LordF
Henrik Posted July 19, 2005 Posted July 19, 2005 I believe the #include's are processed before the script runs (same for the other # keywords). In that case, not possible. Ignorance is strength.
seandisanti Posted July 19, 2005 Posted July 19, 2005 Henrik said: I believe the #include's are processed before the script runs (same for the other # keywords). In that case, not possible.<{POST_SNAPBACK}>i think you're right on that one... one possible work around, is to compile the scripts you would like to dynamically include and put them on the network share, or wherever you were going to have the au3 files to be included at run time, then have your select statement call the appropriate script by run() 'ing the executable. you can even use the opt("TrayIconHide",0) in the support scripts so that you don't get an extra systray icon or anything and it will still give the illusion of all being self contained....
/dev/null Posted July 19, 2005 Posted July 19, 2005 LordF said: Is this construct possible? I allways get the Error message that the WEnd of the While statement is missing.You are basically doing this:While 1 Func RunTests ( ) MsgBox ( 48, "title", "SERVER" ) EndFunc wendHowever, you can't define a function within a while statement (or any other statement "block").Instead have only one function RunTest() and give it a parameter, to testthe several devices.Func RunTests ($device) select case $device = "desktop" ; your desktop code here case $device = "laptop" ; your laptop code here endselect EndFunc RunTest("laptop") RunTest("desktop")CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
LordF Posted July 20, 2005 Author Posted July 20, 2005 /dev/null said: Instead have only one function RunTest() and give it a parameter, to testthe several devices.Func RunTests ($device) select case $device = "desktop" ; your desktop code here case $device = "laptop" ; your laptop code here endselect EndFunc RunTest("laptop") RunTest("desktop")Thanks for your help guys.The RunTests functions will be big so I thougt to minimize the overall programm invclude only the funktion you need.But it does not work as I see. So I will put them all into a spezific programm depending on the maschine. :/Thanks again.LordF
seandisanti Posted July 21, 2005 Posted July 21, 2005 LordF said: Thanks for your help guys.The RunTests functions will be big so I thougt to minimize the overall programm invclude only the funktion you need.But it does not work as I see. So I will put them all into a spezific programm depending on the maschine. :/Thanks again.LordF<{POST_SNAPBACK}>Assuming your computers are networked, it is very possible to do what you want, you just have to tweak the implementation. If i understand correctly, you have a few diff scripts that each have their own "RunTests" and you want to only include the script with the RunTests that applies to the machine that is executing the calling script. I said this in earlier reply but may not have elaborated enough... What you can do, is compile all of your scripts with the specialized 'RunTests" functions and put them all on a network share. that way they're all in one place. Then the algo for your client script to go on each machine could be: this is only psuedo code, don't try to execute it because it won't work as-is.... 1) map network share with the exe's 2) select statement to see which runtests script would apply to the current machine 3) use Run("z:\Rightscript.exe") where 'z:' is the drive letter you've assigned to the mapped network drive, and 'Rightscript.exe' is the correct compiled script for the case in question 4) msgbox(0,"done","i've found a way to implement 20 different scripts without having to add 1k to the client side of my script")not sure how original that idea is, but it will work. to take it one step further and make it look more professional, you could write a single runtests function that takes command line parameters to decide which tests are run etc, that way you don't have to have 20 exe's on your share, just one, and you still don't increase the size of the script being run on the local machine.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now