willwatters Posted February 9, 2005 Share Posted February 9, 2005 Can I create code which is stored in a separate *.au3 and pass paramaters into in? I am intending on reporting errors to file using the following code: $file = FileOpen(c:\Development\vbcommon\LogFile\AutoLab.txt,1) FileWriteLine($file,"text") FileClose($file) What is the code to put this into a separate *.au3 file so that other code in separate *.au3 use this code by passing in paramaters? Thanks Link to comment Share on other sites More sharing options...
zcoacoaz Posted February 9, 2005 Share Posted February 9, 2005 um, im not quite sure what you mean, im either trying to read it with to much noise (which i wouldn't be suprised) or you didn't write too clear. try and use the $CmdLine array $CmdLine[0] has how many command line parameters were passed $CmdLine[1] and up has the command line parameters [font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font] Link to comment Share on other sites More sharing options...
Blue_Drache Posted February 9, 2005 Share Posted February 9, 2005 You want one program to run another by passing parameters? A combination of what the previous response plus ; Program A . code goes here to figure out parameters . Run("Program B.exe " & $param1 & " " & $param2 & " " & ... $paramN) In program B, you'd have a For $x = 1 to $cmdline[0] step 1 Select Case $cmdline[$x] = "blah" ; some statements Case $cmdline[$x] = "bleep" ; more statements EndSelect Next Or something like that. Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted February 9, 2005 Share Posted February 9, 2005 Couldn't you also do an <include file.au3> line into the top of the main code... Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) Link to comment Share on other sites More sharing options...
trids Posted February 10, 2005 Share Posted February 10, 2005 Can I create code which is stored in a separate *.au3 and pass paramaters into in?[..]What is the code to put this into a separate *.au3 file so that other code in separate *.au3 use this code by passing in paramaters?<{POST_SNAPBACK}>Wrap your function like this..Func _MyLog($psText);Writes $psText to my logfile. $file = FileOpen(c:\Development\vbcommon\LogFile\AutoLab.txt,1) FileWriteLine($file,$psText) FileClose($file)EndFunc.. Then save the above file to WillsIncludes.au3. Now you can call this function from any other script you care to write, if you #include its source: suppose you you want to use your log function in another script called WillsTest.au3 ...;WillsTest.au3#include WillsIncludes.au3 ;do stuff ;do stuff ;do stuff _MyLog("Hello world") ;do stuff ;do stuff _MyLog("Version = " & @AUTOITVERSION)HTH .. Sorry about the lack of indentation in the script samples, but that only seems to be available in CODE blocks, which in turn don't allow for custom colours. 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