× 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.



hi Doug,

Any idea how to include that in the list without causing the compiler to
balk at me?

Whenever you want to insert a single-quote (apostrophe) into a string in RPG, just double-up the quotes. It doesn't matter whether this is part of an expression, named constant or literal -- it always works the same way.

For example, if I wanted to say Scott's Computer, I'd do this:

string = 'Scott''s Computer';

See? the quote in the string where I want the apostrophe is doubled-up. It's not any different in your case! Let's say you want to put it between the A and the B in your CONST string:

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

(I've deleted some of the extra spaces from the D-spec to hopefully keep it from wrapping in the e-mail client)

See... it's just '' in between the A and the B -- just like it was when I did Scott''s Computer.

Folks tend to get confused (and sometimes even frustrated) when it comes to these double-quotes if they end up at the start or end of the string where it's adjacent to the starting quotation mark or the ending quotation mark (or both). Personally, I don't find it confusing... I just imagine there being other characters... for example... the following is easy enough for me to understand:

'aaaaaa''hello''bbbbbb'

This results in the string aaaaaa'hello'bbbbbb -- pretty easy to understand, right? I just doubled up the quotes. If I want to just have 'hello' without the aaaaa and bbbbb, all I have to do is delete the aaaaaa and bbbbbb from the string.

'''hello'''

See... because there's 3 quotes at the start and end, people get confused. But if you imagine the aaaaa and bbbbb between the outer quote and the inner quote, it's easier (for me, anyway) to visualize.

So, again, in your case, if you wanted the ' to be at the start of the string you'd do this:

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

And I'd find it easier to visualize as CONST('aaa''!@#-c-&\' It's easy enough to see that the '' takes the place of a single quote. Then, just by deleting the aaa at the start, I end up with CONST('''!@# (etc)

Same thing at the end:

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

It's pretty easy once you think of it that way.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.