jhocott Posted August 20, 2004 Posted August 20, 2004 Is there a better way to pass parameters than to collect data in one script, write that data to a file then #include that file in a second script? Jay
Bartokv Posted August 20, 2004 Posted August 20, 2004 There are several ways to pass information from one program to another: ini files, registry values, command-line arguments, environmental variables, etc. If both programs are called within the same comspec environment (ie: from a batch file) you could also use environmental variables, or errorlevels.I can't really say that one way is better than another without knowing how much information you're wanting to pass, and how you're calling/using each program. Describe your situation a little more, and we may be able to help.
jhocott Posted August 20, 2004 Author Posted August 20, 2004 There are several ways to pass information from one program to another: ini files, registry values, command-line arguments, environmental variables, etc. If both programs are called within the same comspec environment (ie: from a batch file) you could also use environmental variables, or errorlevels. I can't really say that one way is better than another without knowing how much information you're wanting to pass, and how you're calling/using each program. Describe your situation a little more, and we may be able to help. <{POST_SNAPBACK}>I want to collect 3 strings and pass them to a second script for use & display. The second script is compiled and launched by the task scheduler. (That's why I need one script to collect data and another to use the data, to avoid hanging the scheduled script in an InputBox. Please see later post regarding difficulty with include. Jay
Bartokv Posted August 20, 2004 Posted August 20, 2004 Ah, then perhaps your best/easiest way would be to use an INI file. (The registry is also a good alternative, but isn't recommended for the inexperienced...)Here's a very simple example:; Define some variables Dim $AppTitle="My App" Dim $Default="Some text" Dim $IniFile=@ScriptDir & "\MyFile.INI" ; Prompt user for text $Value = InputBox($AppTitle, "Please enter some text below:", $Default, "", -1, -1, -1, -1, 10) ;Write data to INI file IniWrite($IniFile, $AppTitle, "Text", $Value) ;Read data from INI file $IniText = IniRead($IniFile, $AppTitle, "Text", "Not value specified") ; Display results MsgBox(4096, $AppTitle, "Value entered: " & Chr(34) & $IniText & Chr(34)) ExitHope this helps!
Bartokv Posted August 20, 2004 Posted August 20, 2004 Here's a slightly more complicated script for three values: ; Define some variables Dim $AppTitle="My App" Dim $Default="Some text" Dim $IniFile=@ScriptDir & "\MyFile.INI" Dim $IniText[4] For $count = 1 To 3 ; Prompt user for text $Value = InputBox($AppTitle, "Please enter some text below:", $Default, "", -1, -1, -1, -1, 10) ;Write data to INI file IniWrite($IniFile, $AppTitle, "Text" & $count, $Value) Next For $count = 1 To 3 ;Read data from INI file $IniText[$count] = Chr(34) & IniRead($IniFile, $AppTitle, "Text" & $count, "Not value specified") & Chr(34) Next ; Display results MsgBox(4096, $AppTitle, "Values entered: " & @CR & $IniText[1] & @CR & $IniText[2] & @CR & $IniText[3])
jhocott Posted August 20, 2004 Author Posted August 20, 2004 Here's a slightly more complicated script for three values: ; Define some variables Dim $AppTitle="My App" Dim $Default="Some text" Dim $IniFile=@ScriptDir & "\MyFile.INI" Dim $IniText[4] For $count = 1 To 3 ; Prompt user for text $Value = InputBox($AppTitle, "Please enter some text below:", $Default, "", -1, -1, -1, -1, 10) ;Write data to INI file IniWrite($IniFile, $AppTitle, "Text" & $count, $Value) Next For $count = 1 To 3 ;Read data from INI file $IniText[$count] = Chr(34) & IniRead($IniFile, $AppTitle, "Text" & $count, "Not value specified") & Chr(34) Next ; Display results MsgBox(4096, $AppTitle, "Values entered: " & @CR & $IniText[1] & @CR & $IniText[2] & @CR & $IniText[3]) <{POST_SNAPBACK}>Thanks, I was attempting to use an .au3 or .txt file without success. Jay
jhocott Posted August 20, 2004 Author Posted August 20, 2004 Thanks, I was attempting to use an .au3 or .txt file without success. <{POST_SNAPBACK}> Jay
jhocott Posted August 20, 2004 Author Posted August 20, 2004 Would you explain how to use #include? In a test script I included and input script. The input script never ran that I could tell. like #include "input.au3" ;a good running script running test.au3 produced no visible output. A more general question,,, where may I find more prolific and detailed info on AutoIt scripts? Maybe a tutorial? Jay
Bartokv Posted August 20, 2004 Posted August 20, 2004 The #include statement does not include another script for execution... (Run may be used to launch compiled scripts.)When you #include "somefile.au3", you are basically telling your script to look within "somefile.au3" when you reference a function that is not defined within the current file. If the referenced function resides within the "somefile.au3" file, then it will call that routine instead of throwing an error. The #include functionality allows you to build your own User Defined Library (UDF) of common functions so that you don't have to keep adding the same code snippets to each new script.The help file contains examples for most commands/statements, and additional examples may be found within the FAQ area of the help file. You could also browse the v3 Scripts and Scraps area on this site, or Search the forums for related topics.Hope this helps!
jhocott Posted August 20, 2004 Author Posted August 20, 2004 The #include statement does not include another script for execution... (Run may be used to launch compiled scripts.) When you #include "somefile.au3", you are basically telling your script to look within "somefile.au3" when you reference a function that is not defined within the current file. If the referenced function resides within the "somefile.au3" file, then it will call that routine instead of throwing an error. The #include functionality allows you to build your own User Defined Library (UDF) of common functions so that you don't have to keep adding the same code snippets to each new script. The help file contains examples for most commands/statements, and additional examples may be found within the FAQ area of the help file. You could also browse the v3 Scripts and Scraps area on this site, or Search the forums for related topics. Hope this helps! <{POST_SNAPBACK}>Yes, that helps immeasureably! That is NOT what the help file says. I quote: "In an AutoIt script, other scripts can be included using the #include command. #include must be in lower-case." And the following 2 paragraphs talk about functions, then the #include-once caveat. I am willing to report this error if I knew to whom to report. The 'presumed path shortcuts'? (... & <...>) are also ambiguous. I must comment on the friendliness and helpfulness of this forum. It's far, far better than others I've been on. I'm gradually building a user's manual from help text for each function I use and from examples like yours. Thank you for your patience and helpfulness. Jay Jay
Developers Jos Posted August 20, 2004 Developers Posted August 20, 2004 What is wrong in the help file for the statement? When you Run your xyz.au3 script the file will be included at that time. When you compile your script into an EXE it will be included at that time not refreshed until the next compile... 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.
pekster Posted August 20, 2004 Posted August 20, 2004 (edited) For inter-communication between scripts, you might also try setting the title window of the hidden AutoIt3 window. See the AutoItWinGetTitle and AutoItWinSetTitle commands.I'm tempted to release another project that has all the knowledge to handle communication between 2 scripts in this manor including waiting for a specific messgae, or checking to see if a message exists. Not only do I believe people would find a use for it, but I would also use it when I had such a need myself. Maybe I'll start that project within a week. Gotta finish building my new machine. Had to order a few new parts (including an ATI Radeon X800 )Minor edit Edited August 20, 2004 by pekster [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.
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