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.