Framework EDI Reference. Methods and Properties
ediFile. ReplaceCharNotInStrToFile

Replace a character of a file content with a string, and save the modified result to a different file.

Syntax:

Parameters:

Returns:

Returns 1 if the operation is successful; otherwise the operation returns zero.

Remarks:

Example 1.  Replace any single occurrence of the character "A" and "B" with "XYZ", but do not replace any of occurrence of the substring "ABC".  Assume the content of the body is "WHAT ABOUT ABCOULOMB?".  The method call would be:

object.ReplaceCharNotInStrToFile("AB", "ABC", "XYZ", "C:\TEMP\TEST.TXT")

The resulting file TEST.TXT will have the content (bold is for emphasis only):

WHXYZT XYZXYZOUT ABCOULOMXYZ?

 

Example 2.  Replace any single occurrence of the character "A" and "B" with "XYZ".  Assume the content of the file is "WHAT ABOUT ABCOULOMB?".  The method call would be:

object.ReplaceCharNotInStrToFile("AB", "", "XYZ", "C:\TEMP\TEST.TXT"))

The resulting file TEST.TXT will have the content (bold is for emphasis only):

WHXYZT XYZXYZOUT XYZXYZXYZOULOMXYZ?

This method is useful for canonicalizing the message body.  One of the process to canonicalize text is to replace any single occurrences of carriage-return (CR) or line-feed (LF) characters with the carriage-return line-feed (CRLF) pair to indicate the end of line.  The single CR and LF do not include those already in the CRLF sequence.

object.ReplaceCharNotInStrToFile(vbCrLf, vbCrLf, vbCrLf, "C:\TEMP\TEST.TXT"))

The example Visual Basic statement above is explained as follows.  (The VB constant vbCrLf is the CRLF sequence.)