X-Git-Url: https://git.distorted.org.uk/~mdw/ssr/blobdiff_plain/a3da4c116d4216fdec125d687dfc347e343a8b28..c1b567d833a004bb3d978f1f7c99f42cefa7845c:/StraySrc/Utilities/b/msgaof.bas diff --git a/StraySrc/Utilities/b/msgaof.bas b/StraySrc/Utilities/b/msgaof.bas new file mode 100644 index 0000000..42777aa --- /dev/null +++ b/StraySrc/Utilities/b/msgaof.bas @@ -0,0 +1,206 @@ +REM +REM msgAOF +REM +REM Convert message files to an AOF format +REM +REM © 1995-1998 Straylight +REM + +REM ----- Licensing note ---------------------------------------------------- +REM +REM This file is part of Straylight's core utilities (coreutils) +REM +REM Coreutils is free software; you can redistribute it and/or modify +REM it under the terms of the GNU General Public License as published by +REM the Free Software Foundation; either version 2, or (at your option) +REM any later version +REM +REM Coreutils is distributed in the hope that it will be useful, +REM but WITHOUT ANY WARRANTY; without even the implied warranty of +REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +REM GNU General Public License for more details. +REM +REM You should have received a copy of the GNU General Public License +REM along with Coreutils. If not, write to the Free Software Foundation, +REM 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +ON ERROR ERROR EXT 0,REPORT$+" ["+STR$(ERL)+"]" + +DIM q% 256 +SYS "OS_GetEnv" TO comm$ +IF INSTR(comm$,"-quit")=0 THEN ERROR 1,"msgAOF must be started using *Run" +comm$=MID$(comm$,INSTR(comm$,"""")+1) +comm$=MID$(comm$,INSTR(comm$," ")+1) +comm$=LEFT$(comm$,INSTR(comm$,"""")-1) + +table%=FALSE +file$=FNword(comm$) +out$=FNword(comm$) +header$=FNword(comm$) +IF file$="" OR out$="" THEN ERROR 0,"Syntax: msgAOF [
]" +IF header$<>"" THEN + hdr%=OPENOUT(header$) + BPUT #hdr%,";" + BPUT #hdr%,"; Message symbols [generated by msgAOF]" + BPUT #hdr%,";" + BPUT #hdr%,"" + BPUT #hdr%,CHR$(9)+CHR$(9)+"["+CHR$(9)+":LNOT::DEF:msg__dfn" + BPUT #hdr%,CHR$(9)+CHR$(9)+"GBLL"+CHR$(9)+"msg__dfn" + BPUT #hdr%,"" +ELSE + hdr%=0 +ENDIF + +LIBRARY "libs:bas" +PROCbas_init + +in%=OPENIN(file$) +ON ERROR CLOSE #in%:IF hdr% THEN CLOSE #hdr%:IF0ELSE:ERROR EXT 0,REPORT$+" ["+STR$(ERL)+"]" + +PROCbas_aofInit(64*1024) +FOR o=4 TO 6 STEP 2 + [ opt o + FNpass + + FNarea("Resources$$Data","CODE,READONLY") + ] + + PTR #in%=0 + REPEAT + line$=FNstrip(GET$#in%) + + CASE LEFT$(line$,1) OF + WHEN ";","#",":","" + REM Ignore comment lines + OTHERWISE + col%=INSTR(line$,":") + IF col%=0 THEN + CLOSE #in%:IF hdr% THEN CLOSE #hdr%:IF0ELSE:ERROR 0,"Bad message line" + ENDIF + tag$=FNstrip(LEFT$(line$,col%-1)) + msg$=FNstrip(MID$(line$,col%+1)) + CASE LEFT$(msg$,1) OF + WHEN "{" + [ opt o + .help + .syntax ;Just make sure of this + ] + REPEAT + msg$=FNstrip(GET$#in%) + CASE msg$ OF + WHEN "|" + [ opt o + .syntax + ] + WHEN "}" + REM Do nothing + OTHERWISE + IF RIGHT$(msg$,1)="\" THEN + [ opt o + dcb FNgsTrans(LEFT$(msg$,LEN(msg$)-1)) + ] + ELSE + [ opt o + dcb FNgsTrans(msg$) + dcb 13 + ] + ENDIF + ENDCASE + UNTIL msg$="}" + [ opt o + dcb 0 + FNdoExport("help","help_"+tag$) + FNdoExport("syntax","synt_"+tag$) + ] + WHEN "[" + msg$=MID$(msg$,2) + col%=INSTR(msg$,"]") + err%=EVAL(LEFT$(msg$,col%-1)) + msg$=FNstrip(MID$(msg$,col%+1)) + msg$=FNgsTrans(msg$) + [ opt o + FNalign + .label + dcd err% + dcb msg$ + dcb 0 + FNdoExport("label","msg_"+tag$) + ] + OTHERWISE + msg$=FNgsTrans(msg$) + [ opt o + .label + dcb msg$ + dcb 0 + FNdoExport("label","msg_"+tag$) + ] + ENDCASE + ENDCASE + + UNTIL EOF #in% +NEXT + +CLOSE #in% +IF hdr% THEN + BPUT #hdr%,"" + BPUT #hdr%,CHR$(9)+CHR$(9)+"]" + BPUT #hdr%,"" + BPUT #hdr%,CHR$(9)+CHR$(9)+"END" + CLOSE #hdr% + SYS "OS_File",1,header$,&FFFFFF3A,&BD896000,,3 +ENDIF +ON ERROR ERROR EXT 0,REPORT$+" ["+STR$(ERL)+"]" +PROCbas_aofSaveAs(out$) +END + +DEF FNdoExport(alias$,name$) +IF FNexportAs(alias$,name$) +IF hdr%<>0 AND o=6 THEN BPUT #hdr%,CHR$(9)+CHR$(9)+"IMPORT"+CHR$(9)+name$ +=0 + +DEF FNword(RETURN line$) +LOCAL word$ +IF INSTR(line$," ") THEN + word$=LEFT$(line$,INSTR(line$," ")-1) + line$=MID$(line$,INSTR(line$," ")+1) +ELSE + word$=line$ + line$="" +ENDIF +=word$ + +DEF FNstrip(line$) +LOCAL x$,f%,s% +WHILE line$<>"" + IF LEFT$(line$,1)=" " THEN + s%+=1 + ELSE + IF (f% AND 1) THEN + x$+=STRING$(s%," ")+LEFT$(line$,1) + ELSE + x$+=LEFT$(line$,1) + ENDIF + s%=0 + f%=f% OR 1 + ENDIF + line$=MID$(line$,2) +ENDWHILE +=x$ + +DEF FNupper(line$) +LOCAL i% +$q%=line$ +FOR i%=0 TO LEN(line$)-1 + IF q%?i%>=97 AND q%?i%<=122 THEN q%?i%-=32 +NEXT +=$q% + +DEF FNgsTrans(s$) +LOCAL p%,t$ +SYS "OS_GSTrans",s$,q%,256 TO ,,len% +p%=q% +WHILE p%