Re: using forms like Functions - passing parameters to an from
- View SourceChristian,
I wish I had a good answer, but at least I have an answer.
Since there's no way (I know of) to cause the calling form to
actually block until the called form is done, you can have the called
form set a global indicating that it's done, and the calling form can
check to see if the global has been set. So the called form does
Scripting.Globals("done") = True
when it's done, and the calling form notices like this
If Scripting.Globals("done") Then
But you need some way to cause the caller to check if the callee is
done occassionally. One possible way would be to check in a loop,
but without using an external object there's no way (I can think of)
to cause the loop to yield the processor to the other form, so the
calling form would hang.
Instead, you could check whenever some host event fires, and do
something sneaky to cause the event. Assuming your host is ViewDraw,
you can have the called form open and close a bogus schematic, and
have the caller listen for the Application_ActivateView event. This
requires that you structure your code with the stuff you want to do
after calling the form in a separate sub.
Here it is all put together. First the calling form:
Scripting.Globals("done") = False ' It's not done
ExecuteCommand "form callee.efm"
' The called form causes this event to fire, so we
' check to see if it's done, and if so we continue.
If Scripting.Globals("done") Then
' The form we called is done, so we continue here
Now the called form:
' Your code here
Scripting.Globals("done") = True ' Now we're done
' Wake up the caller so he'll notice we're done.
ExecuteCommand "sch imdone.1"
' Close the bogus schematic we just opened. Check
' the name just for paranoia's sake.
If ActiveView.GetName(SHORT_NAME) = "imdone" Then
ActiveView.Document.Close False, ""
TheView.Cancel ' If you want the called form to close
P.S. I'm on vacation for a week, so I won't be able to respond for
--- In innoveda_users@y..., christian.alves@d... wrote:
> that helps - but not completely, because there is a difference in
> behavior compared to a function:
> the calling form does'nt wait until the called form/script has
> So there's the next question: how can I detect that
> Scripting.Globals("result") has changed?
> --- In innoveda_users@y..., lengholm@i... wrote:
> > Christian,
> > When a script runs in an ePD host it gets an intrinsic variable
> > called Scripting which has a Globals property that you can use to
> > store and retrieve global information. That's probably the best
> > to do what you're asking about. The called form can do this:
> > Scripting.Globals("result") = 42
> > to store the result, and the calling form can do this:
> > MsgBox Scripting.Globals("result")
> > to retrieve the result set by the called form. You can use the
> > technique to pass parameters.
> > Scripting.Globals is a collection of variants indexed by variants,
> > you can index the collection using a string (as above) or any
> > type, and you can store any type.
> > And you can open a form from ViewDraw script like this:
> > ExecuteCommand "form foo.efm"
> > or run a script like this:
> > ExecuteCommand "run foo.vbs"
> > Larry
> > --- In innoveda_users@y..., christian.alves@d... wrote:
> > > Hello,
> > > I'd like to call a form (efm) from within several forms.
> > > Is there a way to pass parameters to the called form and get
> > > back to the calling one? (So the the called form is used like a
> > > Function).
> > >
> > > Christian