|
|
|
date: Wed, 20 Aug 2008 07:00:59 -0700 (PDT),
group: microsoft.public.scripting.vbscript
back
RE: Execute error: Type Mismatch: 'Execute'
"kellym@paragon-global.co.uk" wrote:
> I'm in the process of writing a vbscript that uses KixForms as a GUI
> frontend.
> According to a number of web pages (and this group) it is possible to
> to use it as follows;
>
> ...
> Do While Form1.Visible
> Execute(Form1.DoEvents)
> Loop
Ummm...I'm more than a little confused here.
According to the VBS docs
http://msdn.microsoft.com/en-us/library/03t418d2(VS.85).aspx
the Execute *statement* will execute a *string*, only.
So unless Form1.DoEvents is a string, I don't see how that code works, at all.
Perhaps you could try
MsgBox Form1.DoEvents
to see what string Execute is attempting to work with?
********
A couple of minor points (that shouldn't affect the way the code runs):
(1) You are doing
Form1.Visible = "True"
But the Visible property is a BOOLEAN value, *not* a string. Yes, VBS will
convert the string to boolean for you, but it would be better to code
Form1.Visible = True
(2) You should not use parentheses with the EXECUTE statement. They don't
hurt, because any expression is still an expression when enclosed in parens,
but they can have weird side effects in other usages. So just as a matter of
practice, avoid them where they aren't required.
******************
This is *PURELY* a hunch on my part, but I can't help but wonder if you
shouldn't simply eliminate the EXECUTE and do
Do While Form.Visible
Form.DoEvents
Loop
date: Wed, 20 Aug 2008 11:52:01 -0700
author: Old Pedant
Re: Execute error: Type Mismatch: 'Execute'
On Aug 20, 7:52 pm, Old Pedant
wrote:
> "kel...@paragon-global.co.uk" wrote:
> > I'm in the process of writing a vbscript that uses KixForms as a GUI
> > frontend.
> > According to a number of web pages (and this group) it is possible to
> > to use it as follows;
>
> > ...
> > Do While Form1.Visible
> > Execute(Form1.DoEvents)
> > Loop
>
> Ummm...I'm more than a little confused here.
>
> According to the VBS docs
> http://msdn.microsoft.com/en-us/library/03t418d2(VS.85).aspx
> the Execute *statement* will execute a *string*, only.
>
> So unless Form1.DoEvents is a string, I don't see how that code works, at all.
>
> Perhaps you could try
> MsgBox Form1.DoEvents
> to see what string Execute is attempting to work with?
>
Thanks for the reply OP, to answer some of your questions;
When the script is run it loops around the do while loop waiting for
something to happen to the Form.DoEvents object.
If the button is clicked it returns the value of the Button.OnClick,
which in this case is Func_Quit.
I modified the script slightly so that it will display what
Form.DoEvents is returning;
Do While Form.Visible
func = Form.DoEvents
wscript.echo func
Execute(func)
Loop
If the button is clicked, the following is displayed on the console;
Func_Quit <- Function name being called
Function has been called <- Result of function being called.
This demonstrates that the function name is returned by the DoEvents
and it is called by the Execute command.
I've tried what you suggested earlier without success, one can click
the button but nothing happens.;
Do While Form.Visible
Form.DoEvents
Loop
What I want the script to do is to call the function, run it and then
return to the loop
Am I missing something fundamental about the execute statement ?
Thanks,
Martin.
date: Thu, 21 Aug 2008 08:09:41 -0700 (PDT)
author: unknown
Re: Execute error: Type Mismatch: 'Execute'
On Aug 21, 11:09 am, kel...@paragon-global.co.uk wrote:
> On Aug 20, 7:52 pm, Old Pedant
> wrote:
>
>
>
> > "kel...@paragon-global.co.uk" wrote:
> > > I'm in the process of writing a vbscript that uses KixForms as a GUI
> > > frontend.
> > > According to a number of web pages (and this group) it is possible to
> > > to use it as follows;
>
> > > ...
> > > Do While Form1.Visible
> > > Execute(Form1.DoEvents)
> > > Loop
>
> > Ummm...I'm more than a little confused here.
>
> > According to the VBS docs
> > http://msdn.microsoft.com/en-us/library/03t418d2(VS.85).aspx
> > the Execute *statement* will execute a *string*, only.
>
> > So unless Form1.DoEvents is a string, I don't see how that code works, at all.
>
> > Perhaps you could try
> > MsgBox Form1.DoEvents
> > to see what string Execute is attempting to work with?
>
> Thanks for the reply OP, to answer some of your questions;
>
> When the script is run it loops around the do while loop waiting for
> something to happen to the Form.DoEvents object.
> If the button is clicked it returns the value of the Button.OnClick,
> which in this case is Func_Quit.
>
> I modified the script slightly so that it will display what
> Form.DoEvents is returning;
>
> Do While Form.Visible
> func = Form.DoEvents
> wscript.echo func
> Execute(func)
> Loop
>
> If the button is clicked, the following is displayed on the console;
>
> Func_Quit <- Function name being called
> Function has been called <- Result of function being called.
>
> This demonstrates that the function name is returned by the DoEvents
> and it is called by the Execute command.
>
> I've tried what you suggested earlier without success, one can click
> the button but nothing happens.;
> Do While Form.Visible
> Form.DoEvents
> Loop
>
> What I want the script to do is to call the function, run it and then
> return to the loop
>
> Am I missing something fundamental about the execute statement ?
>
> Thanks,
> Martin.
Pure speculation here - I don't have KiXtart to test with - but maybe
this will work ...
Set Form = CreateObject( "Kixtart.Form" )
Set Button = Form.Button
Button.Text = "Close"
Button.OnClick = GetRef("Func_Quit")
Form.Show
Do While Form.Visible
wsh.sleep 100
Loop
Function Func_Quit
MsgBox "Just a message box"
wscript.echo "Function has been called"
End Function
The GetRef function is designed to bind functions to events. This
gets around the need for the Execute, I think. The Sleep in the loop
just gives up the processor for a time so that other threads get their
time to function.
Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
date: Thu, 21 Aug 2008 10:01:20 -0700 (PDT)
author: Tom Lavedas
Re: Execute error: Type Mismatch: 'Execute'
On Aug 21, 6:01 pm, Tom Lavedas wrote:
> On Aug 21, 11:09 am, kel...@paragon-global.co.uk wrote:
>
>
>
> > On Aug 20, 7:52 pm, Old Pedant
> > wrote:
>
> > > "kel...@paragon-global.co.uk" wrote:
> > > > I'm in the process of writing a vbscript that uses KixForms as a GUI
> > > > frontend.
> > > > According to a number of web pages (and this group) it is possible to
> > > > to use it as follows;
>
> > > > ...
> > > > Do While Form1.Visible
> > > > Execute(Form1.DoEvents)
> > > > Loop
>
> > > Ummm...I'm more than a little confused here.
>
> > > According to the VBS docs
> > > http://msdn.microsoft.com/en-us/library/03t418d2(VS.85).aspx
> > > the Execute *statement* will execute a *string*, only.
>
> > > So unless Form1.DoEvents is a string, I don't see how that code works, at all.
>
> > > Perhaps you could try
> > > MsgBox Form1.DoEvents
> > > to see what string Execute is attempting to work with?
>
> > Thanks for the reply OP, to answer some of your questions;
>
> > When the script is run it loops around the do while loop waiting for
> > something to happen to the Form.DoEvents object.
> > If the button is clicked it returns the value of the Button.OnClick,
> > which in this case is Func_Quit.
>
> > I modified the script slightly so that it will display what
> > Form.DoEvents is returning;
>
> > Do While Form.Visible
> > func = Form.DoEvents
> > wscript.echo func
> > Execute(func)
> > Loop
>
> > If the button is clicked, the following is displayed on the console;
>
> > Func_Quit <- Function name being called
> > Function has been called <- Result of function being called.
>
> > This demonstrates that the function name is returned by the DoEvents
> > and it is called by the Execute command.
>
> > I've tried what you suggested earlier without success, one can click
> > the button but nothing happens.;
> > Do While Form.Visible
> > Form.DoEvents
> > Loop
>
> > What I want the script to do is to call the function, run it and then
> > return to the loop
>
> > Am I missing something fundamental about the execute statement ?
>
> > Thanks,
> > Martin.
>
> Pure speculation here - I don't have KiXtart to test with - but maybe
> this will work ...
>
> Set Form = CreateObject( "Kixtart.Form" )
>
> Set Button = Form.Button
> Button.Text = "Close"
> Button.OnClick = GetRef("Func_Quit")
> Form.Show
>
> Do While Form.Visible
> wsh.sleep 100
> Loop
>
> Function Func_Quit
> MsgBox "Just a message box"
> wscript.echo "Function has been called"
> End Function
>
> The GetRef function is designed to bind functions to events. This
> gets around the need for the Execute, I think. The Sleep in the loop
> just gives up the processor for a time so that other threads get their
> time to function.
>
> Tom Lavedas
> ===========http://members.cox.net/tglbatch/wsh/
Hello Tom and OP,
Thanks for your suggestions, I have done some more debugging and have
found the resolution;
When the button is clicked it sets the Button.OnClick value to
Func_Quit.
This function is then called using the execute command in the loop
however, once the function has been called the loop continues and
loops around again but this time with a value of "" i.e. nothing (I've
no idea why it does this), and it this which causes the script to fall
over because it can't execute nothing.
The following snippet solves the problem...
Do While Form.Visible
DoEvent = Form.DoEvents
if DoEvent <> "" then
execute DoEvent
end if
Loop
Thanks,
Martin.
date: Tue, 26 Aug 2008 07:05:10 -0700 (PDT)
author: unknown
|
|