home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / sri314_b.zip / DEMOPRGS.ZIP / BIT.PRG < prev    next >
Text File  |  1990-10-03  |  1KB  |  34 lines

  1. *** BIT.PRG ***
  2. **  A demonstration program provided by  SUB ROSA PUBLISHING INC.
  3. **  (C) Copyright 1990, Sub Rosa Publishing Inc.
  4. **  This program may be copied freely. If it is used in commercial code,
  5. **  please credit the source, Sub Rosa Publishing Inc.
  6. **
  7. **  BIT demonstrates the use of bit( ) function to generate the binary
  8. **  code for characters.
  9. **  BIT is compatible with all current versions of SR-Info and VP-Info.
  10. **
  11. **
  12. **  Sid Bursten and Bernie Melman
  13. *
  14. SET RAW ON   ; eliminates spaces between listed output
  15. DO WHILE t   ; perpetual loop terminated by BREAK command
  16.    ACCEPT 'Enter a short string for binary representation: ' TO string
  17.    IF string=' '
  18.       BREAK
  19.    ENDIF
  20.    ?
  21.    REPEAT (LEN(string)*8) TIMES VARYING position ; 8 bits * number of chars
  22.       BIT_VAL =  IFF(BIT(string,position),1,0) ; note use of IFF( ) function
  23.       ?? str(bit_val,1,0) ; .. and STR( ) to format output
  24.       IF MOD(position,8)=0 ; .. and MOD( ) to space between characters
  25.          IF col()>60
  26.             ?
  27.          ELSE
  28.             ?? ' '
  29.          ENDIF
  30.       ENDIF
  31.    ENDREPEAT
  32. ENDDO
  33. *** end of BIN.PRG ***
  34.