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



I've written lots of programs in various languages to be able to enter, 
interpret,
and translate different base numbers.  It's really not that difficult.

All you have to do is to take the digit and find it's value.  An array lookup 
works
great for this.  Create an array of '0123456789ABCDEF'.  Lookup the character
and subtract 1.  Now you multiply it by it's positional value.  The only 
difficult thing
about this one is you have to work from right to left.  If you get the string 
and TRIM
it, you can figure out the lenghth.  I generally just do a DO loop to the 
lenghth to 1.
Then mulitply the value by ((stringlength - currectstringelement) + 1) ** 16.  
Then
add that to your working number.

So, what you just did is convernt the hex characters into a decimal number.  
Now you
can do anything you want to them, add, subtract multiply, whatever.  Then when 
you
want to print them out, you have to do it in reverse.  This is where DIV and 
MVR come
into play.

If you need any more info on this let me know.

Regards,

Jim Langston

janusz.prusaczyk@big.pl wrote:

> Sorry if I ask easy questions, I am only starting to learn:
>
> I want to read a string from file, the string can contain only these
> characters: "0123456789ABCDEF". I want to treat this string as hex number,
> add to it another hex number and write this number as string to file (I want
> to read this later in CL program as string value).
>
> Can anybody post some example code as how to convert such string to hex, add
> two hex values and write string to file representing the result?
>
> Thank you for your patience,
>
> David

+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

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.