Config File

version 2 by Aaron Reed

  • Home page
  • Beginning
  • Previous
  • Next



  • Section - Converting Strings to Numbers
            
    To decide what indexed text is contents of (str - an indexed text):
        unless str matches the regular expression "^(<['][quotation mark]>)(.*)(<['][quotation mark]>)$":
         say "***Error reading [str] as a string; using default value instead.***";
            decide on "";
        say "*[text matching subexpression 1]|[text matching subexpression 2]|[text matching subexpression 3]*";
        now str is "[text matching subexpression 2]";
        replace the text "\[quotation mark]" in str with "'";
        decide on str.
            
    To decide if boolean of (str - an indexed text):
        if str matches the text "true", case insensitively:
            now theVal is "true";
            decide on true;
        else:
            now theVal is "false";
            decide on false.

    To decide what number is numerical value of (str - an indexed text):
        let cursorPos be the number of characters in str;
        let cursorChar be an indexed text;
        let total be 0;
        let digit be 0;
        let tens be 1;
        while cursorPos > 0:
            now cursorChar is character number cursorPos in str;
            if cursorChar matches the text "9":
                now digit is 9;
            otherwise if cursorChar matches the text "8":
                now digit is 8;
            otherwise if cursorChar matches the text "7":
                now digit is 7;
            otherwise if cursorChar matches the text "6":
                now digit is 6;
            otherwise if cursorChar matches the text "5":
                now digit is 5;
            otherwise if cursorChar matches the text "4":
                now digit is 4;
            otherwise if cursorChar matches the text "3":
                now digit is 3;
            otherwise if cursorChar matches the text "2":
                now digit is 2;
            otherwise if cursorChar matches the text "1":
                now digit is 1;
            otherwise if cursorChar matches the text "0":
                now digit is 0;
            otherwise:
                say "***Error reading [str] as number; using default value instead.***";
                decide on -1;
            increase total by ( digit * tens ) ;
            now tens is 10 * tens;
            decrease cursorPos by 1;
        decide on total.