home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / pocketbk / developmen / oplexamp / OPLFIELD.TXT < prev    next >
Text File  |  1994-07-02  |  2KB  |  89 lines

  1. Subject: Re: Labels for OPL database files
  2. In-Reply-To: ye79@uk.co.gec-mrc's message of 28 Jun 94 11:18:33 GMT
  3. Message-ID: <RJC.94Jun29144821@daiches.cogsci.ed.ac.uk>
  4. Sender: usenet@cogsci.ed.ac.uk (C News Software)
  5. Nntp-Posting-Host: daiches
  6. Organization: Human Communication Research Centre, University of Edinburgh
  7. References: <4683@twix>
  8. Date: Wed, 29 Jun 1994 13:48:20 GMT
  9. Lines: 85
  10.  
  11.  
  12. I use the following two procedures to read and write the field
  13. names. d% is a number corresponding to the handle (1->A etc).
  14.  
  15. The names are stored in a global array fldnm$(). 
  16.  
  17. proc rdfldnm%:(d%)
  18.         local info%(4)
  19.         local d1%, d2%, d3%, d4%
  20.         local n%, i%, p%, e%
  21.         
  22.         odbinfo info%()
  23.         
  24.         d1%=$1700
  25.         d2%=peekw(info%(d%))
  26.         if os($d8, addr(d1%)) and 1
  27.                 return -1
  28.         endif
  29.         
  30.         p%=uadd(peekw(uadd(info%(d%),8)),2)
  31.         
  32.         while (peekw(p%) and $f000)<>$4000
  33.                 p%=uadd(p%,(peekw(p%) and $0fff)+2)
  34.         endwh
  35.         
  36.         e%=uadd(p%,(peekw(p%) and $0fff)+2)
  37.         p%=uadd(p%,2)
  38.         i%=1
  39.         while p%<e%
  40.                 fldnm$(i%)=peek$(p%)
  41.                 p%=uadd(p%,len(fldnm$(i%))+1)
  42.                 i%=i%+1
  43.         endwh
  44.         return i%-1
  45. endp
  46.  
  47. proc wtfldnm:(d%,n%)
  48.         local info%(4)
  49.         local d1%, d2%, d3%, d4%
  50.         local i%, p%, s%, l%, r%
  51.         
  52.         odbinfo info%()
  53.         
  54.         d1%=$1700
  55.         d2%=peekw(info%(d%))
  56.         if os($d8, addr(d1%)) and 1
  57.                 raise 1
  58.         endif
  59.         
  60.         p%=uadd(peekw(uadd(info%(d%),8)),2)
  61.         
  62.         while (peekw(p%) and $f000)<>$4000
  63.                 p%=uadd(p%,(peekw(p%) and $0fff)+2)
  64.         endwh
  65.         
  66.         s%=peekw(uadd(info%(d%),8))
  67.         r%=p%
  68.         p%=uadd(p%,2)
  69.         
  70.         i%=1 :l%=0
  71.         while i%<=n%
  72.                 poke$ p%, fldnm$(i%)
  73.                 p%=uadd(p%,len(fldnm$(i%))+1)
  74.                 l%=l%+len(fldnm$(i%))+1
  75.                 i%=i%+1
  76.         endwh
  77.         
  78.         pokew r%, $4000 or l%
  79.         
  80.         d1%=$1800
  81.         d2%=peekw(info%(d%))
  82.         d3%=p%-s%
  83.         
  84.         if os($d8, addr(d1%)) and 1
  85.                 raise d1% or $ff00
  86.         endif
  87.         
  88. endp
  89.