[SOLVED] Playing with 2 dialogs [one main and one for editing variables]
-- Messing with \ and \\ -- [SOLVED] But another question at the bottom
Hi there, this is my first post here, and i'm a beginner in maxscript, and scripting in general.
I'm currently improving my script so it can store configuration file, and use them as variables.
I have several problem which i can't solve on my own, and, as a French young man, my english is not good enough to understand the all Maxscript Help File.
I'm Asking for help :)
So i learn there is scope things to access variables in different loop, and it's a bit hazy for me. I think It's on problem i have in my script, but first, i have a problem when edit my .ini file:
>> I must store a Network Path into my Ini File, but i just notice that the function "SetINISetting" simply ignore multiple backslash:
in my functions.ms file:
setINISetting theoutput "folders" "dossier_portes_ini" "\\\\Averty\\v\\Oskab\\scenes\\_portes\\" setINISetting theoutput "folders" "dossier_render_ini" "\\\\Averty\\v\\Oskab\\scenes\\__RENDER\\"
in my .ini file i get:
[folders] dossier_portes_ini=\\Averty\v\Oskab\scenes\_portes\ dossier_render_ini=\\Averty\v\Oskab\scenes\__RENDER\
But when I re-use my editvar rollout and manually type the good path,I get the good one... This is a mystery for me...
I need this function to work, because it's the defaults settings, overriding the one missing, or use as default if no modification are made.
Thanks in advance for reading me, and a thousand thanks for trying to help.
-- EDIT --
I'll try to be clear explaining this one !
First, i had only one roullout "main", opening when starting the script with everything in It, it worked well, but i like challenge and for further use, i wanted it to be editable.
So, now i have 3 files; main.ms, functions.ms and editvar.ms
main call editvar.ms by pressing a button, and when editvar close, it store all information into a temp.ini so i can access to my variables easily into main.ms
My problem is that when main start, it create a dropdownlist by parsing a folder, which can be modified by the second rollout.
since the dropdownlist is created when the first roullout is called, when i close my edit var, i don't find a way to update it (i tried "on close" but when i call it in the main script, it's gone since a long time and it does nothing)
So, for now, i close everything and launch the script again... not very handy !
Main:
http://my.jetscreenshot.com/8140/20130907-p6qh-26kb.jpg
EditVar:
http://my.jetscreenshot.com/8140/20130907-qazg-78kb.jpg
Thanks Again for helping me :)
[EDIT 2013/09/04]
-------------------------------------------
Some Handy Functions I use In this script:
1) LISTNG FILES: Create a list of files To put in a DropdownList / ListBox / MultiListBox: Arguments: Directory (path to folder) / Extension (ex: "max") / Extensionlength: number of character in Extension (ex: 3) / directorylengtplus = 1 for network path (UNC) or 2 for classic path (C:\\...) [ I use one Checkbox for It] / the dropdownlist: name of the object UI.
fn listingfiles directory extension extensionlength directorylenghtplus thedropdownlist = ( listeporte = getfiles (directory + "\*." + extension) /*Creating 2 empty arrays listetemp holds thefilename + extension liste holds filename without the extension.*/ liste = #() listetemp = #() for a = 1 to listeporte.count do ( directorylenght = directory.count listetemp [a] = Substring listeporte[a] (directorylenght +directorylenghtplus) 100 counttemp = listetemp [a].count liste [a] = Substring listetemp [a] 1 (counttemp - (extensionlength+1)) ) for a = 1 to liste.count do ( thedropdownlist.items = append thedropdownlist.items (liste[a] as string) ) )
2) Bdigit nb: Return a number value into a String with 4 digits:
fn bdigit nb = ( tostring = nb as string countstring = tostring.count if countstring == 4 then result = tostring if countstring == 3 then result = ("0" + tostring) if countstring == 2 then result = ("00" + tostring) if countstring == 1 then result = ("000" + tostring) return (result) )
Comments
And.. one More Problem !
Thanks for your good advises, i didn't use struct for now, but it's look very nice, and i surely use them into my next script :)
I've got a little problem, which i don't understand, maybe because it's 5am here, and i don't manage to find a solution.
It's quite funny because it's working in a 2 lines script but not in the real one.
When i was working on the script, i made my path point to my desktop in an absolute path, and the script worked well. But when i made the mzp, and made the include point to function.ms by using userscript...
when i try this:
the listener is parsing the entire file, so i assume he found it, but in my main script it crashed.
ps: it's working when I enter the all path in absolute of course, but it's not the point of creating a mzp-file to deploy on several computers.
...
You can't use line
include functions.ms
. Max not recognize this. Now is the time to place all your fn's in struct. And your problem will disappearbga
-Loosing It-
Tell me if i'm wrong, but when i use Struct to organize my functions.ms file, i will always have to include the function.ms file into my main.ms right?
I'm looking all over the web to find examples, but i found contradictory information. example: "don"t use include but file fileIn" Or "Omg you're using Filein, just use include !"
I'm confused
Here: http://neiltech.wordpress.com/2012/11/16/how-to-create-a-class-in-maxscr...
>> I understand the goal of using Struct, because we have 2 functions in the struct MyClass , executed by calling one Struct "MyClass"
But in my case, functions.ms is just a bunch of functions, and using Struct could organize them by type (Ini things / main script), but i don't understand the point.
Here's my functions:
...
No no. Place all fn's from "function.ms" inside struct. But struct neet to be placed in main.ms. Forget about fileIn and include fn's.
bga
Can't find editText.text
Hi there, i'm stuck again.
I put all my function into my main script, into one sturct called "Myfunctions"
I initialize it before i declare my 2 rollouts.
The functions used by the main works just fine, but inside the settings rollout, the functions using the ".text" parameters of the edittext UI is not found by maxscript, and so i can't load or save new Ini...
I give you a piece of my code as exemple, into EDITVAR ROLLOUT (L103),I have several edittext exmple: "In1"
Into my save and load ini functions (L6 & L15) i use the .text parameters to get or assign a stringvalue, but max can"t find the .text parameters now. Is this a scope problem? I thought my functions are available anywhere in my code by using a global initialization of the struct...
I tried to get or assign a value directly from the rollout, not calling a pre-build function, it worked.
So my question is how can i do to make the.text parameters available into my function?
Thanks in advance,
Florent
...
This is the corrected code. I did not tested, but you can.
Read my "upercase" comments.
Also look how I initialized struct.
bga
I think i'm getting in but
Hi there, sorry for the late response, i didn't have time too look at the code yesterday. Youre code is working great but in my case (i didn't tell you all so you were unable to know, but i have about 70 Edittext or check box to load, save or clear.
At the first time, i wanted to save, load or clear all of them by calling one short function for each action into my rollouts
It work when adding the ctrl parameters, but i have to call the function 70 times. Although, i have different type, check-boxes ant EditText, so i cant use the same syntax when i want to get the.text value or the TriState. It's the same problem when i load or save, i have different group in the Ini, different types of values, etc.
I Give you an example with the clear function:
>>With the struct and calling 70 times:
I don't which solution is the more efficient, because in 3 case (loading / saving and clear) each time i want to do one action i call one function In struct 70 times
In that case, i can't call the fucntion insode another rollout thant the one where the fucntion is declare... not handy, but i can cear all of my parameters in one line into mu editvar Roullout:
I tried several thing (don't forget i'm starting, i'm sure it will look strange for you)
>> print the edittext directly and save it to a .ini: : i get "EditTextControl:"
>> but i heard that i have to avoid the execute function for "converting" a string to get the variable with the same name:
exemple:
It can loop for X Variable, but it's very slow, and dirty... and i have still other Edittext who can"t enter in this loop...
I tried a few things, but except crashing the script it's not helpfull.
Can i declare Struct int Struct ? so i could store all my parameters and execute them 70 time by calling another struct parameter ?
exemple: Struct theparams (in1, in2 ... in40,checkbox1...)
So i can call cleareditvar for each params in the same time...
I'm Trying, I didn't count the Google researches about scripting or optimize in the way I want, there's no many article about struct...
Thanks For your time, at worst i can copy/paste the all dirty code into my script, i know it will work, but i'll not be satisfied about it.
...
I not have time right now to read your post but see this example
"main" is your rollout and you can simply loop and affect only edittex controls like this
bga
...
You can test with this example
try this in the listener
bga
...
Is this easy or not
;)
bga