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 >
Wrap
Commodore BASIC
|
2022-10-26
|
382b
|
16 lines
5 rem--ahoy--feb issue--hex2dec--prog page 68
10 rem>> hex2dec - hexadecimal converter
20 print chr$(147) :rem clear screen
30 v=0
40 print"enter a hex value",
50 get a$:if a$="" then 50
60 if a$=chr$(13) then 130 :rem return
70 if a$>="0" and a$<="9" then d=val(a$):goto 100
80 if a$>"a" and a$<="f" then d=asc(a$)-55:goto 100
90 goto 50 :rem ignore bad character
100 v=16*v + d
110 print a$;
120 goto 50
130 print " = ";v : print
140 goto 30