Previous: Structures
Up: Data set types
Previous Page: Structures
Next Page: Tutorial

Structure definitions in DSPACK

In fortran:

* define POINT - REAL, 3 items (X,Y,Z), extra comments 
* for interactive work ('|' separates items if they contain spaces)
* section 0 means that this object is only a template to be used 
* in other definitions rather than to store data
* Using a non-zero section is allowed - POINT would then become
* a data set definition as well and one could store data in it.
* Section number is ignored when POINT is used in other
* definitions.

call dsdef('POINT','R',0,3, > 'X|Y|Z|X coordinate|Y coordinate|Z coordinate',iv,ierr)

* Now define FRAME - a structure - an array of 4 points (1 item)

call dsdef('FRAME','S',0,1,'C(4) POINT',iv,ierr)

* BFLAGS - to keep extra flags - 3 items - 1 integer,1 logical * and one 16 character string - here none of the words * contains spaces, so a space may be used for a separator * (The comments 'Box_colour On_off Box_name' are optional but * recommended) * Note the second argument describing the data set type

call dsdef('BFLAGS','1I 1L 4H',0,3, > 'COLOUR ONOFF NAME '// > 'Box_colour On_off Box_name',iv,ierr)

* Now we are ready to define our box - a structure with 3 items * the first is an array of 2 frames F followed by a point POSITION * and a structure FLAGS defined by BFLAGS above * We can put it into section 2 - sections of elements are ignored

call dsdef('BOX','S',2,3,'F(2) POSITION FLAGS '// > 'FRAME POINT BFLAGS',iv,ierr)

* Now that we have our BOX we may use it as a template to define * another one - in section 1 - this defines BOX3 to look like * BOX.

call dslike('BOX3','BOX',1,iv,ierr)

and the same example in c:

int iv,ierr;

/* define POINT - REAL, section 1, 3 items (X,Y,Z), extra comments for interactive work ('|' separates items if they contain spaces) section 0 means that this object is only a template to be used in other definitions rather than to store data Using a non-zero section is allowed - POINT would then become a data set definition as well and one could store data in it. Section number is ignored when POINT is used in other definitions. */

dsdef("POINT","R",0,3, "X|Y|Z|X coordinate|Y coordinate|Z coordinate",&iv,&ierr);

/* Now define FRAME - a structure - an array of 4 points (1 item) */

dsdef("FRAME","S",0,1,"C(4) POINT",&iv,&ierr);

/* BFLAGS - to keep extra flags - 3 items - 1 integer,1 logical and one 16 character string - here none of the words contains spaces, so a space may be used for a separator (The comments 'Box_colour On_off Box_name' are optional but recommended) Note the second argument describing the data set type */

dsdef("BFLAGS","1I 1L 4H",0,3, "COLOUR ONOFF NAME Box_colour On_off Box_name",&iv,&ierr);

/* Now we are ready to define our box - a structure with 3 items the first is an array of 2 frames F followed by a point POSITION and a structure FLAGS defined by BFLAGS above We can put it into section 2 - sections of elements are ignored */

dsdef("BOX","S",2,3, "F(2) POSITION FLAGS FRAME POINT BFLAGS",&iv,&ierr);

/* Now that we have our BOX we may use it as a template to define another one - in section 1 - this defines BOX3 to look like BOX. */

dslike("BOX3","BOX",1,&iv,&ierr);

BOX and BOX3 are now defined and we may store data - as many entries as needed in each. They may also be mapped directly into fortran or c structures defined above.

An equivalent definition of BOX could be made without BFLAGS structure by using DSPACK pre-defined types (.INT4, .LOG4, and .CHAR16 in this case):

call dsdef('BOX','S',2,5,\ 
     >             'F(2) POSITION COLOUR ONOFF NAME'//\ 
     >             'FRAME POINT .INT4 .LOG4 .CHAR16',iv,ierr)

which corresponds to a fortran structure like this:

structure /BOX/ \ 
                record/FRAME/  F(2)  \           
                record/POINT/  POSITION \        
                Integer*4        COLOUR \          
                Logical*4        ONOFF   \         
                Character*16     NAME  \           
       end structure

In the same way POINT could be replaced by .REAL4 with POSITION replaced by POSITION(3). However it should be stressed that changes as these have no practical effect on performance - so the format should be dictated by the convenience of use. (For instance the last dsdef would result in the name of the box to be BOX.NAME rather than BOX.FLAGS.NAME but replacing POINT by .REAL4 would result in BOX.POSITION.Y to become BOX.POSITION(2) which is, if anything, less convenient)

Pre-defined types are just templates defined by DSPACK and may be treated like any other definitions. There are very few of them in the moment. However - if a programmer wants his box name to have, say 24 characters then a 24 character template can be easily defined:

call dsdef('.CHAR24','C*24',0,1,'C Character*24',iv,ierr)

.CHAR24 may then be used in any subsequent structure definition.



Previous: Structures
Up: Data set types
Previous Page: Structures
Next Page: Tutorial

wwwd@na49
Fri Nov 4 23:36:02 MET 1994