Notifications
Clear all

[Closed] [Need suggest]Set ini setting didnt work as expected


edt_CstInputFormat.text = "hallo"


on btn_SetInput pressed do
(
	if edt_CstInputFormat.text !="" then
	(
	setIniSetting improterSetting "Batch" "Import" ("." + (edt_CstInputFormat.text)) as string;	
	setIniSetting improterSetting "CostumFormat" "ImportCostum" (edt_CstInputFormat.text) as string;
	)
	else (MessageBox "         You need to fill format first ! for example : PRJ and press set button 

Note: Only Imported files that supported by 3dsMax importer only that will work" title:"3ds Max")
)

I wrote the script to set ini setting like something above, but something didnt work as I expected, say from script I wrote it should resulting like this in my ini setting :


[Batch]
Import=.hallo

[CostumFormat]
ImportCostum=hallo

but instead something like that it resulting like this

my previeous edt_CstInputFormat.text = “world”


[Batch]
Import=.hallo

[CostumFormat]
ImportCostum=world

so basiclly instead update both entries it only update one entries only which is first line when command execute, which is :


[Batch]
Import=.hallo


[CostumFormat] ImportCostum=world

didnt updated to be something like this :


[CostumFormat] ImportCostum=hello

How to solve this problem, I want to both entries updated when I press the button ? btw I m workin in max 9

10 Replies

I think it’s because you had “as string” outside of a bracket. Also, “as string” isn’t required because everything is a string already. “;” at the end of the line is not required all the time. It’s only required if you want to tell maxscript to read a new line without putting more stuff on a new line, eg:


obj1.wirecolor = red ; obj2.wirecolor = blue

Updating your code with this worked for me:


setIniSetting improterSetting "Batch" "Import" ("." + edt_CstInputFormat.text)	
setIniSetting improterSetting "CostumFormat" "ImportCostum" (edt_CstInputFormat.text)

Thanks , but still not work properly…I try that too…even I put break command like clearlistener() just to make script pause when excute setini setting betwen one to another, but still doesnt work properly , I mean like I execute set ini many time but one in occasion it didnt work like I expect it…

result that I got from experiment
1st execute :

result :

[Batch]
Import=.hallo

[CostumFormat]
ImportCostum=hallo 

2nd execute or more execute (change hallo –> 3ds)

[Batch]
Import=.3ds

[CostumFormat]
ImportCostum=hallo 

thats mean it succes to change to what I expect isnt 100%, theres still probability to give in an error when I execute it many time and I dont wanna that.

Btw I work on max 2009 in this script.

thanks for answering.
best regard
fajar

Why do you need to save a string with and without a dot? Surely you can just save one string in the ini file and add a dot in the script after loading from the ini file.

What you have posted should work and it does work in max 2009 for me. It’s hard to tell what’s going on with such a small amount of code though.

You could try defining a variable and supplying that to the ini file:


textToSave = edt_CstInputFormat.text
setIniSetting improterSetting "Batch" "Import" ("." + textToSave)	
setIniSetting improterSetting "CostumFormat" "ImportCostum" textToSave

 lo1

there’s no reason this should not work. Please post full code.

im on mission making batch file format converter that support many file format…so I decided to make to editText (2 kind ,one input format, one out put format), instead I must wrote somthing like “.3ds” I decide to input “3ds” only so more easy to remember and writte, and when I press button it should be writte “.3ds” in ini file so I can call it when I need it (starting batch convert), I know I can use many way, I already make one using dropdown list, but its pain when I must writte the code (when dropdown selection == 1 do setinisetting xxxx, when drop down selection ==2 then do set ini setting…etc) its so long. so I m using editText instead…

I know the script I wrotte above should work , indeed it work, but not 100% work when it used to writte in ini setting…like something I reported you above…it strange I know, im used those kind of way long time ago and never had problem, but now something off.

BTW this is the full script


/*
[I]1. give the Input to both editText and pres de button
2. open the ini file afterward and see what happen
3. close the opened ini file
4. keep change editText text both of them and press de button too...  (also give them combination betwen number and text like input = 3ds output=77, then change input=c4d output=max or somthing like that )
5. open the ini file again and see what happen (sometime I got[Batch] Import entries changed to what I expect but not [CostumFormat]ImportCostum or reverse)
6. Keep repeat step 1-5 to see what I mea[/I]n 
*/

(
	improterSetting = ((getDir #plugcfg) + "\\Improter.ini")
	
	rollout testControl "Untitled" width:219 height:30
	(
		editText edt_CstInputFormat "" pos:[5,6] width:49 height:18
		editText edt_customFormat "" pos:[121,7] width:49 height:18
		
		button btn_SetInput "Input" pos:[58,6] width:36 height:20
		button btn_setFormat "Output" pos:[174,7] width:36 height:20
		
		
		on btn_SetInput pressed do
		(
		if edt_CstInputFormat.text !="" do
			(
			setIniSetting improterSetting "Batch" "Import" ("." + (edt_CstInputFormat.text))
			setIniSetting improterSetting "CostumFormat" "ImportCostum" (edt_CstInputFormat.text)
			)
		)
			
		on btn_setFormat pressed do
			(
				if (edt_customFormat.text !="" and (edt_CstInputFormat.text !="")) do
				(
				setIniSetting improterSetting "Batch" "Export" ("." + (edt_customFormat.text))
				setIniSetting improterSetting "CostumFormat" "ExportCostum" (edt_customFormat.text)
				)
			)					
		
	)
	createDialog testControl
)

--PS : sorry too bother with your time
-- thanks

best regard
fajar

 lo1

your code works fine for me.

1 Reply
(@fajar)
Joined: 1 year ago

Posts: 0

did you already do what I quote in my script above many time ? I know something weird.

btw thanks for reply maybe wrong thing is my max…

 lo1

I tried it 10-15 times and didn’t get any unexpected results.

thansk lo for confirming…maybe the wrong thing is my max.

 lo1

if you find an exact reproducible scenario let us know…