Dataport question...value to decimal return zero

kirkostaskirkostas Member Posts: 127
I have an Ascii file fixed length and it has a value 1000.00
I use a dataport to read it.
I want to enter this value to a decimal variable.
But always it takes 0.
I have made some tests.
I use a code variable and it returned ok.
I use evaluate function
evaluate(mydecimal, mycode);
and it returned 0 again.
How can i enter this value into my decimal variable?
kirkostas

Comments

  • krikikriki Member, Moderator Posts: 9,110
    Are you sure "mycode" has a value when you use EVALUATE?
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • kirkostaskirkostas Member Posts: 127
    edited 2007-10-17
    Yes it has a value, I can see it by using
    message(format(mycode));
    

    It returns 1000.00 but when i do evaluate i get this error message

    Decimal must not be blank.
    Decimal is missing or invalid on the expression.
    kirkostas
  • krikikriki Member, Moderator Posts: 9,110
    kirkostas wrote:
    Yes it has a value, I can see it by using
    message(format(mycode));
    
    And what value does it has?
    PS you should use message('%1',format(mycode));
    the first parameter is a formatting string, so it is possible your value is interpreted.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • kirkostaskirkostas Member Posts: 127
    It returns 1000.00 but when i do evaluate i get this error message

    Decimal must not be blank.
    Decimal is missing or invalid on the expression.
    kirkostas
  • Yaroslav_GaponovYaroslav_Gaponov Member Posts: 158
    Hi
    May be problem in separator - what this code return? MESSAGE('%1',FORMAT(3/2)[2])
  • kirkostaskirkostas Member Posts: 127
    It returns comma (,)
    My number is 1000.00 (dot).
    How can I convert it?

    Just replace (.) dot with (,) comma?
    So simple?

    I tried it but no I get the same error.

    This is my original code
    MESSAGE('%1',FORMAT(3/2)[2]);
    
    DebitNetAmt := CONVERTSTR(DebitNetAmt,'.',',');
    CreditNetAmt := CONVERTSTR(CreditNetAmt,'.',',');
    
    EVALUATE(DebitNetAmtDec,DebitNetAmt);
    EVALUATE(CreditNetAmtDec,CreditNetAmt);
    VALIDATE("Debit Net Amount",DebitNetAmtDec);
    VALIDATE("Credit Net Amount",CreditNetAmtDec);
    

    DebitNetAmt and CreditNetAmt returns correct values but when I evaluate them to their decimal variables it crashes.
    kirkostas
  • Yaroslav_GaponovYaroslav_Gaponov Member Posts: 158
    Hi

    Have 2 way
    1. change region and language options
    2. Just change '.' on FORMAT(3/2)[2] symbol
  • krikikriki Member, Moderator Posts: 9,110
    Use this to clean the string from all 'dirty' characters. So you keep only a valid decimal string.
    DebitNetAmt := DELCHR(DebitNetAmt,'=',DELCHR(DebitNetAmt,'=','1234567890.,'));
    

    Afer this command, you can convert the "," to ".".
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • kirkostaskirkostas Member Posts: 127
    Same error again ](*,)
    //MESSAGE('%1',FORMAT(3/2)[2]);
    
    DebitNetAmt := DELCHR(DebitNetAmt,'=',DELCHR(DebitNetAmt,'=','1234567890.,'));
    CreditNetAmt := DELCHR(CreditNetAmt,'=',DELCHR(CreditNetAmt,'=','1234567890.,'));
    
    DebitNetAmt := CONVERTSTR(DebitNetAmt,'.',',');
    CreditNetAmt := CONVERTSTR(CreditNetAmt,'.',',');
    
    EVALUATE(DebitNetAmtDec,DebitNetAmt);
    EVALUATE(CreditNetAmtDec,CreditNetAmt);
    VALIDATE("Debit Net Amount",DebitNetAmtDec);
    VALIDATE("Credit Net Amount",CreditNetAmtDec);
    

    and again the
    MESSAGE(DebitNetAmt);
    
    returns 1000,00 correctly...

    but when evaluate to decimal i get

    Decimal must not be blank.
    Decimal is missing or invalid on the expression.

    Error... ](*,)
    kirkostas
  • Yaroslav_GaponovYaroslav_Gaponov Member Posts: 158
    Hi

    I try and this work


    str := '10000.01';
    str := CONVERTSTR(str,'.',FORMAT(FORMAT(3/2)[2]));
    MESSAGE(str);

    IF EVALUATE(dec,str) THEN
    MESSAGE('%1',dec);
  • krikikriki Member, Moderator Posts: 9,110
    I think I got it.
    If you have both debit and credit in the dataport, in general one of them is blank, so you need to do this:
    IF DebitNetAmt <> '' THEN
      EVALUATE(DebitNetAmtDec,DebitNetAmt);
    IF CreditNetAmt <> '' THEN
      EVALUATE(CreditNetAmtDec,CreditNetAmt);
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Yaroslav_GaponovYaroslav_Gaponov Member Posts: 158
    kriki wrote:
    I think I got it.
    If you have both debit and credit in the dataport, in general one of them is blank, so you need to do this:
    IF DebitNetAmt <> '' THEN
      EVALUATE(DebitNetAmtDec,DebitNetAmt);
    IF CreditNetAmt <> '' THEN
      EVALUATE(CreditNetAmtDec,CreditNetAmt);
    

    Then just so :D


    if EVALUATE(DebitNetAmtDec,DebitNetAmt) then ;
    if EVALUATE(CreditNetAmtDec,CreditNetAmt) then ;
  • kirkostaskirkostas Member Posts: 127
    Thank you Yaroslav Gaponov this was my problem =D>
    kirkostas
Sign In or Register to comment.