import arcpy
from arcpy import env
import os
import traceback
import sys

try:
    project_folder = arcpy.GetParameterAsText(0)
    inputFN = os.path.join(project_folder+os.sep,"lg_user_defined_params.txt")
    inputTxtFile = file(inputFN,'wt')
    crs=open(inputFN,'a')
    crs.write("Rem_ZI_Dist = "+arcpy.GetParameterAsText(1)+"\n")
    fragInput = arcpy.GetParameterAsText(2)
    if fragInput == "GUIDOS output if available otherwise run LFT":
        crs.write("Use_Guidos_when_available = 1\n")
    else:
        crs.write("Use_Guidos_when_available = 0\n")
        
    crs.write("distance4Edge = "+arcpy.GetParameterAsText(3)+"\n")
    crs.write("islandSize = "+arcpy.GetParameterAsText(4)+"\n")    
    crs.write("LR_Dist = "+arcpy.GetParameterAsText(5)+"\n")
    crs.write("LR_ZI_Dist = "+arcpy.GetParameterAsText(6)+"\n")
    crs.write("PPA_Dist = "+arcpy.GetParameterAsText(7)+"\n")
    crs.write("PPA_ZI_Dist = "+arcpy.GetParameterAsText(8)+"\n")
    crs.write("PA_Dist = "+arcpy.GetParameterAsText(9)+"\n")
    crs.write("PA_ZI_Dist = "+arcpy.GetParameterAsText(10)+"\n")
    if arcpy.GetParameterAsText(11) == "true":
    	crs.write("Assign_100 = 1\n")
    else:
	crs.write("Assign_100 = 0\n")
    crs.close()
except:
    #arcpy.AddMessage("exiting")
    tb = sys.exc_info()[2]
    tbinfo = traceback.format_tb(tb)[0]
    #arcpy.AddMessage("exiting2")
    pymsg = tbinfo + "\n" + str(sys.exc_type)+ ": " + str(sys.exc_value)

    arcpy.AddError(pymsg)
finally:

    arcpy.AddMessage("File Written to: "+ inputFN)        
