(view source code of far.kix as plain text)
; FAR -- Find And Replace, Version 1.00
; Search a string for a substring and replace it with another substring
; Written by Rob van der Woude
; http://www.robvanderwoude.com
If $s = "" OR $r = "" OR $string = ""
? "FAR -- Find And Replace, Version 1.00"
? "Search a string for a substring and replace it with another substring"
?
? "Usage: KIX32 FAR.KIX $$S=" + Chr(34) + "string1" + Chr(34) + " $$R=" + Chr(34) + "string2" + Chr(34) + " $$STRING=" + Chr(34) + "string0" + Chr(34)
? "Where: string0 = the string to be searched"
? " string1 = the substring to search for"
? " string2 = the substring that should replace string1"
? "All strings must be enclosed in double quotes."
?
? "Written by Rob van der Woude"
? "http://www.robvanderwoude.com"
?
? "Press any key . . . "
Get $dummy
Quit 1
EndIf
$oldstr = $string
$los = Len( $oldstr )
$ls = Len( $s )
Do
$pos = InStr( $string, $s )
If $pos > 0
$newstr = $newstr + SubStr( $string, 1, $pos - 1 ) + $r
$string = SubStr( $string, $pos + $ls, $los )
Else
$newstr = $newstr + $string
$string = ""
EndIf
Until $string = ""
; Create temporary batch file to return new string value
If RedirectOutput( "%TEMP%.\_FAR_.BAT", 1 ) = 0
"SET NEWSTRING=$newstr"
Else
? "Error writing to file %TEMP%.\_FAR_.BAT"
Quit 2
EndIf
; Stop redirection
If RedirectOutput( "", 0 ) <> 0
Shell "%COMSPEC% /K @ECHO Error stopping redirection"
Quit 3
EndIf
Quit 0
page last modified: 2024-04-16; loaded in 0.0106 seconds