ScriptSpot

Forum topic · General Scripting

read value from an INI file

By tomastnt · 2012-12-19

Downloads
Description

hi all,
I have a problem with my script. I can't solve a bug about reading value from an ini file. I am not a scriptwriter, just trying to write a little script but I need to save my script setting to an INI file. In my case, I have to save a folder path for batch process. Saving works fine I would say, but loading that value crashes the script.
Script has been attached.

Thank you buddies for any help!

Comments (2)

-- macroScript

miauu · 2012-12-19


-- macroScript Library_Helper_Bug category:"TomTNT Script"
	( 	
		rollout Library_Helper_Script_Bug "Library Helper Bug" width:408 height:384
		(
			local libraryhelperbugIniFile = getFilenamePath (getSourceFileName()) + "/libraryhelperbug.ini"
			edittext text_infold "" pos:[16,24] width:312 height:16 text:"select directory to batch"
			button btn_infold "Browse" pos:[336,24] width:56 height:16
					
			on Library_Helper_Script_Bug open do
			(
				if doesFileExist libraryhelperbugIniFile then
				(
					--	if the ini file exist it will load the value from it
					max_dir = ((getIniSetting libraryhelperbugIniFile "Presets" "max_dir") as string)
					text_infold.text = (max_dir as string)
			
					)
					else
					(--	if the ini file does not exist the script will create new ini file
					max_dir = text_infold.text as string
					setIniSetting libraryhelperbugIniFile "Presets" "max_dir"  (max_dir as string)
					)
				)
				
				
				on btn_infold pressed do
				(
					max_dir = getSavePath()
					text_infold.text = (max_dir as string)
				    setIniSetting libraryhelperbugIniFile "Presets" "max_dir" (max_dir as string)
				)	
				
		--------------------------------------------------------------------------------------------------------------
				
				
			on libraryhelperIniFile close do
			(
				setIniSetting libraryhelperbugIniFile "Presets" "max_dir" (text_infold.text as string)
				
			)
			
		)createDialog Library_Helper_Script_Bug 408 64
	)	

Why you want to use stringStream?