#include "randomfiles2.h"

address structpointer,ROpen   {Pay attention that ROpen is only a
                               variable and not as in the last
                               version of this include file a
                               subprogram for opening random files!}

deflng a-z

struct rfilestrucDef
 string famname
 string street
 string town
end struct

declare struct rfilestrucDef *filestruc
input "Enter filename : ",f$
ROpen=_OpenRandom(f$,1,Sizeof(rfilestrucdef))
filestruc=ROpen
if ROpen then
 repeat
  input "entry : ",entry
  if entry then
   input "Reading (1) or writing (2) : ",action
   if action=1 then
    _GetRandom (ROpen,entry)
    print
    print filestruc->famname
    print filestruc->street
    print filestruc->town
    print
   else
    print
    input "family name  : ",nam$
    input "street + nr  : ",st$
    input "town + postal: ",t$
    filestruc->famname=nam$
    filestruc->street=st$
    filestruc->town=t$
    print "Saving ..."
    _PutRandom(ROpen,entry)
    print
   end if
  end if
 until entry=0
else
 print "open file failed"
end if
library close
close 1
clear alloc
stop
