home *** CD-ROM | disk | FTP | other *** search
- REM ** Anyone reading this code can see its a real inefficient hack.
- REM ** But Basic is a language for getting the job done quick and dirty.
- REM ** So I am lax on my code. So shoot me.
- PRINT "[ Hex to Decimal ESN converter ]"
- PRINT " with formatting for the NEC P200 Cellular phone."
- PRINT
- PRINT "-----------=?> Doctor Who <?=-----------"
- PRINT " $ L O D $"
- PRINT
- PRINT
- PRINT "This program is a utility for conversion of various numbers and is "
- PRINT "not to be used for any illegal purpose. The author takes no responsibility"
- PRINT "for the results of its use."
- PRINT
- PRINT "This program may be freely copied, and even modified, as long as the"
- PRINT "original author is given credit."
- PRINT
- PRINT "The P3.EXE program requires the ESN entered in a particular format."
- PRINT "This program converts hexadecimal ESNs to the decimal representation,"
- PRINT "and formats them for p3.exe"
- PRINT
- PRINT
- 10 INPUT "enter hex ESN: ", esn$
- IF esn$ = "" THEN END
- IF LEN(esn$) < 8 THEN
- PRINT "an ESN is 8 hexadecimal digits"
- GOTO 10
- END IF
-
- PRINT
- FOR I = 0 TO 7
- dig$ = MID$(esn$, I + 1, 1)
- IF ASC(dig$) > 64 AND ASC(dig$) < 71 THEN decval = ASC(dig$) - 55
- IF ASC(dig$) > 96 AND ASC(dig$) < 103 THEN decval = ASC(dig$) - 87
- IF ASC(dig$) > 47 AND ASC(dig$) < 58 THEN decval = ASC(dig$) - 48
- IF decval = 0 AND dig$ <> "0" THEN
- PRINT "illegal digit entered."
- GOTO 10
- END IF
- IF I < 2 THEN
- MMC = MMC + (decval * (16 ^ (1 - I)))
- ELSE
- mmb = (decval * (16 ^ (7 - I)))
- END IF
- TOTDEC = TOTDEC + mmb
-
- NEXT I
- PRINT "decimal esn: ";
- mmf$ = RIGHT$(STR$(MMC), LEN(STR$(MMC)) - 1)
- WHILE LEN(mmf$) < 3
- mmf$ = "0" + mmf$
- WEND
- mme$ = RIGHT$(STR$(TOTDEC), LEN(STR$(TOTDEC)) - 1)
- WHILE LEN(mme$) < 8
- mme$ = "0" + mme$
- WEND
-
- PRINT mmf$; mme$
- PRINT
- f1 = 256 * (VAL(mmf$))
- f2 = VAL(mme$)
- f3 = INT(f2 / 65536)
- f4 = f1 + f3
- f5$ = RIGHT$(STR$(f4), LEN(STR$(f4)) - 1)
- WHILE LEN(f5$) < 5
- f5$ = "0" + f5$
- WEND
- f6 = f2 MOD 65536
- f7 = INT(f6 / 4096)
- f8$ = RIGHT$(STR$(f7), LEN(STR$(f7)) - 1)
- IF LEN(f8$) < 2 THEN f8$ = "0" + f8$
- f9 = f6 MOD 4096
- f10 = INT(f9 / 64)
- f11$ = RIGHT$(STR$(f10), LEN(STR$(f10)) - 1)
- IF LEN(f11$) < 2 THEN f11$ = "0" + f11$
- f12 = f9 MOD 64
- f13$ = RIGHT$(STR$(f12), LEN(STR$(f12)) - 1)
- IF LEN(f13$) < 2 THEN f13$ = "0" + f13$
- PRINT
- PRINT "Formatted for P3.EXE: ";
- PRINT f13$; "/"; f11$; "/";
- PRINT f8$; "/";
- PRINT f5$
- PRINT
- INPUT "ctrl-c to quit or return to run again"; ans$
- RUN
-
-
-