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



Read Hans post.

Here is a little more explanation so you understand what Hans means.

Basically, a varying string has to know how long the string is, right?  Well, 
it stores that information in two "hidden" bytes, ones we never really see.  
That are the two first bytes of the string.  Normally, we don't care.  We as 
for the value of the string, and RPG looks at the two hidden bytes, figures the 
length, and returns the string starting at the 3rd byte for that length.

So, say MyVarying contains 'Hi'.
What the MyVarying variable actually contains is something similar to:
1st Byte: 0
2nd Byte: 2
3rd Byte: 'H'
4th Byte: 'i'

the length may be encoded some other way, it really doesn't matter for this 
explanation.

Now, the problem is when you pass a varying string to a function that expects a 
fixed length string.

     c                   eval      htmlOut = x'15' +
     C                             '<UL>'
     c                   eval      outLn = %len(%trim(htmlOut))
     c                   callb     'QtmhWrStout'
     c                   parm                    htmlOut
     c                   parm                    outln
     c                   parm                    qusec

htmlOut is being passed something like x'0' x'5' + '<UL>'
with the initial bytes of 0 and 5 being the length of the string, that's the 
garbage you're seeing.

So, you actually want to pass the string x'15' + '<UL>' that starts in byte 3 
of the varying variable.  So Hans has two "tricks" to do this.

The 3rd option is to, as you stated, move the varying string into a fixed 
length string before the call, but Hans solution is, IMO, much better.

Regards,

Jim Langston

-----Original Message-----
From: MWalter@hanoverwire.com [mailto:MWalter@hanoverwire.com]

Jim,

Here is a code snippit,

     DhtmlOut          S           1024    VARYING
     Dx                s             10i 0

     c                   clear                   htmlOut
     c                   eval      htmlOut = x'15' +
     C                             '<UL>'
     C**                           '<TABLE border="1">'
     c                   eval      outLn = %len(%trim(htmlOut))
     c                   callb     'QtmhWrStout'
     c                   parm                    htmlOut
     c                   parm                    outln
     c                   parm                    qusec
<SNIP>


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.