× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



FWIW.. I just wanted to say that I completely agree with Barbara. There's no reason to hard-code the hex value for an EBCDIC quote. It's both confusing to someone who hasn't memorized the EBCDIC table, and it makes it nearly impossible to port the code to a non-EBCDIC platform.

It's ten times worse if you hard-code a hex value for a variant character. (Which, fortunately, the quote is not.)

If you absolutely must hard-code a hex value, then please hard code the Unicode hex value, as that is likely to translate to any foreseeable situation. For example:

D QU C u'0027'

But, IMHO, a much better idea is to avoid hard-coding a hex value unless absolutely necessary -- and in this case, it's not necessary, just put the quote as a text character in your constant, as Barbara suggested.

D QU C const('''')

I'm sorry, but RPG and CL have treated quotes this way forever. Folks maintaining programs should understand this, and if they don't, they should get a book and learn about it. When it's coded once as a constant (as above) it's not so confusing.


Barbara Morris wrote:
Armbruster, Tom wrote:
You don't need, nor should you use, double quotes in an SQL statement.
Here's how I declare the quote character:

d @Q c const(x'7D')


The constant '''' isn't a double quote. It's a single quote character.

I think '''' is a better way of coding a single quote character than x'7D'. '''' might seem strange to non-RPG programmers, but RPG programmers (and CL programmers) should know that a quote within a string has to be doubled up, to let the compiler know that it's not the end of the string.

string = 'Mary''s little lamb'; // "Mary's little lamb"

I don't like x'7D' because a) it's too fancy and b) it isn't correct in an non-EBCDIC environment. What RPG programmer cares about a non-EBCDIC environment? Other than VA RPG programmers, maybe nobody. But if we learned anything during y2k, we learned that code sometimes lasts orders of magnitude longer than its original coders expect. Maybe none of your code will ever been needed for a VA RPG application, and maybe any VA RPG programmer who reads your recommendation will know that x'7D' isn't correct, and maybe your code will never need to be ported to a non-EBCDIC environment. But maybe it will; you might as well avoid using techniques that are known to be non-portable, especially when a completely portable mechanism exists.

That's my x'7D' rant for 2008. Honest, until at least 2009, I'll sit on my hands when I see a recommendation for x'7D'. Cross and stamp and no erasies.

Apologies to Tom, for picking your post for my rant.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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

This mailing list archive is Copyright 1997-2024 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].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.