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



A am doing something very, very similiar in C++ for TCP/IP communications,
and I can tell you, it's not easy.  Pointer math, where am I in the buffer,
what am I moving to, etc...  It is a major pain, and if you know the
structure and can move it into a data structure, by all means, do so!

My problem is I have variable length text strings packed so can't do so
easily, but if I could use a data structure, believe me I would.

I ran into things like not being able to do a strncpy (string copy) on
a float, and had to use memcpy instead (memory copy) even though it worked
perfectly fine for integers.

If you must do it using pointers, you are going to have to work around
RPG's natural tendancies for data conversions.  Character to numeric,
it must be numeric characters, IE "1234", Numeric to character, it's
going to want to do the same thing.  You should find yourself fighting
the compiler every step of the way.  On the other hand, loading a
4 byte char string that is a 4 byte packed decimal into a data structure
with 4 byte characters and a 4 byte decimal will be no problem and
RPG should do it happilly.

Good luck,

Jim Langston

-----Original Message-----
From: Andrew Goade [mailto:agoade@hubgroup.com]

I was wondering if anyone had an easy way to convert from numeric data
types to character types and back.  I have a data structure that contains
alpha, packed, and binary fields.  It gets moved into a long alpha field
and passed to another program.  Instead of reading the long alpha field
into back into the data structure, I would like to substring out the
variables and move them to hold fields.  When I substring out the binary (4
positions in the buffer) to a 4 alpha field and try to move it to a 9b 0
field, my program blows up.  The hex values of the fields are the same, so
it makes me wonder why RPG won't do the conversion.

Thanks,
Andy


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.