home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / psion / opp16f_zip / INCLUDE / lib / UTIL_LIB.OPP < prev   
Encoding:
Text File  |  1996-09-09  |  947 b   |  59 lines

  1. /*
  2.  * OPP general library procedures
  3.  */
  4. /* Convert C to OPL style string */
  5. LIBPROC ctoo$:(addr%)
  6.     local i%,s$(255),c%,p1%,p2%
  7.     p1%=addr%
  8.     p2%=uadd(addr(s$),1)
  9.     while i%<255
  10.         c%=peekb(p1%)
  11.         if c%=0
  12.             break
  13.         endif
  14.         pokeb p2%,c%
  15.         p1%=uadd(p1%,1)
  16.         p2%=uadd(p2%,1)
  17.         i%++
  18.     endwh
  19.     pokeb addr(s$),i%
  20.     return s$
  21. ENDP
  22.  
  23. /* Get length of C string */
  24. LIBPROC clen%:(addr%)
  25.     return call($B9,0,0,0,0,addr%)
  26. ENDP
  27.  
  28. /* Trim spaces off start & end of OPL string */
  29. LIBPROC trim$:(s$)
  30.     local s%,e%
  31.     s%=1
  32.     while (s%<=len(s$)) and (mid$(s$,s%,1)=" ")
  33.         s%=s%+1
  34.     endwh
  35.     if s%>len(s$)
  36.         return ""
  37.     endif
  38.     e%=len(s$)
  39.     while (e%>0) and (mid$(s$,e%,1)=" ")
  40.         e%=e%-1
  41.     endwh
  42.     return mid$(s$,s%,1+e%-s%)
  43. ENDP
  44.  
  45. /* Round long int */
  46. LIBPROC round&:(a&,b&)
  47.     local v&
  48.     v&=a&/b&*b&
  49.     if a&-v&>=b&/2
  50.         v&=v&+b&
  51.     endif
  52.     return v&
  53. ENDP
  54.  
  55. /* copy block of memory */
  56. LIBPROC copy:(a%,b%,l%)
  57.     call($a1,0,l%,0,a%,b%)
  58. ENDP
  59.