Useful Functions

version 1 by ShadowChaser

  • Home page
  • Beginning
  • Previous
  • Next



  • Section 6 - Rankings

    Table of Example Equal Rankings
    rank  
    "very poor"  
    "poor"  
    "average"  
    "good"  
    "very good"  

    To decide what text is the EqualRankOf (value - a number) out_of (max_value - a number) from_table (rankTable - a table-name):
        let max_rows be the number of rows in rankTable;
        let row_number be (value * max_rows) / max_value;
        if row_number is 0, let row_number be 1;
        decide on the rank in row row_number of rankTable.
        
    Table of Example Ranged Rankings
    maxpercent  rank  
    10  "poor"  
    25  "fair"  
    75  "average"  
    100  "good"  

    To decide what text is the RangedRankOf (value - a number) out_of (max_value - a number) from_table (rankTable - a table-name):
        let max_rows be the number of rows in rankTable;
        let row_percent be (value * 100) / max_value;
        let rank_spoken be 0;
        repeat with row_number running from 1 to the number of rows in rankTable begin;
            if row_percent <= maxpercent in row row_number of rankTable begin;
                if rank_spoken is 0 begin;
                    decide on the rank in row row_number of rankTable;
                    let rank_spoken be 1;
                end if;
            end if;
        end repeat.