home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / baslib1.zip / CONVERT.BAS < prev    next >
BASIC Source File  |  1987-03-27  |  2KB  |  57 lines

  1. 'DEC,HEX,BIN,ASCII Number conversions
  2. 'By Jeff Bretz, John Craig
  3. 'Additional rwts & conversion to Quickbasic 2.01 By Dennis Dreyer
  4. 'CONVERT.BAS
  5.  
  6. cls
  7. locate 9,30:Print    "                    "
  8. locate 10,30,0:Print "  Conversion Demo   "
  9. locate 11,30:Print " In Quickbasic 2.01 "
  10. locate 12,30:Print    "                    "
  11. color 4,4,1:locate 13,30:Print "                    "
  12. locate 8,30:Print "                    "
  13. locate 19,25:color 4,0:Print " Be SURE your printer is on!"
  14. locate 21,22:color 5,0:print "Enter `Q' to quit - if printer not ready."
  15. locate 22,24:print "Otherwise enter `S' to start printing."
  16.  
  17. locate 24,24:INPUT A$
  18. IF A$ = "S" or A$ ="s" then goto start else end
  19.  
  20.  
  21. START:
  22.  
  23. lprint "Decimal, Hexadecimal, Binary, and ASCII Number Conversions"
  24. lprint string$(79,61)
  25. lprint "Decimal   Hexadecimal                              ";
  26. lprint "Binary         ASCII"
  27. lprint string$(34,32);" 7  6  5  4 - 3  2  1  0"
  28. lprint string$(79,61)
  29.  
  30. for y=0 to 255
  31. lprint using "#######";Y;
  32. lprint "            ";
  33.  
  34.     if len(hex$(y))<2 then lprint "0";
  35.     lprint hex$(y);
  36.     lprint "             ";
  37.  
  38.     X=Y
  39.         lprint abs(X>127);:X=X MOD 128
  40.         lprint abs(X>63);:X=X MOD 64
  41.         lprint abs(X>31);:X=X MOD 32
  42.         lprint abs(X>15);:X=X MOD 16
  43.         lprint "-";
  44.         lprint abs(X>7);:X=X MOD 8
  45.         lprint abs(X>3);:X=X MOD 4
  46.         lprint abs(X>1);:X=X MOD 2
  47.         lprint abs(X>0);
  48.     lprint   "            ";
  49.  
  50. if (y>32) and (Y<128) then lprint chr$(Y);
  51.  
  52. lprint " "
  53. z=y+1:If z mod 10=0 then lprint " "
  54. next
  55. lprint chr$(12)
  56. end
  57.