Config File

version 2 by Aaron Reed

  • Home page
  • Beginning
  • Previous
  • Next



  • Section - Reading and Processing the File

    First when play begins (this is the read the external config file rule):
        read config file.

    To read config file:
        unless File of Config exists:
            write " " to File of Config;
            say blank config file message;
            stop;
        let config file be "[text of File of Config]";
        repeat with ln running from 1 to the number of lines in config file:
            let thisline be line number ln in config file;
            set key value pair for thisline;
            if theKey is "", next;
            if setup-external-variables is true, generate external variable code;
            repeat with valObj running through value-objects:
                if nkey of valObj is theKey:
                    if theType is tNumeric:
                        let valNumber be numerical value of theVal;
                        unless valNumber is -1:
                            now nVal of valObj is valNumber;
                    else if theType is tBoolean:
                        let valTruth be whether or not boolean of theVal;
                        now tVal of valObj is valTruth;
                    else:
                        let valStr be contents of theVal;
                        unless valStr is "":
                            now sVal of valObj is valStr;
        if setup-external-variables is true and the number of lines in config file > 0, say "[line break]** Completed generating config file code.";
        repeat with valObj running through value-objects:
            carry out the externally assigning activity with valObj.