saving array down to disk

Become a member of the CGSociety

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

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  07 July 2005
saving array down to disk

Hi.

I need to save an array of booleans in an external file that would let me open the max scene and run the script using the array directly without having to fill it first with the values (because of the time this task takes to complete) but by just loading the file containing the array as i would with a bitmap file.

if somebody could tell how to save the array for future use (and how to load it afterwards) i would be very grateful.

thanks.
 
  07 July 2005
Hi Grenadine,


you can save variables (including arrays) inside of MAX files by making them persistent does this help you? have a read in the MSX help.

J.
__________________
www.joshuanewman.net
 
  07 July 2005
array saved with the whole file a bit weighty

Hi j_man

Thanks for the piece of advice.
Gotta try but seems like a solution.
However an external file would be more handy because it would enable me to load in my max file a specified version of the array among several coming from different max scenes.
(by keeping a library of my different arrays on disk, instead of a bunch of heavy max files)

Heard it was possible but couldn't make it from the Mxs examples.

Thanks J_man i'm sure it'll make it for now.
 
  07 July 2005
Ok,

well basically you need to create a function to save your txt file:


myarr=#(1,2,3,4,5,6,7,8,9,0)
f=createfile "d:\\temp\\output.txt" -- this is the output directory for the text file
for s in myarr do format ((s as string)+",") to:f
close f


and then you need to create a function to re-construct the data from the text file when you load it again.
I just posted something else along these methods:


newarr =#()
f=openfile "d:\\temp\\output.txt"
while not eof f do
(
n =readdelimitedstring f ","
append newarr n
)
format "\t%\n" n


Cheers,

J.
__________________
www.joshuanewman.net
 
  07 July 2005
Works perfectly. this is exactly what i needed.
Thank you J, both of your tips helped a lot.



Cheers
 
  07 July 2005
You're welcome! glad to help.


Josh.
__________________
www.joshuanewman.net
 
  07 July 2005
newarr =#()
f=openfile "d:\\temp\\output.txt"
while not eof f do
(
append newarr (readvalue f)
)
format "\t%\n" n


This method might be more appropriate in your case since it will read the values back in as integers just like you had in the original array.

- Martijn
 
  07 July 2005
good point Martijn, I'd overlooked that!


J.
__________________
www.joshuanewman.net
 
  07 July 2005
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:01 PM.


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