home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a012 / 1.ddi / CHAP18.EXE / CHP1828.PRG < prev    next >
Encoding:
Text File  |  1991-04-30  |  1017 b   |  36 lines

  1. /*
  2.    Listing 18.28  SQZ()
  3.    Author: Joe Booth
  4.    Excerpted from "Clipper 5: A Developer's Guide"
  5.    Copyright (c) 1991 M&T Books
  6.                       501 Galveston Drive
  7.                       Redwood City, CA 94063-4728
  8.                       (415) 366-3600
  9. */
  10.  
  11.  
  12. function sqz_n(_number,_size,_dec)
  13. LOCAL tmpstr,retstring:="",k
  14. _dec     := if(_dec=NIL,0,_dec )
  15. _number  := _number * (10**_dec)
  16. _size    := if(_size/2<>int(_size/2),_size+1,_size)
  17. tmpstr   := str( _number,_size)
  18. tmpstr   := strtran(tmpstr," ","0")
  19. for k = 1 to len(tmpstr) step 2
  20.    retstring=retstring+chr(val(substr(tmpstr,k,2))+100)
  21. next
  22. return retstring
  23.  
  24.  
  25. function unsqz_n(_compressed,_size,_dec)
  26. LOCAL _tmp:="",k,multi,answer
  27. _size     := if(_size/2<>INT(_size/2),_size+1,_size)
  28. for k=1 to len(_compressed)
  29.    _tmp=_tmp+str(asc(substr(_compressed,k,1))-100,2)
  30. next
  31. _tmp   := strtran(_tmp," ","0")
  32. answer := substr(_tmp,1,_size-_dec)+"."+substr(_tmp,_size-_dec+1)
  33. return val(answer)
  34.  
  35. // end of file CHP1828.PRG
  36.