← 都来码 / Dolaima← 例程索引dbase/school/price_fraction.prg 原文

dbase/school/price_fraction.prg · 1305 字节 · 下载原文

FUNCTION PriceFraction( npQuantDispensed )
    LOCAL aPriceFraction := { {0,.06,.1},;
                            {.06,.11,.18}, ;
                            {.11,.16,.26}, ;
                            {.16,.21,.32}, ;
                            {.21,.26,.38}, ;
                            {.26,.31,.44}, ;
                            {.31,.36,.5}, ;
                            {.36,.41,.54}, ;
                            {.41,.46,.58}, ;
                            {.46,.51,.62}, ;
                            {.51,.56,.66}, ;
                            {.56,.61,.7}, ;
                            {.61,.66,.74}, ;
                            {.66,.71,.78}, ;
                            {.71,.76,.82}, ;
                            {.76,.81,.86}, ;
                            {.81,.86,.9}, ;
                            {.86,.91,.94}, ;
                            {.91,.96,.98} }
    LOCAL nResult
    LOCAL nScan
    IF npQuantDispensed = 0
            nResult = 0
    ELSEIF npQuantDispensed >= .96
            nResult = 1
    ELSE
            nScan := ASCAN( aPriceFraction, ;
                   { |aItem| npQuantDispensed >= aItem[ 1 ] .AND.;
                             npQuantDispensed <  aItem[ 2 ] } )
            nResult := aPriceFraction[ nScan ][ 3 ]
    END IF
    RETURN nResult