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



McGovern, Sean wrote:
Joe,

Could you share your quote function code ?

Thanks.
Sean, a lot depends on the context. In general the hardest part is not the quote code, but instead the way you make the procedure generic. RPG requires a little magic to pass fields of differing sizes.

If you're already using varying length fields, it's relatively simple. IBM's support for *VARSIZE and VARYING makes it very easy. I'll include a sort of skeleton example here, showing the use of a couple of bit flags. Things get a little more involved with fixed-length fields; *VARSIZE requires a little more work.

Joe



h dftactgrp(*no) actgrp(*new)

d Quote pr 128 varying
d input 64 varying options(*varsize)
d flags 5u 0 const options(*Nopass)

d Quote_DoubleQuote...
d C 1
d Quote_Trim...
d C 2

d start s 30 varying
d msg s 50
/free
start = 'My Baby ';
msg = Quote(start);
dsply msg;
start = 'My Baby ';
msg = Quote(start : Quote_Trim);
dsply msg;
start = 'She''s my baby';
msg = Quote(start);
dsply msg;
start = 'She''s my baby';
msg = Quote(start : Quote_Trim + Quote_DoubleQuote);
dsply msg;
*inlr = *on;
/end-free

p Quote b
d pi 128 varying
d input 64 varying options(*varsize)
d flags 5u 0 const options(*Nopass)
d SingleQuote c ''''
d DoubleQuote c ''''''
d Work s 128 varying
d x s 3u 0
d char s 1
d Work2 s 128 varying
/free
Work = input;

if %bitand(flags : Quote_DoubleQuote) = Quote_DoubleQuote;
Work2 = '';
for x = 1 to %len(Work);
char = %subst(Work:x:1);
Work2 += char;
if char = SingleQuote;
Work2 += char;
endif;
endfor;
Work = Work2;
endif;

if %bitand(flags : Quote_Trim) = Quote_Trim;
Work = %trim(Work);
endif;

return SingleQuote + Work + SingleQuote;
/end-free
p e

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.