RosettaCodeData/Task/Globally-replace-text-in-several-files/PowerBASIC/globally-replace-text-in-several-files.powerbasic
Ingy döt Net d066446780 langs a-z
2013-04-10 22:43:41 -07:00

23 lines
650 B
Text

$matchtext = "Goodbye London!"
$repltext = "Hello New York!"
FUNCTION PBMAIN () AS LONG
DIM L0 AS INTEGER, filespec AS STRING, linein AS STRING
L0 = 1
WHILE LEN(COMMAND$(L0))
filespec = DIR$(COMMAND$(L0))
WHILE LEN(filespec)
OPEN filespec FOR BINARY AS 1
linein = SPACE$(LOF(1))
GET #1, 1, linein
' No need to jump through FB's hoops here...
REPLACE $matchtext WITH $repltext IN linein
PUT #1, 1, linein
SETEOF #1
CLOSE
filespec = DIR$
WEND
INCR L0
WEND
END FUNCTION