storing info to file

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Display Modes
  12 December 2011
storing info to file

Not quite sure why this does not work.....

When the user selects from the jobdown it should save the selected item to the rootenode using the setAppData but it doesn't do anything. I'm assuming it has to do with the part where it says

setappdata rootnode (data_JobName as integer) (with printallelements on ini_JobName as string)
)

the variable ini_JobName is not an array it is just string. so printallelements does not work then.


rollout rlinfo "Info"
(
	local data_Project = 5004
	local data_JobName = 6052
	
	fn loadInfo =
	(
		projectNaming = try (execute (getappdata rootnode data_Project)) catch(#())
		jobNaming = try (execute (getappdata rootnode data_JobName)) catch(#()) 	
		
		print projectNaming
		print jobNaming
	)
	
	fn saveInfo =
	(
		ini_Project = if rlinfo.dlProject.selected == undefined then "" else rlinfo.dlProject.selected
		setappdata rootnode (data_Project as integer) (with printallelements on ini_Project as string)
		
		ini_JobName = if rlinfo.dJobName.selected == undefined then "" else rlinfo.dJobName.selected
		setappdata rootnode (data_JobName as integer) (with printallelements on ini_JobName as string)
	)
	
	dropdownlist dlProject "" items:#("cool","nice","donuts")
	dropdownlist dJobName "" items:#("old","new","shitty")
	
	button btnPrint "Print"
	
	on btnPrint pressed do
	(
		loadInfo()
	)
	
	on dlProject selected idx do
	(
		saveInfo()
	)
	
	on ini_JobName selected idx do
	(
		saveInfo()
	)
	
	on rlInfo open do
	(
		print (dlProject.selected)
	)
)
createDialog rlInfo 150 150
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com

Last edited by JokerMartini : 12 December 2011 at 06:29 PM.
 
  12 December 2011
There is no need for the execute. Instead you should use if != undefined do.


rollout rlinfo "Info"
(
	local data_Project = 5004
	local data_JobName = 6052
	
	fn loadInfo =
	(
		projectNaming = getappdata rootnode data_Project
		jobNaming = getappdata rootnode data_JobName
		
		print projectNaming
		print jobNaming
	)
	
	fn saveInfo =
	(
		ini_Project = if rlinfo.dlProject.selected == undefined then "" else rlinfo.dlProject.selected
		setappdata rootnode (data_Project as integer) (with printallelements on ini_Project as string)
		
		ini_JobName = if rlinfo.dJobName.selected == undefined then "" else rlinfo.dJobName.selected
		setappdata rootnode (data_JobName as integer) (with printallelements on ini_JobName as string)
	)
	
	dropdownlist dlProject "" items:#("cool","nice","donuts")
	dropdownlist dJobName "" items:#("old","new","shitty")
	
	button btnPrint "Print"
	
	on btnPrint pressed do
	(
		loadInfo()
	)
	
	on dlProject selected idx do
	(
		saveInfo()
	)
	
	on ini_JobName selected idx do
	(
		saveInfo()
	)
	
	on rlInfo open do
	(
		print (dlProject.selected)
	)
)
createDialog rlInfo 150 150


A word of warning - setAppData and getAppData are good ways of storing and saving info quickly and easily, but they can very easily be overwritten by other scripts using the same values. If you do use them I'd recommend using much more than 4 digits just to be safe.

Scripted custom attributes saved to the rootNode are also a good way to go as they can be accessed with a post merge callback using the xRef Scene system.
 
  12 December 2011
Hey Tim

Thanks for the quick response.
I initially was using execute to turn the stored string back into an array. But this time around I was just trying to save a stand alone string and was overlooking that part of it.

Thanks for the help and explanation of things.
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
  12 December 2011
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 10:40 AM.


Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.