how to handle events with in/out parameters 
Author Message
 how to handle events with in/out parameters

J(ava)Script doesn't support parameters by reference, so you
can't use that to return values from JavaScript.

Are you sure that "Object::onfetch" is a correct syntax?
I have never seen it, but maybe I didn't read the correct docs..

Hans Kesting


Quote:
> I need to handle events with modifiable parameters.  Here is an example
that
> works fine in VBScript:

> private sub Object_FetchB (A, B)   'B is in/out parameter
>    If A > 0 Then
>       B = 10
>    End If
> End Sub

> The similar function does not work in JavaScript:

> function Object::onfetchb( A, B)
> {
>    if(A > 0)
>    {
>       B = 10;
>    }
> }

> I have tried all sorts of variations with return values and
> event.returnValue.  The object does not get the value it is looking for.
> Can JavaScript handle these kind of events, or am I bound to use VBScript?



Sat, 17 May 2003 03:00:00 GMT  
 how to handle events with in/out parameters
in vbscript functions return values, subs don't
i.e.

Private Function Object_FetchB(A)
  If A > 0 Then
    Object_FetchB=10
  End If
End Function

you can call it like this;

MsgBox Object_FetchB(20)

in JScript just use return

function Object_FetchB(A)
{
 if(A > 0){
  return 10;
 }

Quote:
}

you can call it like this

alert(Object_FetchB(5));

on both cases you should return something if "A" < 0
like:

If A > 0 Then
  Object_FetchB=10
Else
  Object_FetchB=0
End If


Quote:
> I need to handle events with modifiable parameters.  Here is an example
that
> works fine in VBScript:

> private sub Object_FetchB (A, B)   'B is in/out parameter
>    If A > 0 Then
>       B = 10
>    End If
> End Sub

> The similar function does not work in JavaScript:

> function Object::onfetchb( A, B)
> {
>    if(A > 0)
>    {
>       B = 10;
>    }
> }

> I have tried all sorts of variations with return values and
> event.returnValue.  The object does not get the value it is looking for.
> Can JavaScript handle these kind of events, or am I bound to use VBScript?



Sat, 17 May 2003 03:00:00 GMT  
 how to handle events with in/out parameters
Try it (I don't remember where I first saw this documented - it may not be ;-)...

<html>
<head>
<script language="jscript">
function window::onload()
{
  alert("hello");

Quote:
}

</script>
</head>
<body>
</body>
</html>

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup...
--

Quote:

> J(ava)Script doesn't support parameters by reference, so you
> can't use that to return values from JavaScript.

> Are you sure that "Object::onfetch" is a correct syntax?
> I have never seen it, but maybe I didn't read the correct docs..

> Hans Kesting



> > I need to handle events with modifiable parameters.  Here is an example
> that
> > works fine in VBScript:

> > private sub Object_FetchB (A, B)   'B is in/out parameter
> >    If A > 0 Then
> >       B = 10
> >    End If
> > End Sub

> > The similar function does not work in JavaScript:

> > function Object::onfetchb( A, B)
> > {
> >    if(A > 0)
> >    {
> >       B = 10;
> >    }
> > }

> > I have tried all sorts of variations with return values and
> > event.returnValue.  The object does not get the value it is looking for.
> > Can JavaScript handle these kind of events, or am I bound to use VBScript?



Sat, 17 May 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Handling events with in/out parameters

2. Handling ActiveX events with parameters

3. Session Variable Time-outs

4. gs: how to handle parameters??

5. How to handle a event

6. How to Handle ActiveX Events

7. event handling

8. Handling events for a newly created window

9. Handling events from an Automation application/object

10. HOW to handle EVENT between different Frames

11. handling the "onbeforeunload" window event

12. event handling functions

 

 
Powered by phpBB® Forum Software