Manage Learn to apply best practices and optimize your operations.

Replace Double Quotes

The following script solves the problem of having double quotes within a field
that needs to be written out to a text file that will then be imported or used
by another application such as Crystal Reports or Excel. When writing
information to a text file using the Write# command, fields are automatically
separated by commas and enclosed with double quotes. If there are double
quotes within one these fields, the record is usually not imported properly.
This script replaces the double quotes with two single quotes, thus allowing
the records to be imported.
Function ReplaceDoubleQuotes(x As String) As String
Dim pos As Long
Dim doublequote As String
Dim twosinglequotes As String
pos = 1

doublequote = """"
twosinglequotes = "''"

Do Until pos = 0

L = Len(x) ' Get the length of the whole string
pos& = Instr(1, x, doublequote) ' find the doublequotes
If pos <> 0 Then
P1 = Left(x,pos - 1) ' Part 1 of the text string
P2 = Right(x,L- pos ) ' Part 2 of the text string (determined
by subtracting the current pos from the total length of the string
X = P1 & twosinglequotes & P2 ' combine part 1 with 2 single
quotes and then add part 2
End If
replacedoublequotes = X
End Function

Dig Deeper on Domino Resources - Part 5



  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...