15 pts.
 Data sent to device DSP01 not valid. Negative response code is 10050122.
Hello.

My display file crashes as it can not display the hexadecimal values in my character field. Is there an easy way to replace these values (like scan) in my 79 character long field that has valid characters mixed with hexadecimal values? (Please no APIs)

Thank you in advance.

Regards

Steven



Software/Hardware used:
iSeries RPG
ASKED: September 29, 2010  10:47 AM
UPDATED: September 30, 2010  2:41 PM

Answer Wiki:
Option 1 -- TomLiotta's suggestion: <i>You can loop through the characters in the string. Replace any byte that is less than x’3F’ with x’3F’</i> <pre> d replCharacter c const(x'3F') d fld79a s 79 inz(x'F0F1F2F3F44022') '01234'+ blank + unprintable d loc s 5i 0 c for loc = 1 to %len(fld79a) c if %subst(fld79a:loc:1) < replCharacter c eval %subst(fld79a:loc:1) = replCharacter c endif c endfor </pre> Option 2 -- BigKat's original suggestion incorporating TomLiotta's suggestion: <i>The Character Data Representation Architecture (CRDA) specifies the ‘3F’X character as a replacement character. It should show up as a reverse-image block on the display.</i> <pre> d validCharacters... d c const('0123456789 ') d replCharacter c const(x'3F') d fld79a s 79 inz('01234ABC56789') d loc s 5i 0 c eval loc = %check(validCharacters + replCharacter c :fld79a) c dow loc <> 0 c eval %subst(fld79a:loc:1) = replCharacter c eval loc = %check(validCharacters + replCharacter c :fld79a) c enddo </pre> or if you prefer a procedure for use in a service program (and it even uses <b><i>RECURSION</i></b>) BTW: I arbitrarily chose 132 characters, as that should handle any field on the standard display sizes unless you have used CNTFLD to split a longer field into a continuous multi-line field. <pre> d displaySafe pr 132a d input 132a const p displaySafe b export d displaySafe pi 132a d input 132a const d validCharacters... d c const('0123456789 ') d replCharacter c const(x'3F') d loc s 5u 0 d wrk s 132a c eval wrk = input c eval loc = %check(validCharacters + replCharacter c :wrk) c if loc = 0 c return wrk c else c eval %subst(wrk:loc:1) = replCharacter c return displaySafe(wrk) c endif p displaySafe e </pre>
Last Wiki Answer Submitted:  September 30, 2010  2:41 pm  by  BigKat   7,175 pts.
All Answer Wiki Contributors:  BigKat   7,175 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

%xlate could be used to translate all bad characters to good characters, but I figured it was easier to create a list of all valid characters rather than a list of all invalid ones.

%xlate(from:to:string)
 7,175 pts.

 

Hello BigKat.

Thank you for the prompt response, I will give it a bash in the morning, it is sunset here in RSA.
How does query display/report the values, even if it is garbage. Could the same technique not be used?

Regards
Steven

 15 pts.

 

query does a character substituition for unprintable characters at the system level. It is not a function that you can call (as far as I know)

 7,175 pts.

 

For this line:

 d replCharacter   c                   const(' ')

…consider making this change:

 d replCharacter   c                   const( x'3F' )

The Character Data Representation Architecture (CRDA) specifies the ’3F’X character as a replacement character. It should show up as a reverse-image block on the display.

Tom

 107,695 pts.

 

You can loop through the characters in the string. Replace any byte that is less than x’3F’ with x’3F’.

Tom

 107,695 pts.

 

if you do Tom’s suggestion

d replCharacter   c                   const(’ ‘)

you need to change

c                   eval      loc = %check(validCharacters:fld79a)

to

c                   eval      loc = %check(validCharacters + replCharacter
c                             :fld79a)                                    
 7,175 pts.

 

doh!

Tom’s suggestion of

d replCharacter   c                   const( x’3F’)
 7,175 pts.