Globally replace text in several files: Difference between revisions

Globally replace text in several files en FreeBASIC
m (→‎{{header|Phix}}: added syntax colouring, marked p2js incompatible)
(Globally replace text in several files en FreeBASIC)
Line 591:
 
END</lang>
 
=={{header|FreeBASIC}}==
{{trans|BASIC}}
<lang freebasic>Const matchtext = "Goodbye London!"
Const repltext = "Hello New York!"
Const matchlen = Len(matchtext)
 
Dim As Integer x, L0 = 1
dim as string filespec, linein
 
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
Do
x = Instr(linein, matchtext)
If x Then
linein = Left(linein, x - 1) & repltext & Mid(linein, x + matchlen)
Else
Exit Do
End If
Loop
Close
Open filespec For Output As 1
Print #1, linein;
Close
filespec = Dir
Wend
L0 += 1
Wend</lang>
 
=={{header|Go}}==
2,122

edits