David,

Use whatever would be easiest for you to keep track of. Rather than use 
a single object to hold any dialog, I recommend using three different 
items, e.g. Dialog1, Dialog2, and Dialog3. Using them as globals is 
perfectly fine.

Steve


On 2/19/2015 9:00 PM, David via Scripting wrote:
> Listers,
> I have several Dialogs defined in my XML. For illustrative purposes, 
> let's just name them D1, D2, D3 and so forth.
>
> To make as clean a code as possible, each has its separate 
> EventHandling function, and each one is being called by its own Sub 
> routine. To make it all cook down to the raw basics, I end up with a 
> framework like this:
>
> Dim MyDialog: Set MyDialog = Nothing
>
> Sub Display1()
>     Set MyDialog = Dialog( "MyXml", "D1", "EH1")
>     Set MyDialog = Nothing
> End Sub 'Display1.
>
> Sub Display2()
>     Set MyDialog = Dialog( "MyXml", "D2", "EH2")
>     Set MyDialog = Nothing
> End Sub 'Display2.
>
> So far, everything is working. But my issue is, if it would be correct 
> to use a global MyDialog object, which would be used in all the subs. 
> Or, would it be more correct and smoothly running, to make the subs 
> define their own internal dialog object. Like
>
> Sub Display1()
>     Dim Dialog1
>     Set Dialog1 = Dialog( "MyXml", "D1", "EH1")
>     Set Dialog1= Nothing
> End Sub 'Display1.
>
> Sub Display2()
>     Dim Dialog2
>     Set Dialog2 = Dialog( "MyXml", "D1", "EH1")
>     Set Dialog2 = Nothing
> End Sub 'Display2.
>
>
> Is there any benefit, or drawback, in either of the approaches? One 
> thing is the readability of the code of course, which may be a bit 
> easier in the second aproach. But I am more concerned if there is any 
> programatic reason to choose the one over the other. Is there, for 
> instance, any chance that the global object could be called twice, and 
> thereby make the system go crazy in certain cases? Haven't seen any 
> such case yet, but want to make things as bug-free as possible.
>
> Thanks for any feedback,
>
>

_______________________________________________
Any views or opinions presented in this email are solely those of the author 
and do not necessarily represent those of Ai Squared.

For membership options, visit 
http://lists.window-eyes.com/options.cgi/scripting-window-eyes.com/archive%40mail-archive.com.
For subscription options, visit 
http://lists.window-eyes.com/listinfo.cgi/scripting-window-eyes.com
List archives can be found at 
http://lists.window-eyes.com/private.cgi/scripting-window-eyes.com

Reply via email to