I'm using the V5R3 version and I cannot seem to get it to convert negative numbers into negatives on the generated spreadsheet. I've tried both packed and signed decimals and they all come out positive on the spreadsheet no matter the sign in the physical file.
--
Bob Comer
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Okay, figured out the problem -- in the XLCRTR ILERPG program, you use %SCAN to test for a value of x'D0', where I assume you were thinking it would test for greater than rather than equals, it tests for equals so it doesn't work. I replaced that logic with a quick and dirty array scan instead and it works as intended. I'm sure there's a much more elegant way to do this, but I don't have the time to think about it right now.
Reaplce the two instances of this code:
Negative=%Scan(x'D0':Zoned);
If Negative>0;
CNumeric=CNumeric*-1;
EndIf;
with
I=1;
Negative=0;
DoU I>31 or Negative>0;
If Scanstr(I)>x'D0';
Negative=I;
endif;
I=I+1;
enddo;
If Negative > 0;
CNumeric=CNumeric*-1;
endif;
**added defines
DScanstr s 1A DIM(31)
DI s 3i 0
--
Bob Comer
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm using the V5R3 version and I cannot seem to get it to convert negative numbers into negatives on the generated spreadsheet. I've tried both packed and signed decimals and they all come out positive on the spreadsheet no matter the sign in the physical file.
--
Bob Comer
Okay, figured out the problem -- in the XLCRTR ILERPG program, you use %SCAN to test for a value of x'D0', where I assume you were thinking it would test for greater than rather than equals, it tests for equals so it doesn't work. I replaced that logic with a quick and dirty array scan instead and it works as intended. I'm sure there's a much more elegant way to do this, but I don't have the time to think about it right now.
Reaplce the two instances of this code:
Negative=%Scan(x'D0':Zoned);
If Negative>0;
CNumeric=CNumeric*-1;
EndIf;
with
I=1;
Negative=0;
DoU I>31 or Negative>0;
If Scanstr(I)>x'D0';
Negative=I;
endif;
I=I+1;
enddo;
If Negative > 0;
CNumeric=CNumeric*-1;
endif;
**added defines
DScanstr s 1A DIM(31)
DI s 3i 0
--
Bob Comer
<red faced>
Ooops, my logic made everything negatives.
</red faced>
Here's a new go that's slightly more elegant and actually works:
c movea Zoned Scanstr
/free
I=1;
DoU I>31;
If Scanstr(I)>=x'D1' And Scanstr(I)<x'D9';
CNumeric=CNumeric*-1;
leave;
endif;
I=I+1;
enddo;