Re: XForms: Using app-defaults file to set default form values?

T.C. Zhao (zhao@bloch.phys.uwm.edu)
Sat, 20 Dec 1997 22:15:36 -0600

To subscribers of the xforms list from "T.C. Zhao" <zhao@bloch.phys.uwm.edu> :

On Dec 20, 2:19pm, Steve Lamont wrote:

> You would have to read the app_defaults file and process it.

I hate to contradict the mighty spl, but in this case, I think
there are easier ways to handle the resource file.

> static void set_startup_resources( void )
>
> {
>
> FILE *f = fopen( APP_DEFAULT_FILE, "r" );
>
> if ( f ) {

> The above is a pretty stoneaxe approach but it did work in some
> limited sense.
>
fl_initialize will read the resources from several places, including
the standard app resource, so application does not have to open/read
the file.

Say, the resource for the input is inputN.content, you can
do the following (content_holder is a char array that will hold the
content):

fl_initialize();
fl_get_resource("inputN.content","InputN.Content",
FL_STRING, default_val, content_holder, size);

or you can lump every resource into a structure

FL_resource res[] = {
{"inputN.content","InputN.Content",FL_STRING, content_holder, 0, size},
...
}

then
fl_initialize();
fl_get_app_resource(res, Nres);
/* create_all the forms */
fl_set_input(input_object, content_holder);

Of course, for this to work, the application default has to be
in the standard place with standard name.

_________________________________________________
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://bloch.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/