Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-05 - 43,50337/21/specif.sim
There is 1 other file named specif.sim in the archive. Click here to see a list.
BEGIN
  EXTERNAL REF (Infile) PROCEDURE findinfile;
  EXTERNAL REF (Directfile) PROCEDURE finddirectfile;
  EXTERNAL REF (Outfile) PROCEDURE findoutfile;
  EXTERNAL TEXT PROCEDURE front,scanto,getitem;
  EXTERNAL INTEGER PROCEDURE maxint,search,splita,hash,arrlgd;
  EXTERNAL PROCEDURE split,arrtxt;
  EXTERNAL BOOLEAN PROCEDURE puttext;
  EXTERNAL TEXT PROCEDURE conc,upcase,frontstrip,rest,checkextension;
  EXTERNAL CHARACTER PROCEDURE fetchar,findtrigger;
  EXTERNAL LONG REAL PROCEDURE scanreal;
  EXTERNAL INTEGER PROCEDURE checkreal,checkint,scanint,ilog;
  EXTERNAL BOOLEAN PROCEDURE menu;
  EXTERNAL CLASS safeio,simdbm;
  simdbm("","","",0,TRUE) BEGIN
    INTEGER k,n; TEXT t; TEXT ARRAY ta[1:4];
    REF (record) r1; REF (rspec) rs;

    REF (rspec) PROCEDURE makerecordspec(rname,fnames,ftypes,rkey,
    rsize,nfields);
    VALUE rname,fnames,ftypes,rkey; TEXT rname,fnames,ftypes,rkey;
    INTEGER rsize,nfields;
!  ------------------------------------------------------
!  creates a new record type specification dynamically
!  and allocates corresponding space within data base file.
!  parameters:
!	RNAME	name of record type
!	FNAMES	field names separated with commas
!	FTYPES	types of fields, coded
!	RKEY	name of key field
!	RSIZE	size of area to be allocated
1	NFIELDS	number of fields within the record
!  ------------------------------------------------------------;
    BEGIN
      INTEGER k,n,keypos; INTEGER ARRAY ia[1:nfields+1];
      TEXT ARRAY ta[1:nfields+1],rta[1:8];
      REF (rspec) rs;

      PROCEDURE splitt(t); TEXT t;
      BEGIN
	k:=splita(t,komma,ta,nfields); IF k < nfields THEN
	BEGIN outline("ILLEGAL ARG TO MAKERECORDSPEC!"); GOTO fin; END;
      END SPLITT;

      splitt(ftypes);
      FOR k:=1 STEP 1 UNTIL nfields DO ia(k):=scanint(ta(k));
      splitt(fnames);
      keypos:=loctext(rkey,ta);
      rta(1):-rname; rta(2):-rkey; rta(3):-intput(oflowtop);
      rta(4):-intput(rsize); rta(5):-intput(keypos);
      rta(6):-intput(nfields);
      rta(7):-fnames; rta(8):-ftypes;
      rs:-NEW rspec(spec__spec,rta,rname,rkey,oflowtop,
      rsize,keypos,nfields,ta,ia);
      oflowtop:=oflowtop+rsize;
      rs.store;
      rs.prototype:-NEW record(rs,ta);
      makerecordspec:-rs;
      fin:
    END MAKERECORDSPEC;

    !  ------------  START OF MAIN  ----------------;
!  example of the use of makerecordspec and of the
!  records specified through it;

    request("Data base file: ","",textinput(t,TRUE),"",nohelp);
    request("Image size: ","68",intinput(n,TRUE),"",nohelp);
    openbase(t,n);

    !  ------   create new record type RNEW  --------;

    rs:-makerecordspec("RNEW","X,Y,Z","3,1,3","X",20,3);

    !  ------  store ten records of type RNEW  --------;

    IF rs =/= NONE THEN
    BEGIN
      FOR k:=1 STEP 1 UNTIL 10 DO
      BEGIN
	ta(1):-intput(100+k); ta(2):-intput(100-k); ta(3):-intput(k);
	r1:-NEW record(rs,ta); r1.store;
      END;
    END;
    eof:
  END;
END;