VictorFarbau 0 Posted November 24, 2008 So far I wasn't able to find out if there's a way to do it. Maybe I am blind again, maybe it is impossible. Problem is easy to describe: Script A calls Dialog D. Dialog D calls script B. But script B needs information known to Script A. Any way to pass params from A to D to B w/o using global variables? Or can D maybe directly access information of A? Seems to me that dialogs run in a completely separate codespace. Maybe A can constantly query D for button actions and handle button events directly calling B until D is closed? Hm, that doesn't sound very pleasant. Just thinking... Thanks for any hints, VictorFarbau Share this post Link to post Share on other sites
Namikaze 0 Posted November 24, 2008 Dialogs do seem to run by their own little rules, but there are ways to access their data. It's important to know what kind of control you're using. Listboxes are basically just arrays, so they are fantastic for doing this sort of thing. Check the commands on this list. The ones that affect listboxes are prefixed with "lb". An example of storing data in a listbox would be using script A to load a listbox in dialog D, then using commands from script B to load the data in the listbox into a new array. Share this post Link to post Share on other sites
kronzky 5 Posted November 24, 2008 Global variables definitely work between different dialogs, and would probably be the easiest way to achieve this. Share this post Link to post Share on other sites
VictorFarbau 0 Posted November 24, 2008 @Namikaze - awesome idea. I am busy with it right now. @Kronzky - no doubt, but in my case this is not feasible. My dialog can potentially be used by several parties at the same time which would result in variable conflicts. I need context specific parameters here. Thanks, VictorFarbau Share this post Link to post Share on other sites
dr_eyeball 16 Posted November 24, 2008 You could probably use an invisible rscText control as well, assuming the data is a string or simple types which are convertible using "_data = call compile _str". You say "used by several parties at the same time"? A global variable is local to a client, a dialog is local to a client, each client runs it's own copy of a dialog, so there should be no conflict (unlike public variables). Share this post Link to post Share on other sites
VictorFarbau 0 Posted November 25, 2008 First, a definition of terms used by me: - private var; only known within a script - local var; only known to the local machine (local space) - public var; published to all clients in MP by "publicVariable" I am doing some concept work for the next version of VFAI and the control panel. The control panel can be invoked by every group leader simultaneously so I need to be careful with using public variables in the process. I tested the listbox which worked well, technically. But once translated into text (like "WEST 1-1-A") the unit name becomes useless - I didn't manage to get this back into code using "compile" or "format" in any fashion. Apart from that obstacle, thanks to Dr_Eyeball I am thinking about locality again. I guess this could work since the machine running the CP is also running the related action scripts. Local vars could be used in the process and later translated into public vars to be used by all other MP clients. I need to try this. Thanks for the input! Cheers, VictorFarbau Share this post Link to post Share on other sites
dr_eyeball 16 Posted November 25, 2008 But once translated into text (like "WEST 1-1-A") the unit name becomes useless So you need access to objects too. The method I used in Merlin was to simply maintain an array of objects, then reference the array via index. This index number can be stored as a string and/or converted back. New objects are added to the array after a quick 'find' to prevent duplicates. Old entries are never deleted, but can be nullified. Alternatively, the strings like "WEST 1-1-A" can be matched to objects by comparing their string equivalents, so long as this is done on the same client as the object reference and is not obtained via a public variable (which alters certain object names). Share this post Link to post Share on other sites
VictorFarbau 0 Posted November 25, 2008 Ehrm, yes, access to objects is required now that I can't translate unit/group names back into code (parser hates the space char). I was also thinking to keep a public array of group references for that purpose as my last option. It doesn't feel comfy but since 1.09 arrays supposedly work as public vars in MP. So I will need to give this a go. I guess your (btw - masterpiece! ) Merlin proves this is workable. Thanks again, VictorFarbau Share this post Link to post Share on other sites