removing decimal point (AREV Specific)
At 17 JAN 2008 10:22:43PM Chang Lee Churn wrote:
Is there a built-in program or function that allows me to remove decimal point from a string or mathematical value?
the problem I'm having now is because the decimal point can sometimes be in the 2nd or the 3rd position in the string.
is there a way to solve this problem?
At 17 JAN 2008 11:56PM Warren Auyong wrote:
See the documentation on the ICONV/OCONV function.
At 18 JAN 2008 11:21AM Victor Engel wrote:
My preferred method is to use the masked decimal conversion. Suppose you have a value in variable X that is numeric. You can set a variable Y to the closest integer using this statement:
Y=OCONV(X,"MD0")
or the abbreviated version:
Y=X "MD0"
If, instead, you want to truncate the value, you'd use the INT function:
Y=INT(X)
There are certainly more options available to you, but your question was pretty vague, so I'll leave it at that.
At 20 JAN 2008 08:04PM Chang Lee Churn wrote:
let's just I have a string "10.000"
or "9.232"
how would I be able remove the decimal point from these 2 strings?
as you can see the position of decimal point from these 2 strings.
At 20 JAN 2008 09:55PM Chang Lee Churn wrote:
" let's just I have a string "10.000"
or "9.232"
how would I be able remove the decimal point from these 2 strings?
as you can see the position of decimal point from these 2 strings. "
What I'm trying to say is that. the position of decimal point is different 2 strings, in
1st string, the decimal point is in 3rd position,
while in the 2nd string, the decimal point is 2nd position.
At 20 JAN 2008 10:33PM [email protected]'s Don Bakke wrote:
Will the number always have the same number of significant digits? That is, will the numbers always be 3-digit decimals? If so, then using the Iconv function as has already ben suggested. For example:
Val='10.000' [/color]NewVal=Iconv(Val, [/color]'MD3'[/color])[/color][/color][/size]If the number of decimal points is variable then you can always to a Convert:
Convert [/color]'.' [/color]to [/color]'' [/color]in [/color]Val[/color][/color][/size]
At 23 JAN 2008 12:56PM Paul Marraffa wrote:
Split the string, or Convert to @FM then act on each part accordingly.
ReturnResultInt=Field(OrigValue,".",PositionOne)
ReturnResultDec=Field(OrigValue,".",PositionTwo)
Convert "." to @FM in OrigValue
ReturnResultInt=OrigValue
ReturnResultDec=OrigValue
BASIC:
Length=Len(OrigValue)
Pos=Index(".",OrigValue,1)
Pos+=1
ReturnResultInt=Int(OrigValue)
ReturnResultDec=OrigValuePos,Length
At 23 JAN 2008 05:39PM Victor Engel wrote:
BASIC:
Length=Len(OrigValue)
Pos=Index(".",OrigValue,1)
Pos+=1
ReturnResultInt=Int(OrigValue)
ReturnResultDec=OrigValuePos,Length
–
I think you wanted to say:
Pos=Index(OrigValue,".",1)
but even that would give unexpected results. Consider if there were no decimal point. In that case, you'd wind up with ReturnResultDec having the original value.
Why not just use math for math problems:
ReturnResultInt=Int(OrigValue)
ReturnResultDec=Mod(OrigValue,1)
It's simpler, and it works. Of course this asssumes you're actually dealing with numbers.
At 24 JAN 2008 02:43AM Chang Lee Churn wrote:
Here's my method.
CONVERT '.' to
in RESULT1 * Assuming RESULT1 is string, has value of 98.9000 * R1_CHK=LEN(RESULT1) IF R1_CHK ] 3 THEN RESULT1=ICONV(RESULT1,'MD0') END ELSE RESULT1 =FMT((RESULT1),"L(0)#6") END Here's another question: for CONVERT '.' to
in RESULT1I'll start from
RESULT1 to RESULT15.
Would it possible to do it this way?
FOR RST_CNT=1 TO 15
STG1 =.'"STG2 ='"STG3 = TO "STTG =CONVERT ":STG1:" to ":STG2:" in RESULT":RST_CNT:" "* CALL MSG("RST_CNT IS %1%",'T1','',RST_CNT)
PCPERFORM STTGNEXT
I've encountered this message like executing the PCPERFORM STTG line.
"Invalid Parameter - to"
At 24 JAN 2008 06:12AM [url=http://www.sprezzatura.com]The Sprezzatura Group[/url] wrote:
Do you have any AREV manuals? What you are doing is incredibly far off base and seems to be driven more by experimentation than actual programming knowledge. A set of AREV manuals would seem to be a good starting point.
What are you trying to achieve? We know the stated aim was to remove decimals but are you trying to arrive at a standardised number (e.g. given inputs of 12.123 4.12 888.3542 etc be able to treat them all as 12.1230 4.1200 and 888.3542?) To do this you'd say
Variable=Oconv(Iconv(Variable, "MD4"), "MD4")
PcPerform is used to execute DOS commands, not to run R/Basic commands. Hence the command interpreter is telling you that "TO" is not an option for the CONVERT DOS command. The DOS CONVERT command converts FAT volumes to NTFS.
You can't create variable variables in a loop like that in any case.
World leaders in all things RevSoft
At 24 JAN 2008 06:20AM [url=http://www.sprezzatura.com]The Sprezzatura Group[/url] wrote:
BTW - in relation to your offline queries - the email address we have for you is bouncing - hence our lack of response. If you'd care to email again ([email protected]) we can reply properly.
Regards
World leaders in all things RevSoft
At 25 JAN 2008 02:20AM Chang Lee Churn wrote:
well, it's impossible to have string has no decimal point at all.
the removal of decimal point is actually a minor part of a program,
that reads a text file line-by-line. then extracts the data with a certain length then assign them into fields of an AREV table.
the strings in question here is actually values of chemicals in the finished goods.
the values will either be in 0.0000 , or 98.8000, which means even there's ZERO value, the string will appear as 0.0000.
so, I think
ResultReturnDec=OrigValuePos,Length
should be sufficient.
At 25 JAN 2008 10:49AM Michael Slack wrote:
Here is an idea. Assuming that right of the decimal is always 4 digits in this case and to the left of the deciaml will be 1 or 2 digits.
STRING=NUMBER ;* NUMBER EQUALS 1.1234 or 98.7654
SWAP "." WITH "" IN STRING ;* STRING EQUALS 11234 or 987654
STRING=0" : STRING ;* STRING EQUALS 011234 or 0987654
STRING=STRING-1, 6 ;* STRING EQUALS 011234 or 987654
By always padding the number/string, your code doesn't have to do anything fancy. You'll always get a consitent number of digits as the final result.
I hope this helps.
Michael Slack
At 25 JAN 2008 11:05AM Victor Engel wrote:
In your scenario, the appropriate method would be to use:
ICONV(value,"MD4")