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



hi Dave,

Back in the days when I coded in BASIC (long, long ago) we used to do things like this (hopefully I still remember the syntax)

MYDATA$ = "Hello World" + CHR$(13) + CHR$(10)

The CHR$(10) and CHR$(13) insert values of ASCII 10 (line feed) and ASCII 13 (carriage return).

My interpretation was that John McKee (the original poster) thought that RPG's %CHAR() BIF worked the same way as the BASIC CHR$() BIF. In other words, it sounded to me like John expected this RPG code:

MyData = 'Hello World' + %char(13) + %char(10)

to work the same as this BASIC code:

MyData$ = "Hello World" + CHR$(13) + CHR$(10)

Obviously, they do not work the same. The RPG example results in this string: 'Hello World1013', whereas the BASIC code results in 'Hello World<cr><lf>' (where <cr> is the carriage return, and <lf> is the line feed)

To do the same thing in RPG, you'd code this instead:

MyData = 'Hello World' + x'0d' + x'0a';

Except, of course, RPG is usually coded in EBCDIC, not ASCII... and in EBCDIC instead of x'0a' it'd be x'25' (Though, the x'0a' would be correct if you are coding for Windows or other ASCII system.)

MyData = 'Hello World' + x'0d' + x'25';

Now, of course, John's example wasn't looking for the CR and LF characters, instead he was trying to get the equivalent of CHR$(105) and CHR$(12)... So I posted the RPG hex values for those... though, I don't know enough about his particular situation to know whether 105 and 12 were the proper characters to begin with?


On 8/3/2011 4:34 AM, Dave wrote:
Scott, I am amazed that you got the answer, I did not even understand
fully the question.

Would you mind elaborating for curiosity's sake?

2011/8/3 Scott Klement<midrange-l@xxxxxxxxxxxxxxxx>:
RPG questions should really be posted to RPG400-L...

But, %char() converts data in a numeric field to it's human readable
representation in a character field. (I think you are confusing it with
the BASIC CHR$() function that converts an ASCII code point to a character.)

Assuming you want to put a byte containing the value decimal 105 (hex
69) together with a byte containing decimal 12 (hex 0c) then the RPG
code would be:

bc = x'69' + x'0c'


On 8/2/2011 6:12 PM, John McKee wrote:
I am trying to build a composite code 128 bar code. The composite part is that I am needing to use mode B and mode C.

I have a sample barcode and when I compare my results, the bars don't match.

Today, I had a "bright idea". Run a test program in debug mode and look at the character string that the test program built.

What I have, partially is:

eval bc = %char(105) + %char(12)

The bc field is defined as character.

When I looked at the bc variable in debug, it showed 10512

Is debug "helping" me like Windows usually does? Or, am I using the wrong BIF? Looking at the manual, %char would seem to be the right BIF. I seem to remember something a few months ago where debug does try to "help". I can't remember enough of what I think I remember to search the archives.

Seems like a stupid question, to me.

Thanks for assistance.


John McKee

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.





As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.