Re: XForms: fl_add_timeout

David Smead (smead@amplepower.com)
Mon, 2 Nov 1998 17:16:56 -0800 (PST)

# To subscribers of the xforms list from David Smead <smead@amplepower.com> :

Greetings,

C declarations - Some notes from the distant past:

1. Make a left to right statement of what you want to declare, i.e.:
pointer to function returning pointer to array of pointers to functions
returning integers.

2. Choose a name, (identifier) for this mess and write it in the middle of the
page so that you can write on both sides of it. Note that () and [] can only
appear to the right of an identifier, and * to the left.

3. The first word is pointer, so add * to make *mess.

4. The next word is function, so paren the whole thing and then add () to make
(*mess)().

5. Next word is `returning' which goes on the left, and it's a pointer, so that
means to use a * which now gives *(*mess)().

6. The pointer returned is to an array, so you have to add [] to right side,
but first paren the whole thing first as in 4. (*(*mess)())[].

7. The array is full of pointers to functions. Add the pointer (*(*mess)())[] first on the
left. *(*(*mess)())[].

8. The pointers are to functions, so once again paren the thing before adding
the () to the right side, (*(*(*mess)())[])().

9. Finally, those functions are returning ints, so add that on the left.
int (*(*(*mess)())[])().

10. Add what ever parameters you want inside the function parens, i.e.
int (*(*(*mess)(long, char *))[])(FILE *).

11. Call it like this. abc = (*mess)(a,b);

Isn't C wonderful!

Here's a simple menu example.

typedef struct menuitem
{
int (*func)(); /* ptr to function returning int */
char thetext[80]; /* description of choice */
} MENUITEM;

static MENUITEM tstmenu[] =
{ /* open the array */
{ test1, "Test1" },
{ exitup, "Exit to Linux" },
{ 0, 0 } /* necessary termination */
}; /* close the array */

And here's the call to it.

menu( "Menu Test", tstmenu );

Sincerely,

David Smead
Please visit our web site -- amplepower.com.

On Mon, 2 Nov 1998, controltech wrote:

> # To subscribers of the xforms list from controltech <joel@bamboo.verinet.com> :
>
> I have a program that uses fl_add_timeout. The question I have is two fold.
> First, the function I am calling at timeout has some parameters that need
> to be passed to it, I'm not sure how to do this. Using ,
>
> fl_add_timeout(time, myfunc(param1, param2),NULL);
>
> doesn't work.
>
> The second question I have is how to do the same thing using an array of
> pointers to functions. I have something like
>
> int (*myfuncs[8])();
>
> ....
>
> myfuncs[1] = somefunction();
>
> How do I use fl_add_timeout with myfuncs[1], and again, I need to pass
> parameters.
>
> I understand pointers, but have not used pointers to funtions before.
>
> Thanks
> Joel
>
> _________________________________________________
> To unsubscribe, send the message "unsubscribe" to
> xforms-request@bob.usuf2.usuhs.mil or see
> http://bob.usuf2.usuhs.mil/mailserv/xforms.html
> XForms Home Page: http://bragg.phys.uwm.edu/xforms
> List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/
>

_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/