We have some data that is coming in to our program that contains a floating $ (the good old dollar sign).
The incoming field is 14 chars including the $ so what the program we have
does is read each char position from right to left and evaluate it for being GE 0 (zero). If it is, it moves it. The thing is this done using a loop, and several lines of code. It seems bulky and unnecessary. In COBOL we just use a function that pulls the number out of the variable (NUMVAL-C).
Is there anything in NATURAL that does that?
-kevin
DEFINE DATA LOCAL
1 #A (A14) INIT<"$ 100.20">
1 #P (P7.2)
END-DEFINE
EXAMINE #A FOR FULL "$ " DELETE
if #A IS (P7.2)
#P := VAL(#A)
end-if
WRITE #P
end
Thanks, that was pretty close - the problem then became when there was no space (like $2345678901.34) - so I just made it “$” since “$ 102.20” is still going to become numeric if I delete the $ sign (Natural seems to handle the spaces to the left just fine).
-Kevin