Personalized MAX does not know where the code is wrong.

The script is problematic, but I don't know how to modify it, please point out, thank you.

The code is as follows:

rollout SPmyPersTitle "个性化Max" width:347 height:318
(
	GroupBox grp1 "个性化标题栏" pos:[10,10] width:195 height:176
	checkbox isOpen "启用个性化标题栏" pos:[23,158] width:150 height:18
	checkbox filen "文件名" pos:[23,30] width:120 height:20
	checkbox filep "文件路径" pos:[23,50] width:120 height:18
	checkbox size "文件大小" pos:[23,70] width:120 height:20
	checkbox creDate "文件创建时间" pos:[23,90] width:120 height:20
	checkbox modDate "最后修改时间" pos:[23,110] width:120 height:18
	checkbox ver "Max版本" pos:[23,130] width:120 height:18
	local cont=#(filen,filep,size,creDate,modDate,ver)
	local tit=""
 
	fn getVer =
	(	v=(maxversion())[1]/1000
		if v<=9 then return v
		else return (2008+v-10)
	)
 
	fn getStr n =
	(	filename=maxfilename
		filepath=CGplusplusFunc.SlashConvert maxfilepath
		file=filepath+filename
		if not doesfileexist file then (
			filename="Untitled"
			filepath=CGplusplusFunc.SlashConvert (getdir #Scene)
		)
		case n of
		(	1 : filename
			2 : filepath
			3 : (	thestr="大小:"
					fs=getFileSize file
					ss=fs/1024
					if ss < 1024 then thestr+=ss as string + " KB"
					else thestr+=(fs/1048576) as string + " MB"
					thestr
				)
			4 : ( 	s01="创建:"
					if not doesfileexist file then s01+="未创建" else s01+=getFileCreateDate file
					s01
				)
			5 : (	s01="修改:"
					if not doesfileexist file then s01+="未修改" else s01+=getFileModDate file
					s01
				)
			6 : "3ds Max "+(getVer()) as string
			default : ""
		)
	)
	fn setTitle content:"" =
	(	str=""
		idx=findstring content "1"
		if idx!=undefined then 
		(	str+=getStr idx
			for t in idx+1 to 6 where content[t]!=undefined and content[t]!="0" do str+="  -  " + getStr t
		)
		if str.count==0 then str="请在场景助手-->选项-->个性化Max 中定制此处标题"
		cui.setAppTitle str
	)
 
	fn setTheTitle =
	(	tit=getinisetting spInifilepath "Main" "PerTitle"
		SPmyPersTitle.setTitle content:tit
	)
 
	fn switchTitle state:false =
	(	callbacks.removeScripts id:#setThePersTitle
		if state then
		(	tit=getinisetting spInifilepath "Main" "PerTitle"
			SPmyPersTitle.setTitle content:tit
			callbacks.addScript #filePostOpen "SPmyPersTitle.setTheTitle()" id:#setThePersTitle
			callbacks.addScript #filePostSave "SPmyPersTitle.setTheTitle()" id:#setThePersTitle
			callbacks.addScript #systemPostReset "SPmyPersTitle.setTheTitle()" id:#setThePersTitle
			callbacks.addScript #systemPostNew "SPmyPersTitle.setTheTitle()" id:#setThePersTitle
		)
		else ()
	)
 
	fn getINIpath = 
	(	
		thepath = getFilenamePath (getmaxinifile())+"defaults\\*"
		dirs = getDirectories thepath
		for d in dirs do
		(	
			file=d+"\\CurrentDefaults.ini"
			if doesfileexist file then return file 
			else (
				dirs01 = getDirectories (d+"*")
				for d01 in dirs01 do (
					file01 = d01+"\\CurrentDefaults.ini"
					if doesfileexist file then return file01
				)--end for
			)--end else
		)--end for
		""
	)
	on SPmyPersTitle open do
	(
 
		tit=getinisetting spInifilepath "Main" "PerTitle"
		for t in 1 to 6 do if tit[t]=="0" then cont[t].checked=false else cont[t].checked=true
		st=getinisetting spInifilepath "Main" "PerTitOpen"
		if st=="1" then isOpen.checked=true
		else (isOpen.checked=false;for i in cont do i.enabled=false)
		thever=maxversion()
 
	)
	on isOpen changed st do
	(	if st then
		(	setTheTitle()
			for i in cont do i.enabled=true
			setinisetting spInifilepath "Main" "PerTitOpen" "1"
		)
		else (
			for i in cont do i.enabled=false
			setinisetting spInifilepath "Main" "PerTitOpen" "0"
		)
		switchTitle state:st
	)
	on filen changed state do
	(	if state then tit[1]="1"
		else tit[1]="0"
		setTitle content:tit
		setinisetting spInifilepath "Main" "PerTitle" tit
	)
	on filep changed state do
	(	if state then tit[2]="1"
		else tit[2]="0"
		setTitle content:tit
		setinisetting spInifilepath "Main" "PerTitle" tit
	)
	on size changed state do
	(	if state then tit[3]="1"
		else tit[3]="0"
		setTitle content:tit
		setinisetting spInifilepath "Main" "PerTitle" tit
	)
	on creDate changed state do
	(	if state then tit[4]="1"
		else tit[4]="0"
		setTitle content:tit
		setinisetting spInifilepath "Main" "PerTitle" tit
	)
	on modDate changed state do
	(	if state then tit[5]="1"
		else tit[5]="0"
		setTitle content:tit
		setinisetting spInifilepath "Main" "PerTitle" tit
	)
	on ver changed state do
	(	if state then tit[6]="1"
		else tit[6]="0"
		setTitle content:tit
		setinisetting spInifilepath "Main" "PerTitle" tit
	)
 
)
 
createdialog SPmyPersTitle

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
fajar's picture

hmm.....

Are you chinese man? not racist question tho. I just want to know , can you convert those "chinese" word into english. May be someone able to help you , remember not everyone in the world can read chinese/japanese/korean/russian word, but percentage people able to read english are bigger than the previous one tho. So my suggestion if you in international forum , hope you use english language first than your native language . Im not english man too , im from indonesia, my english is bad.

on SPmyPersTitle open do
	(
 
		try 
		(
			local tit=getinisetting spInifilepath "Main" "PerTitle" -- this is the main issue
			local st=getinisetting spInifilepath "Main" "PerTitOpen"  -- this is the main issue
 
			-- because you try to get ini setting which is empty or undefined or not exist then its return undefined 
			-- you must set your ini first 
 
			for t in 1 to 6 do if tit[t]=="0" then cont[t].checked=false else cont[t].checked=true
 
			if st=="1" then isOpen.checked=true
			else (isOpen.checked=false;for i in cont do i.enabled=false)
		)
 
		catch
			(
			 ---setinisetting ..bla bla
 
			)
 
		thever=maxversion() -- what s this for ?????? 
 
	)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.