home *** CD-ROM | disk | FTP | other *** search
/ TAP YIPL / TAP_and_YIPL_Collection_CD.iso / PHREAK / CELLULAR / ESNNECP2.BAS < prev    next >
Encoding:
BASIC Source File  |  1995-02-24  |  2.4 KB  |  89 lines

  1. REM ** Anyone reading this code can see its a real inefficient hack.
  2. REM ** But Basic is a language for getting the job done quick and dirty.
  3. REM ** So I am lax on my code. So shoot me.
  4. PRINT "[  Hex to Decimal ESN converter ]"
  5. PRINT " with formatting for the NEC P200 Cellular phone."
  6. PRINT
  7. PRINT "-----------=?> Doctor Who <?=-----------"
  8. PRINT "               $ L O D $"
  9. PRINT
  10. PRINT
  11. PRINT "This program is a utility for conversion of various numbers and is "
  12. PRINT "not to be used for any illegal purpose. The author takes no responsibility"
  13. PRINT "for the results of its use."
  14. PRINT
  15. PRINT "This program may be freely copied, and even modified, as long as the"
  16. PRINT "original author is given credit."
  17. PRINT
  18. PRINT "The P3.EXE program requires the ESN entered in a particular format."
  19. PRINT "This program converts hexadecimal ESNs to the decimal representation,"
  20. PRINT "and formats them for p3.exe"
  21. PRINT
  22. PRINT
  23. 10 INPUT "enter hex ESN: ", esn$
  24. IF esn$ = "" THEN END
  25. IF LEN(esn$) < 8 THEN
  26.  PRINT "an ESN is 8 hexadecimal digits"
  27.  GOTO 10
  28. END IF
  29.  
  30. PRINT
  31. FOR I = 0 TO 7
  32.  dig$ = MID$(esn$, I + 1, 1)
  33.  IF ASC(dig$) > 64 AND ASC(dig$) < 71 THEN decval = ASC(dig$) - 55
  34.  IF ASC(dig$) > 96 AND ASC(dig$) < 103 THEN decval = ASC(dig$) - 87
  35.  IF ASC(dig$) > 47 AND ASC(dig$) < 58 THEN decval = ASC(dig$) - 48
  36.  IF decval = 0 AND dig$ <> "0" THEN
  37.   PRINT "illegal digit entered."
  38.   GOTO 10
  39.  END IF
  40.  IF I < 2 THEN
  41.   MMC = MMC + (decval * (16 ^ (1 - I)))
  42.  ELSE
  43.   mmb = (decval * (16 ^ (7 - I)))
  44.  END IF
  45.  TOTDEC = TOTDEC + mmb
  46.  
  47.  NEXT I
  48. PRINT "decimal esn: ";
  49. mmf$ = RIGHT$(STR$(MMC), LEN(STR$(MMC)) - 1)
  50. WHILE LEN(mmf$) < 3
  51.  mmf$ = "0" + mmf$
  52. WEND
  53. mme$ = RIGHT$(STR$(TOTDEC), LEN(STR$(TOTDEC)) - 1)
  54. WHILE LEN(mme$) < 8
  55.  mme$ = "0" + mme$
  56. WEND
  57.  
  58. PRINT mmf$; mme$
  59. PRINT
  60. f1 = 256 * (VAL(mmf$))
  61. f2 = VAL(mme$)
  62. f3 = INT(f2 / 65536)
  63. f4 = f1 + f3
  64. f5$ = RIGHT$(STR$(f4), LEN(STR$(f4)) - 1)
  65. WHILE LEN(f5$) < 5
  66.  f5$ = "0" + f5$
  67. WEND
  68. f6 = f2 MOD 65536
  69. f7 = INT(f6 / 4096)
  70. f8$ = RIGHT$(STR$(f7), LEN(STR$(f7)) - 1)
  71. IF LEN(f8$) < 2 THEN f8$ = "0" + f8$
  72. f9 = f6 MOD 4096
  73. f10 = INT(f9 / 64)
  74. f11$ = RIGHT$(STR$(f10), LEN(STR$(f10)) - 1)
  75. IF LEN(f11$) < 2 THEN f11$ = "0" + f11$
  76. f12 = f9 MOD 64
  77. f13$ = RIGHT$(STR$(f12), LEN(STR$(f12)) - 1)
  78. IF LEN(f13$) < 2 THEN f13$ = "0" + f13$
  79. PRINT
  80. PRINT "Formatted for P3.EXE: ";
  81. PRINT f13$; "/"; f11$; "/";
  82. PRINT f8$; "/";
  83. PRINT f5$
  84. PRINT
  85. INPUT "ctrl-c to quit or return to run again"; ans$
  86. RUN
  87.  
  88.  
  89.