How permanently save a text written in an EditText and added in a ListBox?
As written in the title, how permanently save a text written in an EditText and added in a ListBox? (when I reopen the rollout, the text written before is present in the listbox)
Below is my example:
-----------------------------------------------------------------
rollout t "test" ( listbox l1 "" items:#() edittext ed1 "" button b "Insert Name in ListBox" button s "Save Text in Listbox" on b pressed do ( if txt != "" do ( l1.items = append l1.items (ed1.text as string) l1.selection = l1.items.count ed1.text = "" ) ) on s pressed do ( -- How save the text??? ) ) createdialog t
------------------------------------------------------------
Waiting for help, a greeting from
Michele
Question off topic:
how to write script code in discussions?
Comments
For Anubis@: You have another
For Anubis@:
You have another solution to resolve this problem??? it's nice to know if there is another way.... :) :)
printAllElements is nessecary
printAllElements is nessecary to print out arrays with more than n (15 or so) items.
you might have noticed before that when you print an array to the listener the ..) at the end, thats what has been written to the reg too so it crashed. with printAllElements every single element is written; you can either en/disable it globally or like i did use it to "encase" an expression
furthermore in the first codeblock you again forgot the lineBreak ( ; )
..execute val ; if classOf..
happy it works
Raphael Steves
I am happy for your great
I am happy for your great help you gave me Insanto!!!
I completed the script part with the ability to delete the text from listbox...
Thanks Insanto!!! This update
Thanks Insanto!!! This update works fine:) :)
Today during my tests I've written:
but I did not understand that this was necessary also:
while I was writing:
In fact the script was not working...
Thank you again Insanto! :)
P.S: I can explain the part that I skip to write?
( /* automated loading and
this one now includes a working example of how to store/restore items in a listbox between sessions.
it only deals with that part tho
obviously you also want a description going with the ior value so i'd suggest some seperator you can later take the strings appart by with the filterstring function, a semicolon comes to mind as people most probably wont include that in the name.
thing with storing and restoring strings is the interpretation. i made a little function to help with that (converts an array to a string containing verbatim signed array items)
using that you can store/restore any stringArray savely to ini or reg without having to worry about string literals
Raphael Steves
Hello Anubis and Insanto. Now
Hello Anubis and Insanto.
Now explain better what I want;
I am creating a script where there is a text list (listbox) with names and values relate to the IOR (index of Reflection). Now the list is very long and I am dividing into categories (metal, liquid, fabric etc.). While I was writing the list (to see in the listbox) I thought: Is possible update the list? If I want to add a new material IOR how to do? It 'like to create presets: I select the category "Metal" and I add a new name text in this category...
Now, with the example shown at start post, I could write the text and add it in ListBox. But when I closed (and reopen) rollut, the text disappeared. I decided to create a save button to this function...But how to save the text permanently?
Example Insanto is good, but I find it difficult to arrange the array in the script, while Anubis, I must find the text the next opening script... I hope that I explained :) :)
I have ListBox whit IOR value
I have the spinner to adjust IOR in the material (or something like)
I'll update the listbox with new IOR text
....
Hi and thanks again from Michele :)
Hi Insanto, do not understand
Hi Insanto,
do not understand me wrong. Access to registry from Max is a good feature, but personally I see sense to use it only if I need to interact with Windows environment, so I prefer ini files ;-)
P.S. - Here I add a simple example for Michele to get started with ini files.
Cheers
my recent MAXScripts RSS (archive here)
because the registry is
because the registry is independent of the max version and user config and i dont mess with anything i always create new ones. ini files are all good n fine but for my taste to mediocre :P
Raphael Steves
I really wonder why the
I really wonder why the peoples mess with registry keys for that purpose... Never mind...
Hi Michele,
I'm not sure what exactly you ask. If you need to store the items in memory (for the active session only), then you need only a variable. Example:
And if you need to keep this data for the next sessions, just spend a little time to study read/write INI files ;-)
my recent MAXScripts RSS (archive here)
Thanks Again. Today try with
Thanks Again. Today try with your advice :)
And yes, "The night produce advice"