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



Arthur Marino wrote:
Speaking of negative numbers, as I've explained earlier, I'm reading
columns in a .csv file, which can contain a leading minus sign (and,
optionally, a decimal point). Then I'm building a character string that
conforms to the output file's DDS. So I handled the negative value in
the 'coldta' string by purging the decimal point and minus sign, and
then substituting J, K, L, etc. for the last 'digit' before appending
'coldta' to the string.

Can anyone tell me how I could just alter the sign portion of the last
byte to denote 'negative' so I wouldn't need the alternating tables?


The %DEC built-in function will take a string like '-123.45' and return a numeric value. If you multiply it by 10 to the power of your decimal places, you'll get a zero-decpos value with the same zoned-decimal data. If you then use %EDITC 'X' on the zero-decpos value and then substring, you'll get the result you want.

D len s 10i 0
D decpos s 10i 0
D string s 50a varying
D num s 63S 0
D val s 63A varying
D NUM_LEN c %len(num)

len = 5;
decpos = 0;
string = '-12345';
num = %DEC(string : 63 : 31) * %INTH(10 ** decpos);
val = %EDITC(num : 'X');
val = %subst(val : NUM_LEN - len + 1);


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.