Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Global Arrays for Passing Between Scripts

Status
Not open for further replies.

aaiqbal

Programmer
Sep 15, 2003
26
US
Hi Everyone,
I wanted to know if there's a way to access the values of an array from different scripts. I know only the predefined global variables I0-I9, S0-S9 and L0-L9 can be passed between scripts or be seen by all scripts. I want that functionality with an array. Is this possible? Any help would be appreciated. Thanks.
 
You can use DDE to pass values between scripts, I have a couple examples of using DDE to communicate between multiple instances of Procomm on my site. I'm not certain if you can pass the value of an array between scripts, you may need to just pass the values on element at a time.


aspect@aspectscripting.com
 
Hi Knob,
I was wondering if you could point me to the script to which you are referring. Also, I don't necessarily want to "pass" a whole array to another script but I want all of my scripts to be able to see the array and to be able to modify the array. If I make the array a global array in my main script, from which all the other scripts are spawned, will the other scripts be able to see the array? Thanks for any help you can provide.
 
This script can be run from a "parent" Procomm window and will launch two "child" Procomm windows that can be controlled via DDE (in this case, each child window is told to run a different script):

proc main
string pathname
integer pwhwnd1, pwhwnd2
long pwchanid1, pwchanid2

pathname = $pwtaskpath ;Get Procomm's path.
addfilename pathname "PW5.EXE" ;Add Procomm's EXE.
if run pathname ;Run the program.
pause 5
pwhwnd1 = $mainwin ;Get the active window ID.
if run pathname
pause 5
pwhwnd2 = $mainwin
if ddeinit pwchanid1 "PW5" "System" pwhwnd1 ;Establish DDE connection with first instance.
ddeexecute pwchanid1 "EXECUTE HINTS.WAX"
else
errormsg "Error initializing DDE channel"
endif
if ddeinit pwchanid2 "PW5" "System" pwhwnd2 ;Establish DDE connection with second instance.
ddeexecute pwchanid2 "EXECUTE HOSTUTIL.WAX"
else
errormsg "Error initializing DDE channel"
endif
endif
else ;Problems running program.
errormsg "Error running %s" pathname
endif
endproc

Now, the script above will let your parent script push values to the child scripts via the ddepoke command. If you wanted to go the other way (the child scripts requesting updated variable information from the parent script), I think it is possible but it may require the parent script passing the proper values for the ddeinit command to the child scripts (so that the child scripts can setup a DDE connection back to the parent script).

In the sample above, the ASPECT environment is not shared (due to the run command being used), so the child scripts and parent script cannot share values of the predefined global variables.


aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top