Guys, Both versions worked but I chose the $ga_between script by Smoke_N. Below is what I have so far (bit messy) but it works for the test I have conducted so far. I used it to modified the session file for a webcam application and it worked without any apparent errors. i.e. I was able to pull up the webcam application with the new session file, and see the changed receipient email in various places, and all other functions appeared to be unaffected. Thanks again to all.
-------------------------------------------------------------------------------------------------------------
;Below finds the HEX string to replace, and defines the replacement string variables.
$filename = "TEST.txt"
Global $gs_data = FileRead($filename)
if @error = 1 then
MsgBox(0,"File not opened or other error")
Else
msgbox(0,"AFTER",$gs_data)
EndIf
;Hex for (EmailAddress=) and (,"EmailSubject=)
Global $ga_between = _StringBetween($gs_data, "456d61696c416464726573733d", "2c22456d61696c5375626a6563743d")
if $ga_between = 0 then
MsgBox(0, "_StringBetween", "Failure")
EndIf
if $ga_between = 1 then
MsgBox(0,"_StringBetween", "No between found")
else
MsgBox(0, "StringBetween Is", $ga_between)
EndIf
;Hex for the replacement string (dog@catz.com) -Example email address for demo
Global $gs_findstr, $gs_replacestr, $gs_myreplacementstr
$gs_myreplacementstr = "646f6773406361747a2e636f6d"
MsgBox(0,"Replacement String", $gs_myreplacementstr)
For $i = 0 To UBound($ga_between) - 1
MsgBox(0,"$ga_between size",UBound($ga_between))
$gs_findstr = "456d61696c416464726573733d" & $ga_between[$i] & "2c22456d61696c5375626a6563743d"
MsgBox(0,"gs_findstr", $gs_findstr)
$gs_replacestr = "456d61696c416464726573733d" & $gs_myreplacementstr & "2c22456d61696c5375626a6563743d"
MsgBox(0,"$gs_replacestr",$gs_replacestr)
$find = $gs_findstr
$replace = $gs_replacestr
$NewFile = _ReplaceStringInFile($filename,$find,$replace, 0, 0)
if $NewFile = -1 then
msgbox(0, "ERROR", "The pattern could not be replaced in file: " & $filename & " Error: " & @error)
exit
else
msgbox(0, "INFO", "Found " & $NewFile & " occurances of the pattern: " & $find & " in the file: " & $filename)
endif
Next
FileClose($filename)