[comp.os.vms] Thoughts On FORTRAN Item Lists, Using STRUCTURE Statement, And DSIN...

CLAYTON@XRT.UPENN.EDU ("Clayton, Paul D.") (08/08/88)

The following question was recently asked regarding itemlists.

> I've seen at least 3 formats and (in some BLISS code) some nice ways 
> of declaring ($ITMLST_DECL) and initializing ($ITMLST_INIT). But I use 
> FORTRAN and/or C here.

There are a number of ways to do item lists in fortran or any langauge for that
matter. Personally I like MACRO-32 and RATFIV (upgraded RATFOR) and the macro
abilities of those languages for such things.

I also refer you to the Digital Software Information Network, otherwise known
as DSIN. The number for this service and an account number to use can be gotten
from your sales rep, provided you have software maintenance.

Once in to the DSIN database, you can ask for example code segments that perform
various system calls and what have you. The Fortran examples are well written
and work, at least the ones that I have used in the past. They are also well
commented and show many different ways of doing the item lists that you have 
asked about. 

But just to get you going again, I also offer the following which addresses 
your initial question on how to use item list in the form of a STRUCTURE 
statement in FORTRAN. 

Hope this helps.
pdc

Paul D. Clayton 
Address - CLAYTON%XRT@RELAY.UPENN.EDU

Disclaimer:  All thoughts and statements here are my own and NOT those of my 
employer, and are also not based on, or contain, restricted information.

*************************************************************************
 
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C                                                                       C
C      This program call SYS$SNDJBCW to put a file into a print queue.  C
C      It prompts you for the file name and the queue where the file    C
C      is to print.                                                     C
C                                                                       C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
       implicit none
       include '($SJCDEF)'	!this gets the job controller symbols
       integer * 4      sys$sndjbcw,
     *                  status,
     *                  func,
     *                  notify,
     *                  queue_len,
     *                  file_len,
     *                  notify_len
     * 		        iosb(2)
       character * 31   queue
       character * 255  file

CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C                                                                       C
C      Build the item list.                                             C
C                                                                       C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC

       structure/component/
          union
            map
	        integer * 2     buffer_length
	        integer * 2     item_code
	        integer * 4     buffer_address
	        integer * 4     return_length_address
            end map
            map
	        integer * 4     list_terminator/0/	!init'ed to end list
            end map
          end union
       end structure

CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C                                                                       C
C      Component_list has 4 elements:  it will be necessary to pass 3   C
C      item codes to SYS$SNDJBCW, and one element from the terminator.  C
C Note:									C
C	The terminator is automatically done for you do the definition  C
C	of the structure for the item list. Therefore only three	C
C	entries have to be initialized.					C
C                                                                       C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC

       record/component/component_list(4)	!three plus terminator

CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C                                                                       C
C      Prompt the terminal for the name of the queue to print the       C
C      file and the name of the file. Note how the length of the	C
C      are placed directly into the item list for later processing.	C
C                                                                       C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC

       type *,'Enter the queue name to place job into: '
       read (6,200) component_list(1).buffer_length, queue
200    format(q,a)

       type *,'Enter the file you want to print: '
       read (6,400) component_list(2).buffer_length, file
400    format(q,a)

CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C	Now that we have the data, lets setup the appropiate variables  C
C	in the item lists.						C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC

       component_list(1).item_code = sjc$_queue		!Tell what queue
       component_list(1).buffer_address =		!  to use
     *          %loc(queue(1:))
       component_list(1).return_length_address = %loc(queue_len)

       component_list(2).item_code = sjc$_file_specification	!Tell what
       component_list(2).buffer_address =		!file to print...
     *          %loc(file(1:))
       component_list(2).return_length_address = %loc(file_len)

       component_list(3).buffer_length = 4		!this one for user
       component_list(3).item_code = sjc$_notify	!notification when
       component_list(3).buffer_address = %loc(notify)	!its done printing
       component_list(3).return_length_address = %loc(notify_len)

CCCC       component_list(4).list_terminator = 0 !this would be needed if
CCCC						   the variable was not pre
CCCC						   init'ed in the structure
CCCC						   definition.

       func = sjc$_enter_file				!function id

       status = sys$sndjbcw(,%val(func),,component_list,iosb,,) !send it to
       if (.not. status) call lib$stop (%val(status))	!the job controller
       if (.not. iosb(1)) call lib$stop (%val(iosb(1)))	!and see if all okay
       end