ChipMaster's bwBASIC This also includes history going back to v2.10. *WARN* some binary files might have been corrupted by CRLF.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

109 lines
3.0 KiB

  1. rem Purpose: re-define externals to only 6 characters for CMS
  2. rem Author: Howard Wulf, AF5NE
  3. rem Date: 2015-02-10
  4. rem Usage: implementation defined
  5. rem Example:
  6. rem ~/bwbasic cms.bas
  7. rem
  8. rem -------------------------------------------------------------------------------
  9. rem File File Name IN/OUT Description
  10. rem #1 "bwbasic.h" INPUT read looking for "extern" statements
  11. rem #2 "cms.h" OUTPUT written with "#define" statements
  12. rem -------------------------------------------------------------------------------
  13. rem Variable Description
  14. rem N The number of "extern" statements so far processed
  15. rem E$ The constant value "extern "
  16. rem E The length of E$
  17. rem L$ The input line read from "bwbasic.h"
  18. rem M$ The next line from "bwbasic.h" when L$ does not contain a semicolon
  19. rem X The location of special characters in L$
  20. rem H$ The hexadecimal value of N
  21. rem -------------------------------------------------------------------------------
  22. rem
  23. let N = 0
  24. let E$ = "extern "
  25. let E = len( E$ )
  26. open "bwbasic.h" for input as #1
  27. open "cms.txt" for output as #2
  28. while not eof( #1 )
  29. line input #1, L$
  30. L$ = trim$( L$ )
  31. if left$( L$, E ) = E$ then
  32. rem extern ....
  33. while instr( L$, ";" ) = 0
  34. ' read more lines until we get a semicolon
  35. line input #1, M$
  36. M$ = trim$( M$ )
  37. L$ = L$ + " " + M$
  38. wend
  39. rem extern ...;
  40. L$ = trim$(mid$( L$, E + 1 ))
  41. ' truncate trailing semicolon
  42. X = instr( L$, ";" )
  43. if X > 0 then
  44. L$ = trim$(left$( L$, X - 1 ))
  45. end if
  46. ' truncate trailing parenthesis
  47. X = instr( L$, "(" )
  48. if X > 0 then
  49. L$ = trim$(left$( L$, X - 1 ))
  50. end if
  51. ' truncate trailing bracket
  52. X = instr( L$, "[" )
  53. if X > 0 then
  54. L$ = trim$(left$( L$, X - 1 ))
  55. end if
  56. ' find the last word
  57. X = instr(L$, " " )
  58. while X > 0
  59. L$ = trim$(mid$( L$, X + 1 ))
  60. X = instr(L$, " " )
  61. wend
  62. ' skip leading asterick
  63. while left$( L$, 1 ) = "*"
  64. L$ = trim$(mid$( L$, 2 ))
  65. wend
  66. if L$ = "main" or L$ = "putenv" or L$="sleep" then
  67. ' ignore magic function name
  68. else
  69. ' pad for alignment
  70. REM L$ = L$ + space$(32)
  71. REM L$ = left$( L$, 32 )
  72. REM H$ = "00000" + hex$(N)
  73. REM H$ = right$( H$, 5 )
  74. REM print #2, "#define ";L$;" X";H$
  75. REM N = N + 1
  76. if len( L$ ) > 0 then
  77. print #2, L$
  78. end if
  79. end if
  80. end if
  81. wend
  82. close #2
  83. close #1
  84. REM sort before assigning value
  85. if shell( "sort < cms.txt > cms.out" ) = 0 then
  86. N = 0
  87. open "cms.out" for input as #1
  88. open "cms.h" for output as #2
  89. while not eof(#1)
  90. line input #1, L$
  91. L$ = trim$(L$)
  92. if len(L$) then
  93. ' pad for alignment
  94. L$ = L$ + space$(32)
  95. L$ = left$( L$, 32 )
  96. H$ = "00000" + hex$(N)
  97. H$ = right$( H$, 5 )
  98. print #2, "#define ";L$;" X";H$
  99. N = N + 1
  100. end if
  101. wend
  102. close #2
  103. close #1
  104. rem Cleanup temporary files
  105. kill "cms.txt"
  106. kill "cms.out"
  107. end if
  108. end