If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
Save / Load RubyObject to File
8 posts
• Page 1 of 1
Save / Load RubyObject to File
Hello!
I did some simple save and load modules for ruby objects.
My Problem was that i got realy big objects and this module kees it easier to save object to a binary file.
WARNING: Binay files are no TEXT Files!!! - Never open and save them with a text Editor!!!
If you want to save a text to the object use an object-Array.
Regards
C.Hackl
I did some simple save and load modules for ruby objects.
My Problem was that i got realy big objects and this module kees it easier to save object to a binary file.
WARNING: Binay files are no TEXT Files!!! - Never open and save them with a text Editor!!!
If you want to save a text to the object use an object-Array.
Regards
C.Hackl
- Attachments
-
- save_load ruby.fsm
- Save & Load Ruby Objects to Files
- (2.71 KiB) Downloaded 1241 times
Last edited by chackl on Wed Oct 02, 2013 7:01 am, edited 1 time in total.
100% accuracy is the guarantee to your success. The value alters if you combine it with musical creativity.
-
chackl - Posts: 233
- Joined: Tue Aug 17, 2010 8:46 pm
- Location: Austria / Salzburg
Re: Save / Load RubyObject
Thanks for sharing..... .
BV MUSIC SYDNEY AUSTRALIA..Songwriting and Software development
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
- billv
- Posts: 1157
- Joined: Tue Aug 31, 2010 3:34 pm
- Location: Australia
Re: Save / Load RubyObject
u'r welcome
Please NOTE:
Custom classes Need some extras to get it working:
http://ruby-doc.org/core-2.0.0/Marshal.html
Not working with Bitmap objects - needs a Workaround. - I'll be on this.
Regards
Please NOTE:
Custom classes Need some extras to get it working:
http://ruby-doc.org/core-2.0.0/Marshal.html
Not working with Bitmap objects - needs a Workaround. - I'll be on this.
Regards
100% accuracy is the guarantee to your success. The value alters if you combine it with musical creativity.
-
chackl - Posts: 233
- Joined: Tue Aug 17, 2010 8:46 pm
- Location: Austria / Salzburg
Re: Save / Load RubyObject
chackl wrote:Custom classes Need some extras
Yeh i got caught out....trying to make it work...went inside module
and saw 'marshal'....who's that..??...never heard of him...
Had planned to try my first 'class' maybe next week....
In over my head again
chackl wrote:I'll be on this.
thanks...i can watch and learn... .
BV MUSIC SYDNEY AUSTRALIA..Songwriting and Software development
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
- billv
- Posts: 1157
- Joined: Tue Aug 31, 2010 3:34 pm
- Location: Australia
Re: Save / Load RubyObject to File
'Marshal' is a special class that used for 'serialising' objects - taking a Ruby object and converting it into a stream of binary numbers, so that the object can be saved and then re-created when loaded.
But it only works for Ruby classes that have special methods defined to say how the conversion should be done. Most of the standard Ruby classes have the 'marshal' methods, but many FS specific classes don't.
Behind the scenes, the FS 'loadState' and 'saveState' methods, and storing the input/output values, will be using 'Marshal' - which is why there are some objects (e.g. bitmaps, graphics paths, brushes) that can't be stored between sessions.
But it only works for Ruby classes that have special methods defined to say how the conversion should be done. Most of the standard Ruby classes have the 'marshal' methods, but many FS specific classes don't.
Behind the scenes, the FS 'loadState' and 'saveState' methods, and storing the input/output values, will be using 'Marshal' - which is why there are some objects (e.g. bitmaps, graphics paths, brushes) that can't be stored between sessions.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
Don't stagnate, mutate to create!
-
trogluddite - Posts: 1730
- Joined: Fri Oct 22, 2010 12:46 am
- Location: Yorkshire, UK
Re: Save / Load RubyObject to File
i think it will be easy to restore Brushes and so on.... I'm just saving the input variables for Brush class and calculate it again afer load.
For Bitmaps.... difficult. I'm working now with the FloStone primitive get pixel and save it to a 2 dimensional color array within ruby. And this is slow.... Getting back a bitmap is also tricky - Also a Primitive again View to bitmap and i draw every pixel as a recktangle in ruby (But this is much faster)
If you use it you have to get all classes ready for it otherwise there will be loads of lost data.
Regards
For Bitmaps.... difficult. I'm working now with the FloStone primitive get pixel and save it to a 2 dimensional color array within ruby. And this is slow.... Getting back a bitmap is also tricky - Also a Primitive again View to bitmap and i draw every pixel as a recktangle in ruby (But this is much faster)
If you use it you have to get all classes ready for it otherwise there will be loads of lost data.
Regards
100% accuracy is the guarantee to your success. The value alters if you combine it with musical creativity.
-
chackl - Posts: 233
- Joined: Tue Aug 17, 2010 8:46 pm
- Location: Austria / Salzburg
Re: Save / Load RubyObject to File
Is there someone out there who knows how to 'capture' the 'ZeroDivisionError' in the Flowstone Ruby interpreter and rectify the code below?
erum
- imi90
- Posts: 1
- Joined: Tue Nov 05, 2013 12:00 pm
Re: Save / Load RubyObject to File
imi90 wrote:Is there someone out there who knows how to 'capture' the 'ZeroDivisionError' in the Flowstone Ruby interpreter and rectify the code below?
Could you please open a new topic if it is not belonging to save/load Ruby Objects?
Thanks
100% accuracy is the guarantee to your success. The value alters if you combine it with musical creativity.
-
chackl - Posts: 233
- Joined: Tue Aug 17, 2010 8:46 pm
- Location: Austria / Salzburg
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 15 guests