Re: XForms: array of objects

Steve Lamont (
Mon, 21 Jul 97 05:56:28 PDT

To subscribers of the xforms list from (Steve Lamont) :

> Of course,I need to manipulate these 160 counters using an array of
> counters, but fdesign doesn't allow me to define an array of n same
> objects.

Wow! That's rather a lot.

Actually, fdesign does allow this. Simply declare your object in
standard C array notation (foo[0], foo[1], ...) in the Name field of
the Attributes dialog. It only supports singly dimensioned arrays.
In fact, if you specify a multiply dimensioned array, only the first
subscript is recognized and output.

However, for 160 counters, this will probably be somewhat tedious.

I suppose you might be able to write a script in awk, perl, or your
favorite scripting language to automagically generate the fdesign .fd
file and then process it with fdesign to create the supporting form
creation code. However, I don't know that this will be any easier
than what you are doing.

Creating a large number of objects is pretty easy -- you can use the
cut and paste features of fdesign to replicate large chunks of the
form trivially, but there's no facility for automagically numbering
each member of the array.

Here again, an awk or perl script might be the answer -- create the
form using fdesign with a bunch of identically named objects, run it
through a script which creates a new name field with a subscript as
you desire, and then run fdesign using the newly created .fd file.

I did something like this on a considerably smaller scale when I was
called upon to design a little piece of test code to twiddle all of
the lenses and deflectors on our electron microscope.

> So my solution was to write my own program with arrays of counters "by
> hand" without fdesign, but it's not very convenient and any modification
> in this panel must be done by program.

Since the array is likely to be regular in some manner, this may be
the best solution. It's probably easier to modify your program than
to modify the form by hand.

You don't have to create the entire form using your program -- you can
just use it to create the objects of interest and let fdesign do the
other objects -- just leave space for your objects in the form. Use
fl_addto_form() to reopen the form after creation, stuff your objects
in, then close it with fl_end_form().

If you feel you must have an array declared in the FD_* structure, you
can be tricky and just declare the last object in your array with
fdesign -- in this case, object 159, given that C arrays are zero
based, of course. Then use your program to fill in the missing

Hope this helps.

To unsubscribe, send the message "unsubscribe" to or see
Xforms Home Page:
List Archive: