C Collection of code snippets by Arne Vajhøj 
C (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
      program p4
      implicit none
      integer*4 db
      parameter (db=21)
      structure /msgrectyp/
        integer*4 id
        character*100 msg
      end structure
      record /msgrectyp/msg
c  silly hack to avoid breaking lines over 80 characters
      open(unit=6,file='sys$output',status='new',recl=132) 
c  open database
      open(unit=db,file='msgs.isq',status='old',
     +     recordtype='fixed',form='unformatted',recl=26,
     +     organization='indexed',access='keyed',key=(1:4:integer))
c  write message to database
      msg.id=4
      msg.msg='Hi from Fortran!'
      write(unit=db) msg
c  dump all messages in database
      read(unit=db,keyge=0,keyid=0,err=200) msg
100   write(6,*) '|'//msg.msg//'|'
      read(unit=db,end=200) msg
      goto 100
200   continue
c  close database
      close(unit=db)
      end
