Hi David,

I agree with Steve: just for clarity, if you only had a single global variable 
shared among all your dialogs, and a hotkey launched each sub displaying each 
dialog, then there's a chance more than one dialog would be open at once (and 
so over-writing the global dialog variable); I always think it's better to have 
a global variable for each dialog, that way, you can tell by looking at these 
variables which dialogs are open and which are not.  This could be helpful if 
you wanted to close all your dialogs due to WE or your app closing down; or 
perhaps you don't want to open a second instance of a dialog if one is already 
open.

Hth,

Chip






Chip Orange
Florida Public Service Commission
Computer Systems Analyst
850-413-6314



-----Original Message-----
From: Scripting 
[mailto:[email protected]] On 
Behalf Of David via Scripting
Sent: Thursday, February 19, 2015 9:00 PM
To: GWScripting
Subject: Dialog, Global or Internal?

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,


-- 
David

_______________________________________________
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/corange%40psc.state.fl.us.
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
_______________________________________________
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