ivke.stojic
New User
Joined: 20 Dec 2021 Posts: 2 Location: Србија
|
|
|
|
I have trouble computing two numbers where one can be a negative number. All numbers are kept as text.
What is happening...
All the values are kept as text in the field of type PIC X(...) VALUES SPACES.
I have a procedure that will find the start of the value. For example:
_ _ _ _ _ 2 3 4 . 32
_ _ _ _ _ - 19. 32 (can be also negative number)
( underscores are representing spaces)
Adding, subtracting, multiplying, dividing everything works fine with a positive number. IF I got a negative number the program will break.
MOVE "_ _ _ _ 2 3 4 . 3 2" TO NAZIV
PERFORM SEC-LEN
SEC-LEN will give me two informations 1) whare are the first number position from left - PCP
2) what is the length of the number - DUZ
For the above example, PCP is 5 and DUZ is 6 (five numbers + dot)
MOVE SPACE TO SLXMLDBF
STRING " <AMOUNT>" DELIMITED SIZE
NAZIV(PCP:DUZ) DELIMITED SIZE
"</AMOUNT>" DELIMITED SIZE INTO SLXMLDBF
WRITE SLXMLDBF
The above code will write in the file <AMOUNT>234.32</AMOUNT>
01 NUM-1 PIC 9(13) VALUE 0.
MOVE NAZIV(PCP:DUZ) TO NUM-1.
COMPUTE NUM-1 = NUM-1 + 10.
If I try to move string "-23.32" tp S9 variable and do some addition the program will crash
I tried to work with S9(...) type of fields for the calculation of positive and negative numbers but without results. All operation on two positive numbers works fine. The problem comming when I get a negative number (tried with S9 type of filed
Redefining text field also didn't work for me.
My question is ... If there is a negative number written as text, how can I put it in the S9 variable and then use it for additions with another positive/negative number converted also from text?
I really hope that somebody can help me to overcome this problem!
Regards,
Ivan |
|