1. call_back ?

Can EU not do this?
... specifically, this definition for a user defined API 'function' says, *NO*
return value.

VOID WINAPI RasDialFunc(

    UINT unMsg, // type of event that has occurred
    RASCONNSTATE rasconnstate, // connection state about to be entered
    DWORD dwError // error that may have occurred
   ); 

 Return Values
None.

.. anyways, it's 'puking' all over me, so I'm.. just wondering, how ??

new topic     » topic index » view message » categorize

2. Re: call_back ?

> What do you mean 'puking'?  Can't you just return 0 (or whatever) in
> your call_back function?  VOID simply means the return value is ignored
> anyway...

Maybe... maybe not... I've tried (whatever).
This call_back is used to display progress messages when RasDial() is called
asynchronously.
I get something like, ( my own messages ) :
"Comm Port Opened Successfully."
.. which starts the modem dialing, maybe? 2 of 7 numbers.
.. and an immediate 'squeal of distress'  :)
.. ending with:
"Error 631: User disconnected the modem."
Not using the call_back, everything works just fine!

As a side-note, the VB guru I'm stealing code from, said that putting a break in
this call_back, or trying to step thru
it, crashed VB's IDE.
Sensitive!

new topic     » goto parent     » topic index » view message » categorize

3. Re: call_back ?

> Can EU not do this?
> ... specifically, this definition for a user defined API 'function' says, *NO*
> return
> value.
> 
> VOID WINAPI RasDialFunc(
> 
>     UINT unMsg, // type of event that has occurred
>     RASCONNSTATE rasconnstate, // connection state about to be entered
>     DWORD dwError // error that may have occurred
>    ); 
> 
>  Return Values
> None.
> 
> .. anyways, it's 'puking' all over me, so I'm.. just wondering, how ??

Actually this doesnt matter one bit as far as EU is concerned.  Or any
other language.

Under all the sugar of high/ mid level languages (even C) you can see
from looking at assembly code whats actually happening...

1> you call a function
2> the return value is placed into register EAX (or not)
3>
     A> if you need the return value you can assign it to a variable from EAX
     B> if you dont need it just dont do anything and EAX just sits there

Everything else doesnt matter.  If you assign a return value from a
function call you are getting the contents of the EAX register.  If you
dont need it thats fine.  The value is *still* in the EAX register.
In other words functions with and without return values are coded
the exact same way.

If they are coded the same way (which they are), you can go ahead
and use your call as a function that *does* return a value.  And you
can even assign the return to a variable (which in EU is required).
Just realise that the value returned will have no meaning because,
if they were nice, they zeroed EAX before returning.  Its possible
they did not touch it however and it would contain whatever just happens
to be there before the call happened...


Don Phillips - aka Graebel
     National Instruments
     mailto: eunexus @ yahoo.com

new topic     » goto parent     » topic index » view message » categorize

4. Re: call_back ?

Wolf wrote:

> Can EU not do this?
> ... specifically, this definition for a user defined API 'function' says, *NO*
> return value.
>
> VOID WINAPI RasDialFunc(
>
>     UINT unMsg, // type of event that has occurred
>     RASCONNSTATE rasconnstate, // connection state about to be entered
>     DWORD dwError // error that may have occurred
>    );
>
>  Return Values
> None.

I think in Euphoria this would be a procedure rather than a function,
wouldn't it?

> .. anyways, it's 'puking' all over me, so I'm.. just wondering, how ??

In the Euphoria 2.4 documentation for define_c_func(), it reads:
"If you are not interested in using the value returned by the C function,
you should instead define it with define_c_proc() and call it with
c_proc()."

Does that work for you?

Regards,
   Juergen

new topic     » goto parent     » topic index » view message » categorize

5. Re: call_back ?

Juergen Luethje wrote:

>I think in Euphoria this would be a procedure rather than a function,
>wouldn't it?
>  
>
This is the correct way to do it.  If the function your calling requires 
no return, then use procedure.  That C/C++ Function would translate into 
this in Euphoria

procedure RasDialFunc(integer unMsg, atom rasconnstate, atom dwError)
    ... Your handling of the Data that is returned to you ....
end procedure
c_proc(xRasDialFunc,{call_back(routine_id("RasDialFunc"))})

This should work.  And I assume that rasconnstate is a C/C++ Structure, 
so you will need to know the structure, in order to properly get the 
information from it.

>In the Euphoria 2.4 documentation for define_c_func(), it reads:
>"If you are not interested in using the value returned by the C function,
>you should instead define it with define_c_proc() and call it with
>c_proc()."
>
>Does that work for you?
>
>Regards,
>   Juergen
>

Good Luck,
Mario

new topic     » goto parent     » topic index » view message » categorize

6. Re: call_back ?

Thanks to all, but it was... my bad...
.. that was killing me.
I just wasn't handling *all* the possible return values generated by the
call_back properly.

Working now !

new topic     » goto parent     » topic index » view message » categorize

7. Re: call_back ?

Mario Steel wrote:
> procedure RasDialFunc(integer unMsg, atom rasconnstate, atom dwError)
>     ... Your handling of the Data that is returned to you ....
> end procedure
> c_proc(xRasDialFunc,{call_back(routine_id("RasDialFunc"))})

Call-back routines must be functions.
That is actually strange.
One should be able to get a machine address of a procedure.
Another restriction is that call-backs cannot be used in DOS,
which also is strange.

Regards, Alexander Toresson

Shhh! Be vewy quiet! I'm hunting wuntime ewwows!

new topic     » goto parent     » topic index » view message » categorize

8. Re: call_back ?

Alexander Toresson wrote:
> 
> Mario Steel wrote:
> > procedure RasDialFunc(integer unMsg, atom rasconnstate, atom dwError)
> >     ... Your handling of the Data that is returned to you ....
> > end procedure
> > c_proc(xRasDialFunc,{call_back(routine_id("RasDialFunc"))})
> 
> Call-back routines must be functions.
> That is actually strange.
> One should be able to get a machine address of a procedure.

I agree...

> Another restriction is that call-backs cannot be used in DOS,
> which also is strange.

Why?  Are you trying to wrap a DOS lib that has callbacks?  Just curious...

-- Brian
 
> Regards, Alexander Toresson
> 
> Shhh! Be vewy quiet! I'm hunting wuntime ewwows!

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu