rem CAP-CB80.BAS Ver. 1.1 23 Jan 84\ \ Maps all CB80 reserved words to upper case. This program will process source\ code files for V1.3 and V1.4 of CB80 and can be compiled with either version.\ \ Note: 25 Jan 84. If compiled with V 1.3, the time from the last apparent\ record print to disk may be excessive. This is due to a documented problem\ with the GET function in V 1.3.\ \ By: Phil Cary, Mesilla Valley RCP/M, Las Cruces, NM (505) 522-8856 \ based on an idea by David Ransen, Baton Rouge, LA\ \ Known limitations:\ 1. All remarks must begin with REM or rem followed by a space(not TAB)\ Remarks may be continued with the continuation character(\),\ however, remarks following a \ on a line of code will be processed\ and any keywords converted to uppercase unless rem is used. Do not\ use REMARK or remark to start a remark.\ \ 2. A maximum of three quoted strings within a line will be processed\ correctly. Keywords within additional quoted strings on the line\ will be converted to upper case. This should be adequate for\ normal applications. If this program is run on itself, an example\ of this can be found in the data area at the end of the program.\ \ Note that when this program is run on itself, there will be some undesired\ results due to the way keywords are used within the program.\ \ Please report any bugs or enhancments to Mesilla Valley RCP/M, (505) 522-8856 rem following notice required in composite program by Digital Research, Inc. license.notice$="Portions of this program (c)1982 Digital Research Inc" rem Define constants false% = 0 true% = not false% view% = false% examine% = false% record.number% = 1 cr% = 0dh lf% = 0ah quote.mark% = 22h alpha.min% = 41h ctrlc% = 03h dim keyword$(122) rem 123 CB80 reserved words for i% = 0 to 122 read keyword$(i%) next i% file.in: input "Input Filename (.BAS assumed): " ; infile$ input.file$ = ucase$(infile$) + ".BAS" if not size(input.file$)\ then print "File does not exist. Check spelling." : goto file.in\ else open input.file$ as 1 buff 64 if end # 1\ then all.done file.out: print input "Output Filename (.BAS assumed):" ; outfile$ output.file$ = ucase$(outfile$) + ".BAS" if output.file$ = input.file$\ then print "Output filename same as input. Choose another name." :\ goto file.out if not size(output.file$)\ then create output.file$ as 2 buff 64 : goto startup\ else print : print output.file$; :\ input " exists. Do you want to overwrite it?"; line answer$ if ucase$(left$(answer$,1)) = "Y"\ then create output.file$ as 2 buff 64\ else goto file.out startup: print : print "Do you want to View or Examine the processing?"; input " o, iew, xamine:"; line answer$ if ucase$(left$(answer$,1)) = "V"\ then view% = true% : goto restart if ucase$(left$(answer$,1)) = "E"\ then view% = true% : examine% = true% : print :\ print "Enter ^C to abort, any other key for next record." :\ print : goto restart print "Processing file." restart: def NEW.RECORD$(record$,position%,keyword$) word$ = mid$(record$,position%,len(keyword$)) caps.word$ = ucase$(word$) NEW.RECORD$ = left$(record$,(position% -1)) + caps.word$ + \ right$(record$,(len(record$) - position% - len(word$) + 1)) fend process.record: if(not view% and not examine%)\ then print "Record number: "; record.number%; chr$(cr%); :\ record.number% = record.number% + 1 quote.one% = 0 quote.two% = 0 quote.three% = 0 quote.four% = 0 quote.five% = 0 quote.six% = 0 end.record% = false% record$ = "" record.position% = 0 gosub get.record rem Mark location of quoted strings if quote.position% <> 0\ then quote.one% = quote.position% : gosub get.record\ else goto got.record if quote.position% <> 0\ then quote.two% = quote.position% : gosub get.record\ else goto got.record if quote.position% <> 0\ then quote.three% = quote.position% : gosub get.record\ else goto got.record if quote.position% <> 0\ then quote.four% = quote.position% : gosub get.record\ else goto got.record if quote.position% <> 0\ then quote.five% = quote.position% : gosub get.record\ else goto got.record if quote.position% <> 0\ then quote.six% = quote.position% : gosub get.record got.record: rem Ignore quotes over 6 and find end of record if not end.record%\ then gosub get.record if quote.position% <> 0\ then goto got.record rem Check for remark beginning line. Note: The following code\ segment will not be processed correctly if this program is run on\ itself because of the "REM ". if ucase$(left$(record$,4)) = "REM "\ then position% = 1 : dummy.word$ = "xxx " :\ record$ = NEW.RECORD$(record$,position%,dummy.word$) :\ gosub skip.remarks : goto process.record rem Check for remark at end of line( rem or REM ) remark.position% = match("rem ",record$,1) if remark.position% <> 0\ then gosub split.record : goto continue remark.position% = match("REM ",record$,1) if remark.position% <> 0\ then gosub split.record continue: for i% = 0 to 122 start% = 1 scan: position% = match(keyword$(i%),record$,start%) if position% = 0\ then goto no.match rem Skip quoted strings (up to 3 per line) if (position% > quote.one% and position% < quote.two%)\ then start% = position% + quote.two% : goto scan if (position% > quote.three% and position% < quote.four%)\ then start% = position% + quote.four% : goto scan if (position% > quote.five% and position% < quote.six%)\ then start% = position% + quote.six% : goto scan rem Keyword trailing part of label, move forward in record if position% > 1\ then if mid$(record$,position% - 1,1) = "."\ then start% = start% + position% : goto scan rem Keyword at end of record if position% = len(record$)-len(keyword$(i%))+1\ then gosub check.left : goto no.match rem Keyword first word on line if position% = 1\ then gosub check.right : goto scan rem Keyword with non-alpha character to the left if asc(mid$(record$,position% - 1,1)) < alpha.min%\ then gosub check.right rem Imbedded keyword, so move forward in record start% = start% + position% goto scan no.match: next i% gosub put.record goto process.record split.record: code.segment$ = left$(record$,remark.position% + 3) remark.segment$ = right$(record$,len(record$)-len(code.segment$)) record$ = code.segment$ return skip.remarks: if right$(record$,1) = "\"\ then gosub put.record : read #1; line record$ :\ if view%\ then print "in ->";record$ : goto skip.remarks\ else goto skip.remarks\ else gosub put.record return check.left: rem First and only keyword on line if position% = 1\ then record$ = NEW.RECORD$(record$,position%,keyword$(i%)) : return rem Check for non-alpha character preceeding last keyword found in line if asc(mid$(record$,position% - 1,1)) < alpha.min%\ then record$ = NEW.RECORD$(record$,position%,keyword$(i%)) : return rem Imbedded keyword at end of record return check.right: rem Continuation character after keyword OK if mid$(record$,position% + len(keyword$(i%)),1) = "\"\ then record$ = NEW.RECORD$(record$,position%,keyword$(i%)) : return rem Keyword imbedded in label so move forward in record if mid$(record$,position% + len(keyword$(i%)),1) = "."\ then start% = start% + position% : return rem Check for keyword with (, %, or $ at end if asc(mid$(record$,position% + len(keyword$(i%)) - 1,1)) < alpha.min%\ then record$ = NEW.RECORD$(record$,position%,keyword$(i%)) : return rem Check for non-alpha character following keyword if asc(mid$(record$,position% + len(keyword$(i%)),1)) < alpha.min%\ then record$ = NEW.RECORD$(record$,position%,keyword$(i%)) : return rem Must be imbedded keyword, so move forward in record start% = start% + position% return get.record: quote.position% = 0 character% = 0 rem Do until end of record marked by line feed while character% <> lf% record.position% = record.position% + 1 character% = get(1) record$ = record$ + chr$(character%) rem If quotation mark, then mark it and return if character% = quote.mark%\ then quote.position% = record.position% : return wend rem Strip cr,lf from record if len(record$) > 0\ then record$ = left$(record$, len(record$) - 2) if view%\ then print "in ->";record$ rem Flag the end of the record end.record% = true% return put.record: rem Rebuild record and null remark.segement$ record$ = record$ + remark.segment$ if remark.segment$ <> ""\ then remark.segment$ = "" : gosub skip.remarks : return if view%\ then print "out->";record$ if examine%\ then if inkey = ctrlc%\ then stop print using "&"; # 2; record$ return all.done: print: print "File processed." stop data "unlock(", "unlocked", "wend", "while", "xor", "fend", "abs(",\ "and", "as", "asc(", "atn(", "attach(", "buff", "call",\ "chain", "chr$", "close", "command$", "common", "conchar%", "console",\ "constat%", "cos(", "create", "data", "def", "delete", "detach",\ "dim", "else", "end", "error", "errl", "err", "eq",\ "exp(", "external", "float(", "for", "fre(", "get(", "ge",\ "goto", "gosub", "go", "gt", "if", "initialize", "inkey",\ "input", "inp(", "lprinter", "print", "int%", "integer", "len(",\ "left$", "let", "le", "line", "locked", "lock(", "log(",\ "lt", "match(", "mfre", "mid$", "mod(", "ne", "next",\ "not", "on", "open", "or", "out(", "peek(", "poke",\ "pos", "int%(", "int(", "public", "put", "randomize", "readonly",\ "read", "real", "recl", "recs", "remark", "rem", "rename(",\ "restore", "return", "right$", "rnd(", "sadd(", "sgn(", "shift(",\ "sin(", "size(", "sqr(", "step", "stop", "str$", "string$",\ "string", "sub", "tab(", "tan(", "then", "to", "ucase$",\ "using", "val(", "varptr(", "width", "%chain", %debug, "%eject",\ "%include", "%list", "%nolist", "%page" end