juk Posted August 4, 2005 Share Posted August 4, 2005 I have a master script that has a for-next loop in which it calls other functions in other files (files are #included of course). I need to call ProgressBar and LogToFile functions in every loop also. Like so:$length=UBound($files)-1 for $j=0 to $length Step +1 ProgressBar($files[$j]) Sleep($sleep) $p = Call($files[$j]) LogToFile($files[$j], $p) NextI have an array ($files) that has the function calls as strings. Now I found out that Call function doesn't support calling a function with parameters. Is there another way I could keep the simple loop and call the functions with parameters? -juk Link to comment Share on other sites More sharing options...
seandisanti Posted August 4, 2005 Share Posted August 4, 2005 (edited) I have a master script that has a for-next loop in which it calls other functions in other files (files are #included of course). I need to call ProgressBar and LogToFile functions in every loop also. Like so:$length=UBound($files)-1 for $j=0 to $length Step +1 ProgressBar($files[$j]) Sleep($sleep) $p = Call($files[$j]) LogToFile($files[$j], $p) NextI have an array ($files) that has the function calls as strings. Now I found out that Call function doesn't support calling a function with parameters. Is there another way I could keep the simple loop and call the functions with parameters?-juk<{POST_SNAPBACK}>you don't have to use the Call function... you can call the function like any of the default functions it it's #include'ed (#included? bah whatever) example;in script1 Func MsgBoxThis($x) msgbox(0,"blah?",$x) EndFunc;in script 2 #include <script1.au3> $tell = InputBox("? ? ?", "Tell me what to say....") MsgBoxThis($tell) Edited August 4, 2005 by cameronsdad Link to comment Share on other sites More sharing options...
juk Posted August 4, 2005 Author Share Posted August 4, 2005 you don't have to use the Call function... you can call the function like any of the default functions it it's #include'ed (#included? bah whatever) example<{POST_SNAPBACK}>I know, but I need to run the ProgressBar and LogToFile functions (as you see in my code) in every loop so how can I call the other functions that are in the $files array? The number of elements (=function calls) in $files -array can change and ProgressBar and LogToFile have to be run in between other funtions.-juk Link to comment Share on other sites More sharing options...
LxP Posted August 4, 2005 Share Posted August 4, 2005 If the elements in the array are properly formatted as AutoIt commands, or with some programmatic manipulation they can be, then Execute() is most likely for you. Link to comment Share on other sites More sharing options...
seandisanti Posted August 4, 2005 Share Posted August 4, 2005 I know, but I need to run the ProgressBar and LogToFile functions (as you see in my code) in every loop so how can I call the other functions that are in the $files array? The number of elements (=function calls) in $files -array can change and ProgressBar and LogToFile have to be run in between other funtions.-juk<{POST_SNAPBACK}>sorry, maybe i'm just being stupid, but i still don't understand where you're having an issue... here's some code...script 1:#include <stuffdoer.au3> $length=100 ProgressOn("Progress Bar","Stuff is Happening",0,0) Global $j $j = 0 while 1 $j = stuffdoer($j) ;MsgBox(0,"blah",$j) ProgressSet($j/$length*100,$j/$length*100 & "%") sleep(10) if $j = $length then ExitLoop WEndscript 2 that is called during the loop...Func StuffDoer($x) Return($x + 1) EndFuncyou can have a control variable that is incremented in your outermost loop and no matter how many other functions/scripts whatever you call, your progress will still do what you want it to if you do it right....i hope this example helps... Link to comment Share on other sites More sharing options...
hgeras Posted August 5, 2005 Share Posted August 5, 2005 I dont if that works but maybe you had a chance if you used Call(String(Files[$j])) or Execute(...) instead.... Test it and tell me.... Useful information about COM/Objects referenceMy Scripts:PapDefragNvidia Temperature Logger V3.0 with graph analyzerAutoiIt Update Checker And Downloader V1.0ArrayPush UDF Link to comment Share on other sites More sharing options...
juk Posted August 5, 2005 Author Share Posted August 5, 2005 I dont if that works but maybe you had a chance if you usedCall(String(Files[$j])) or Execute(...) instead....Test it and tell me....<{POST_SNAPBACK}>Call(String($blah[$j])) works like it would work without theString function in there, meaning I still can't use Call to call a function using parameters. So that won't help.I installed the latest beta version so that I could try that Execute thingy, but when I do Beta Run or Beta Compile from SciTE it just pops up an AutoCheck window telling: ERROR: Execute(): undefined function. What's wrong?-juk Link to comment Share on other sites More sharing options...
juk Posted August 5, 2005 Author Share Posted August 5, 2005 sorry, maybe i'm just being stupid, but i still don't understand where you're having an issue... here's some code...*clip*you can have a control variable that is incremented in your outermost loop and no matter how many other functions/scripts whatever you call, your progress will still do what you want it to if you do it right....i hope this example helps...<{POST_SNAPBACK}> Maybe I'm not explaining myself clearly enough. See, you're calling only StuffDoer() in your script, but I need to call different functions that are listed (in an array, which is created) before the loop.Like for example:$files=_ArrayCreate( _ "TheFirstFunction", _ "SecondOne", _ "Third", _ "LastOne(5,3)") The variable name "files" is a bit misleading. I used to have filenames listed in the array and then call RunWait to run autoit.exe with the filename as a commandline parameter, but now I need those functions to return something back, hence this mess.The first three function calls would work fine with Call(), but the LastOne needs parameters. And the contents of the array might change so that it'd be calling a dozen functions with parameters, so I'd rather not hardcode the funtion calls.-juk Link to comment Share on other sites More sharing options...
SumTingWong Posted August 5, 2005 Share Posted August 5, 2005 (edited) The first three function calls would work fine with Call(), but the LastOne needs parameters. And the contents of the array might change so that it'd be calling a dozen functions with parameters, so I'd rather not hardcode the funtion calls.-juk<{POST_SNAPBACK}>You could put your params in a global array.e.g, before each call,$aParams[0] = NumOfParams $aParams[1] = param1 $aParams[2] = param2 $aParams[3] = param3 . . . Edited August 5, 2005 by SumTingWong Link to comment Share on other sites More sharing options...
juk Posted August 5, 2005 Author Share Posted August 5, 2005 You could put your params in a global array.e.g, before each call,$aParams[0] = NumOfParams $aParams[1] = param1 $aParams[2] = param2 $aParams[3] = param3<{POST_SNAPBACK}>Heh, that might do the trick. Though it would have to be multidimensional array if I wanted the parameters for all possible functions to be included.But all that sounds too macgyveristic and complicated (I'd have to change every function declaration). I'm even thinking of writing a script that writes the required function calls to a file in a loop and then includes the file into the main script and runs it after that! Blah, I'd rather get that Execute() to work or a better version of Call(). Btw, anyone had similar problems with Execute (see a couple of posts previous)?-juk Link to comment Share on other sites More sharing options...
juk Posted August 5, 2005 Author Share Posted August 5, 2005 You could put your params in a global array.<{POST_SNAPBACK}>Actually, that was a relatively simple way to get this working! Thanks! -juk Link to comment Share on other sites More sharing options...
SumTingWong Posted August 5, 2005 Share Posted August 5, 2005 Actually, that was a relatively simple way to get this working! Thanks! -juk<{POST_SNAPBACK}>Good....remember, always KISS! Link to comment Share on other sites More sharing options...
hgeras Posted August 6, 2005 Share Posted August 6, 2005 I installed the latest beta version so that I could try that Execute thingy, but when I do Beta Run or Beta Compile from SciTE it just pops up an AutoCheck window telling: ERROR: Execute(): undefined function. What's wrong?SCiTe doesnt have the latest definitions included.So it thinks it is a UDF and searches for Func Execute() in the script.If you press continue it will work fine. Useful information about COM/Objects referenceMy Scripts:PapDefragNvidia Temperature Logger V3.0 with graph analyzerAutoiIt Update Checker And Downloader V1.0ArrayPush UDF Link to comment Share on other sites More sharing options...
juk Posted August 8, 2005 Author Share Posted August 8, 2005 SCiTe doesnt have the latest definitions included.So it thinks it is a UDF and searches for Func Execute() in the script.If you press continue it will work fine.<{POST_SNAPBACK}> So it does. I didn't realize to do that with Beta Run as I tried with regular Build. Thanks!-juk Link to comment Share on other sites More sharing options...
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