On 28/08/2008, at 2:20 AM, Doug Palme wrote:

Since the ' is the delimiter for a character field....is there anyway for
me to test for it?

All these responses with 'might' and 'try' and other guesses. The standard solution in RPG, COBOL, and CL to this problem of embedding the enclosing character is simply to double it. That is if you want a constant containing a single apostrophe you need to specify FOUR of them. One is the start of the constant, one is the end of the constant, one is the value itself and one is doubled so the compiler does not interpret the previous one as an end marker. Thus:


Simple. In your case you want an apostrophe within a larger string so the same principle applies: double it. Thus.

D @INV c CONST('!@#-c-&\}|NOT{?><.`~||(),*$+-%

Note the two apostrophes between the quote character and the capital A character.

The same principle applies to any delimiter such as a quote character or the C-language escape character \.

This behaviour is explained in the RPG Reference manual under Literals (on page 121 for VRM510) if anyone except me actually bothered reading it.

An apostrophe required as part of a literal is represented by two apostrophes.
For example, the literal O’CLOCK is coded as ‘O’’CLOCK’.

Note that using a hexadecimal representation is cheating somewhat and while it will work for invariant characters it will fail when you try the same technique on variant characters and your code runs in a different CCSID from the one in which you derived the hex value.

Simon Coulter.
FlyByNight Software OS/400, i5/OS Technical Specialists

Phone: +61 2 6657 8251 Mobile: +61 0411 091 400 /"\
Fax: +61 2 6657 8251 \ /
ASCII Ribbon campaign against HTML E-Mail / \

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2020 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].