home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1984 January to June / Ahoy_Magazine_84-Jan-Jun_1984_Double_L.d64 / hex2dec (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  382b  |  16 lines

  1. 5 rem--ahoy--feb issue--hex2dec--prog page 68
  2. 10 rem>> hex2dec - hexadecimal converter
  3. 20 print chr$(147) :rem clear screen
  4. 30 v=0
  5. 40 print"enter a hex value",
  6. 50 get a$:if a$="" then 50
  7. 60 if a$=chr$(13) then 130 :rem return
  8. 70 if a$>="0" and a$<="9" then d=val(a$):goto 100
  9. 80 if a$>"a" and a$<="f" then d=asc(a$)-55:goto 100
  10. 90 goto 50 :rem ignore bad character
  11. 100 v=16*v + d
  12. 110 print a$;
  13. 120 goto 50
  14. 130 print " = ";v : print
  15. 140 goto 30
  16.