Notifications
Clear all

[Closed] Getting info to and from textfiles

Thanks Martijn,

OK I get the difference between global and local and broadly the scope of each of these. Where I am getting confused is the the use of the structure instance. I presume that when a spinner is changed the new value is stored in the instanced structure. There are two of these, so the question then becomes which to use or how to combine them. (or use them at all – go back to using a list of locals at the start of the script?

I’m beginning to think that the use of a structure for the variables is causing more harm than good! Why does it need to be outside the main scope of the script? Should I call a single instance at the start rather then one for each rollout?

Whats the best way of filling the array with an uptodate list of the variables (and making sure that these in turn are kept up to date in one place)?

For the functions def_parse and def_save I wouldn’t use structs because it doesn’t add any functionality…

I’ve attached a modified script… It’s not the most efficient way to do this though…

The vvmvars structure holds all variables… BUT, the UI items ALSO hold all variables… so basically you store the vars 2 times… Instead, you also could save the UI values directly, and get rid of the vvmvars structure…

Also, in your case I think it’s best to use setINIsetting & getINIsetting.

cheers!
Martijn

Thanks again Martijn,

I’ve tried using the getpropnames function on the structure instance and for some reason it messes up the order of the variables – any ideas.

Getting too complicated to manage when scaled up so I’ve gone down the ini file route…just a quick question:

the getINISetting command returns a string…whats the best way of converting this to a boolean value apart from using an if statement and return?

Originally posted by Alex Morris
whats the best way of converting this to a boolean value apart from using an if statement and return?

myValue = “true”
myValue = execute myValue

returns:
true

cheers
Martijn

Getting a Boolean value from an .ini file.

TrueorFalse=true

setINIsetting “D:\ emp\ ester.ini” “Catagory” “DataItem” (TrueorFalse as string)

a=( getINIsetting “D:\ emp\ ester.ini” “Catagory” “DataItem” == “true” )

One of many…

Keith Morrison

You can also do;

a = execute (getINISetting…)

for booleans.

QUOTING FROM MAXSCRIPT BOOK

INI files I/O

INI files are easier to manage through MaxScript because you will not need to worry about opening and closing files. All you will need to do is ask MaxScript to read or write the information you need and it will be written using the INI command.

The two commands used to manipulate INI files are getinisetting and setinisetting. They need the filename, the section, and the key. This is how an INI file looks:

[Section01]
key01 = value01
key02 = value02

For example, getinisetting (getdir #maxroot + “\3dsmax.ini”) “Render Dialog Position” “Dimension” returns the position and dimension of the render dialog box, which is saved to the INI file.

You can create INI files to store your script’s date. For example, setinisetting(getdir #plugcfg + “\sample.cfg”) “settings” “reload” “true” creates a new file and writes the specified data to it.

Sorry if this is offtopic. Just thought it would help

Page 2 / 2