DEFLNG a-z DECLARE FUNCTION SuckIn$ (theFile$) ' Quickly pull in file DECLARE FUNCTION FindTopChar$(instring$) 'find most common non alpha-numeric character in a string FUNCTION PBMAIN() 'aatext - tool for inserting text messages into ascii art files aafile$ = PARSE$(COMMAND$, " ", 1) textfile$ = PARSE$(COMMAND$, " ", 2) replacechar$ = PARSE$(COMMAND$, " ", 3) IF LEFT$(replacechar$, 1) = "-" AND LEN(replacechar$) <> 1 THEN options$ = replacechar$ replacechar$ = "" ELSE options$ = PARSE$(COMMAND$, " ", 4) END IF STDOUT "AATEXT - A tool for inserting text messages into ASCII art files." STDOUT "by Shannon Larratt - glider@bmezine.com" STDOUT IF aafile$ = "" OR textfile$ = "" THEN STDOUT "Usage:" STDOUT " aatext aafile.txt txtfile.txt [abc] [-[sun]]" STDOUT " aafile.txt - Name of text file containing ascii art." STDOUT "txtfile.txt - Name of text file containing spaces. STDOUT " abc - Char(s) to replace with text. Default is to use the" STDOUT " most common non-space character in the file." STDOUT " -s - Include spaces and punctuation in replace (default" STDOUT " strips them)." STDOUT " -u - Convert text to uppercase." STDOUT " -n - Remove numbers." STDOUT "" EXIT FUNCTION END IF aadata$ = suckin$(aafile$) IF aadata$ = "" THEN STDOUT "ERROR: '" & aafile$ & "' file not found." STDOUT EXIT FUNCTION END IF textdata$ = suckin$(textfile$) IF textdata$ = "" THEN STDOUT "ERROR: '" & textfile$ & "' file not found." STDOUT EXIT FUNCTION END IF IF replacechar$ = "" THEN replacechar$ = FindTopChar$(aadata$) END IF STDOUT "Replacing: '" & replacechar$ & "'" removeit$ = "" FOR r = 0 TO 30 removeit$ = removeit$ & CHR$(r) NEXT FOR r = 128 TO 255 removeit$ = removeit$ & CHR$(r) NEXT IF INSTR(options$, "s") > 0 THEN STDOUT "Stripping punctuation and spaces." removeit$ = removeit$ & " `~!@#$%^&*()_+|-=\[]{};':"",./<>?" END IF IF INSTR(options$, "n") > 0 THEN STDOUT "Stripping numbers." removeit$ = removeit$ & "1234567890" END IF textdata$ = REMOVE$(textdata$, ANY removeit$) IF INSTR(options$, "u") > 0 THEN STDOUT "Converting to UPPERCASE." textdata$ = UCASE$(textdata$) END IF STDOUT outputdata$ = "" intext = 1 FOR r = 1 TO LEN(aadata$) thischar$ = MID$(aadata$, r, 1) IF INSTR(replacechar$, thischar$) > 0 THEN outputdata$ = outputdata$ & MID$(textdata$, intext, 1) INCR intext IF intext > LEN(textdata$) THEN intext = 1 ELSE outputdata$ = outputdata$ & thischar$ END IF NEXT STDOUT "Results:" STDOUT STDOUT outputdata$ STDOUT END FUNCTION FUNCTION SuckIn$ (theFile$) ' Quickly pull in file x$ = DIR$(theFile$) IF x$ = "" THEN SuckIn$ = "" EXIT FUNCTION END IF ff = FREEFILE OPEN theFile$ FOR BINARY LOCK SHARED AS #ff GET$ #ff, LOF(ff), Buffer$ CLOSE #ff SuckIn$ = Buffer$ EXIT FUNCTION END FUNCTION FUNCTION FindTopChar$(instring$) 'find most common non alpha-numeric character in a string DIM chars(0 TO 255) DIM charptr(0 TO 255) FOR r = 0 TO 255 chars(r) = 0 charptr(r) = r NEXT FOR r = 1 TO LEN(instring$) INCR chars(ASC(MID$(instring$, r, 1))) NEXT ARRAY SORT chars(), TAGARRAY charptr(), DESCEND FOR r = 0 TO 255 IF charptr(r) <> 32 THEN EXIT FOR NEXT FindTopChar$ = CHR$(charptr(r)) END FUNCTION