Re: XForms: printf to a browser or canvas

From: spl@ncmir.ucsd.edu
Date: Fri Oct 11 2002 - 12:52:04 EDT

  • Next message: Gayle C Roth: "Re: XForms: printf to a browser or canvas"

    # To subscribers of the xforms list from spl@ncmir.ucsd.edu :

    > How could I display the output of e.g. printf("Hello world!"); into an
    > object. Should this object be a browser or a canvas?

    That entirely depends upon what you want to do with the output.

    If you want to send a transient message to the user, you may want to
    look at

            fl_show_message()

    or

            fl_show_oneliner()

    There's also the Command log "Goodie" but that's probably overkill.

    See the "Goodies" section of the manual for more details.

    If you want to display this in a form, you have several options. I
    usually use a Text object. You can write to a Text object by doing
    something to the effect of

            char buffer[BUFSIZE];

            snprintf( buffer, sizeof( buffer ), "%s", your_message );
            fl_set_object_label( your_text_object, buffer );

    Of course, the arguments to snprintf() can be much more elaborate than
    what I've shown. In fact, I use this method so often that I've
    written a little convenience function in a private library which does
    this:

        void readout( FL_OBJECT *obj, char *fmt, ... )
        
        {
        
            va_list list;
            char buffer[1024];
        
            va_start( list, fmt );
            
            vsnprintf( buffer, sizeof( buffer ), fmt, list );
        
            va_end( list );
        
            fl_set_object_label( obj, buffer );
        
        }

    You could use a Browser object, as well, and just add text lines.
    If you want the user to be able to edit your text, then an Input
    object might meet your needs.

    Again, it all depends on what you're trying to accomplish.

    A Canvas object is probably the least appropriate, since it's really a
    graphical drawing area, not really suitable for text output without a
    lot of extraneous work.

                                                            spl
    _________________________________________________
    To unsubscribe, send the message "unsubscribe" to
    xforms-request@bob.usuhs.mil or see
    http://bob.usuhs.mil/mailserv/xforms.html
    XForms Home Page: http://world.std.com/~xforms
    List Archive: http://bob.usuhs.mil/mailserv/list-archives/



    This archive was generated by hypermail 2b29 : Fri Oct 11 2002 - 12:53:46 EDT