# File rddc_generate_config.rb, line 24
def generate_config

  user_output = Rddc_txt_file.new(@default_file, "user_output")

  #generate <rddc options> part
  explanation_file = Rddc_txt_file.new(@default_file, "config_explanation")
  

  @config_file.to_a.each do |config|
    if explanation_file[config[0]] != nil then
      input = nil
      valid_options = Rddc_txt_file.new(@valid_options, config[0])
      #output to user
      puts explanation_file[config[0]]
      puts user_output["valid_options"] + valid_options.to_s if valid_options.valid?
      while (input == nil)
        print config[0] + "="
        input = gets
        if !valid_options.has_key?((input.chop)) and valid_options.valid? then
          puts user_output["invalid_option"]
          input = nil
        end
        #chop to remove the \n
        input = input.chop if input != nil
      end
      @config_file[config[0]]=input
    end
    if config[0]  == "language" then
      #reload the global file with the new language

      #taking user_output since it was inititalized with @default_file
      #Fixxme put the /global. string somewhere else
      @default_file = user_output.dirname + "/global." + input
      puts @default_file
      #reload those two files
      #maybe this should be a method on its own. (called twice)
      user_output = Rddc_txt_file.new(@default_file, "user_output")
      explanation_file = Rddc_txt_file.new(@default_file, "config_explanation")
    end
  end


  #generate <update variables> part
  explanation_file = Rddc_txt_file.new(@default_file, "update_explanation")

  @update_file.to_a.each do |config|
    service_config_file = @config_file.dirname + "/" + @config_file["service"]
    valid_update_variables = Rddc_txt_file.new(service_config_file, "update variables")
    #Debug
    #puts valid_update_variables.to_hash.include? config[0]
    #puts config[0]
    if Debug != 0 then
      puts service_config_file
      puts valid_update_variables.to_a.to_s
    end

    if valid_update_variables.to_hash.include? config[0] then

    if explanation_file[config[0]] != nil then
      input = nil
      #valid_options = Rddc_txt_file.new(@config_file["service"], "update_variables")
      valid_options = Rddc_txt_file.new(service_config_file, config[0])
      #output to user
      puts explanation_file[config[0]]
      puts user_output["update_variables"] + valid_options.to_s if valid_options.valid?
      while (input == nil)
        print config[0] + "="
        input = gets
        #chop to remove the \n
        input = input.chop
        if Debug != 0 then
          puts input + "|" if input != nil
        end
        if !valid_options.has_key? input and valid_options.valid? then
          puts user_output["invalid_update_variables"]
          input = nil
        end
      end
      @update_file[config[0]]=input
    end
    end
  end #do
  @update_file.write
  @config_file.write
end