home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / pibterm / pibt41s3.arc / READCONF.MOD < prev    next >
Text File  |  1988-02-06  |  3KB  |  74 lines

  1. (*----------------------------------------------------------------------*)
  2. (*           Read_Config_File --- Read configuration file               *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. FUNCTION Read_Config_File : BOOLEAN;
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*     Function:   Read_Config_File                                     *)
  10. (*                                                                      *)
  11. (*     Purpose:    Reads parameters from primary PibTerm config. file   *)
  12. (*                                                                      *)
  13. (*     Calling Sequence:                                                *)
  14. (*                                                                      *)
  15. (*        Read_Ok := Read_Config_File : BOOLEAN;                        *)
  16. (*                                                                      *)
  17. (*           Read_Ok --- TRUE if config file found, else FALSE.         *)
  18. (*                                                                      *)
  19. (*     Calls:   Get_Config_File_Line                                    *)
  20. (*                                                                      *)
  21. (*----------------------------------------------------------------------*)
  22.  
  23. VAR
  24.    Ival       : INTEGER;
  25.    OK_To_Read : BOOLEAN;
  26.    I          : INTEGER;
  27.    J          : INTEGER;
  28.    Param_Num  : INTEGER;
  29.    Param_Str  : AnyStr;
  30.    Param_Ival : INTEGER;
  31.    Param_Rval : LONGINT;
  32.    Full_Name  : AnyStr;
  33.    Config_File: Text_File;
  34.  
  35. BEGIN (* Read_Config_File *)
  36.                                    (* Assign configuration file *)
  37.  
  38.   Add_Path( Config_File_Name, Home_Dir, Full_Name );
  39.  
  40.   ASSIGN( Config_File , Full_Name );
  41.        (*!I-*)
  42.   RESET( Config_File );
  43.        (*!I+*)
  44.  
  45.   OK_To_Read := ( Int24Result = 0 );
  46.  
  47.   IF NOT OK_To_Read THEN           (* If config file missing, prompt *)
  48.                                    (* user for input                 *)
  49.  
  50.      BEGIN (* No configuration file *)
  51.  
  52.         WRITELN;
  53.         WRITELN('Can''t find configuration file ',Full_Name);
  54.  
  55.      END   (* No configuration file *)
  56.  
  57.   ELSE                            (* PIBTERM.CNF exists -- read it *)
  58.      BEGIN  (* Config file exists *)
  59.  
  60.         WRITELN('Reading configuration file ',Full_Name);
  61.  
  62.         WHILE( Get_Config_File_Line( Config_File, Param_Num, Param_Str,
  63.                                      Param_Ival, Param_Rval ) ) DO
  64.            IF ( Param_Num > 0 ) THEN
  65.               Set_Parameter( Param_Num, Param_Ival, Param_Rval, Param_Str );
  66.  
  67.         CLOSE( Config_File );
  68.  
  69.      END    (* Config file exists *);
  70.  
  71.    Read_Config_File := OK_To_Read;
  72.  
  73. END   (* Read_Config_File *);
  74.