parenthesis around a negative decimal figure

gulamdastagirgulamdastagir Member Posts: 411
hello,
please can u tell me the how to set the format property or function to achieve a parenthesis around a negative decimal figure 8-[ appearing in a textbox with sourceexpression set to a field in a table. in short is this possible ? "(-99.888)"

thanks in advance

gd
Regards,

GD

Comments

  • krikikriki Member, Moderator Posts: 9,118
    I think you must use a global text-variable, fill it up in the OnAfterGetRecord-trigger.
    Something like:
    txtTheText := FORMAT("The Decimal");
    IF "The Decimal" < 0 THEN
      txtTheText := '(' + txtTheText + ')';
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • DenSterDenSter Member Posts: 8,307
    I believe you can also set this in the Windows Regional Settings.
  • Made_in_HollandMade_in_Holland Member Posts: 1
    if it's only for viewing you could create a new function in the table, using the value as a parameter and a text value as a returnvalue.
    FormatDec(DecData : Decimal) FormattedValue : Text[1024]
    IF (DecData < 0) THEN BEGIN
      EXIT('(' + COPYSTR(FORMAT(DecData),1,MAXSTRLEN(FormattedValue)-2) + ')');
    END;
    
    EXIT(COPYSTR(FORMAT(DecData),1,MAXSTRLEN(FormattedValue)));
    

    to use this place the function with the decimal field in the SourceExpr, like :
    FormatDec(DecField)
    
  • gulamdastagirgulamdastagir Member Posts: 411
    kriki Posted: Mon Aug 21, 2006 4:46 am Post subject:


    I think you must use a global text-variable, fill it up in the OnAfterGetRecord-trigger.
    Something like:
    Code:
    txtTheText := FORMAT("The Decimal");
    IF "The Decimal" < 0 THEN
    txtTheText := '(' + txtTheText + ')';

    Thanks To Denster,Made in Holland and especially Kriki very impressive.
    Regards,

    GD
  • David_CoxDavid_Cox Member Posts: 509
    if it's only for viewing you could create a new function in the table, using the value as a parameter and a text value as a returnvalue.
    FormatDec(DecData : Decimal) FormattedValue : Text[1024]
    IF (DecData < 0) THEN BEGIN
      EXIT('(' + COPYSTR(FORMAT(DecData),1,MAXSTRLEN(FormattedValue)-2) + ')');
    END;
    
    EXIT(COPYSTR(FORMAT(DecData),1,MAXSTRLEN(FormattedValue)));
    

    to use this place the function with the decimal field in the SourceExpr, like :
    FormatDec(DecField)
    

    If it is a Form output then look at the TextBox Cal/Code, all you need is the following in the OnFormat Trigger

    DecDataControl - OnFormat(VAR Text : Text[1024]; )
    IF (DecData < 0) THEN
    Text := '('+Text+')';

    You can Also update the font color to Red as well within this trigger :D

    DecDataControl - OnFormat(VAR Text : Text[1024]; )
    IF (DecData < 0) THEN BEGIN
    Text := '('+Text+')';
    CurrForm.DecDataControl.UPDATEFORECOLOR(255);
    END ELSE
    CurrForm.DecDataControl.UPDATEFORECOLOR(0);
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
Sign In or Register to comment.