Thanks Scott.....I get it.......and I appreciate your taking the time for
the explanation.

From: Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx>
To: RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>
Date: 08/27/2008 01:07 PM
Subject: Re: Xlate help


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

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{?><.`~||(),*$+-

(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:


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.


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{?><.`~||(),*$+-

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{?><.`~||(),*$+-

It's pretty easy once you think of it that way.
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives

This transmission may contain information that is privileged, confidential
and/or exempt from disclosure under applicable law. If you are not the
intended recipient, you are hereby notified that any disclosure, copying,
distribution, or use of the information contained herein (including any
reliance thereon) is STRICTLY PROHIBITED. If you received this
transmission in error, please immediately contact the sender and destroy
the material in its entirety, whether in electronic or hard copy format.
Thank you.

This thread ...


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

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