// chart-defaults.afl
// ---------------------------------------------------------------------------
// A deliberately tiny include file, used by Part 11 to demonstrate #include
// before the full course library is built.
//
//   Version : 1.00
//   Requires: AmiBroker 5.30 or later
//
// Every public name here starts with Demo, so this file cannot collide with
// your own variables, with the course library, or with anything AmiBroker
// ships. Nothing in this file executes: it only defines.
// ---------------------------------------------------------------------------

// ---------------------------------------------------------------------------
// DemoHeaderText( ExtraText )
//   Purpose : One consistent first line for every chart title you write.
//   Inputs  : ExtraText - STRING appended after the symbol and interval
//   Returns : STRING
//   Notes   : Interval( 2 ) returns the interval's NAME. The official page
//             warns never to compare that name in code, because it is
//             translated in localised builds - displaying it is fine.
// ---------------------------------------------------------------------------
function DemoHeaderText( ExtraText )
{
    local Result;

    Result = Name() + " - " + Interval( 2 ) + " - " + ExtraText;

    return Result;
}

// ---------------------------------------------------------------------------
// DemoPercentOf( PartArray, WholeArray )
//   Purpose : Express one array as a percentage of another without producing
//             an infinity when the divisor is zero.
//   Inputs  : PartArray, WholeArray - ARRAYs
//   Returns : ARRAY, percent, Null where the result would not be finite
// ---------------------------------------------------------------------------
function DemoPercentOf( PartArray, WholeArray )
{
    local Quotient;
    local Result;

    Quotient = PartArray / WholeArray;
    Result   = IIf( IsFinite( Quotient ), 100 * Quotient, Null );

    return Result;
}

// End of chart-defaults.afl
