Inline conditional (conditional operator)

AshtonAshton Member Posts: 3
hi,

Is there any way in C/AL to do something like this (conditional operator):

A = F>0 ? 'yes' : 'No' ; // java example

just one line, no complex IF statement.

thx

Comments

  • BeliasBelias Member Posts: 2,998
    quantityIsGreaterThanZero := quantity > 0;
    
    is it simple enough 4 you? :wink::mrgreen:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Dirk.FischerDirk.Fischer Member Posts: 11
    The ?-:-Operater is not realized in C/AL.
    If it is possible to condition the result of a assignment like Belias posted then this is a short way otherwise you have no other chance than to code an IF-statement
  • DenSterDenSter Member Posts: 8,305
    What's wrong with an IF statement?
  • Joe_MathisJoe_Mathis Member Posts: 173
    The ?-:-Operater is not realized in C/AL.
    If it is possible to condition the result of a assignment like Belias posted then this is a short way otherwise you have no other chance than to code an IF-statement
    I think you meant:
    IF it is possible to condition the result of a assignment like Belias posted THEN
      this is a short way 
    ELSE
       you have no other chance than to code an IF-statement;
    
    :mrgreen:
    Sorry just feeling a little silly just now.
  • DenSterDenSter Member Posts: 8,305
  • David_SingletonDavid_Singleton Member Posts: 5,479
    I think a bicycle would be better.
    David Singleton
  • AshtonAshton Member Posts: 3
    thx to all for reply.

    Inline conditional wold be very usefull for reports design...
    for instance in TextBox.SourceExpr , instead:
    ( ABS("Credit Amount")>0 ? "G/L Account No." : '' )
    i have to create prosthesis like this:
    COPYSTR("G/L Account No.",1,20*(STRLEN(FORMAT(ABS("Credit Amount")))-1))

    ("Credit Amount" appear number or empty)
    IF-statement in SourceExpr is not accepted.

    Any better ideas for conditional in SourceExpr ??
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Ashton wrote:
    ...
    Any better ideas ...

    Always you should do what will be best in the long term for the customer.
    David Singleton
Sign In or Register to comment.