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
Help needed with .exe file issues.
13 posts
• Page 2 of 2 • 1, 2
Re: Help needed with .exe file issues.
Spogg wrote:tulamide wrote:When you use loadState and saveState in Ruby, it makes use of the Marshal module. You can use it as well. It generates a binary string, which you can simply save with the File class/IO class and later load in.
Usage:
- Code: Select all
result = Marshal.dump([myArray, myVar, "some string", in_short_any_object])
some_array, some_var, some_string, some_obj = Marshal.load(result)
Ooh that’s interesting!
So if I understand correctly, Tim could stay completely in the Ruby world…?
If that's a requirement, then yes. But you can use this also to save everything that you are able to input to Ruby. Marshalling is more than just saving some numbers, though. It makes binaries of every object fed to it, so that it can be restored exactly as it was. For that it scans through all references to objects, to "paint the whole picture". For example, if you have an array filled with arrays of arrays, all of them will be saved to the binary string. Imagine it like a DAW snapshot - it will load all plugins, set them all to the last state, load the mixer settings, and so on.
But if understood, it's a very useful instrument of restoring the state of objects and therefore saving data.
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Help needed with .exe file issues.
@tulamide
That’s remarkable, to say the least!
Although I’ll never use it myself, I find that really impressive.
That’s remarkable, to say the least!
Although I’ll never use it myself, I find that really impressive.
-
Spogg - Posts: 3358
- Joined: Thu Nov 20, 2014 4:24 pm
- Location: Birmingham, England
Re: Help needed with .exe file issues.
Hello tulamide, I've put together code which works (without using Marshal) but it involves a lot of conversion to strings etc.
I've tried to implement Marshal as you suggest, but cannot get any of it to work!
I have created a Class Button, which includes data about what I want to be drawn, how to respond to clicks etc.
I make a collection of these in an array, @buttons. This all works
I tried to dump @buttons with
File.open("D:\FILES - LIVE\KEYBOARD\KS WIP\K3M","w+") do |f|
@save=Marshal.dump(@buttons,f)
and restoring it by triggering an input in def events
if i==9
#Marshal try
@buttons=Marshal.load(@save)
end
As I understand it, File.open should create a file if the name doesn't exist, but I'm not even getting a file created, so the dump method does nothing, and of course there's nothing for the load to load.
I think, in theory, the Marshal method would be better and more reliable, so I'd apprecate you pointing me in the right direction!
Tim
I've tried to implement Marshal as you suggest, but cannot get any of it to work!
I have created a Class Button, which includes data about what I want to be drawn, how to respond to clicks etc.
I make a collection of these in an array, @buttons. This all works
I tried to dump @buttons with
File.open("D:\FILES - LIVE\KEYBOARD\KS WIP\K3M","w+") do |f|
@save=Marshal.dump(@buttons,f)
and restoring it by triggering an input in def events
if i==9
#Marshal try
@buttons=Marshal.load(@save)
end
As I understand it, File.open should create a file if the name doesn't exist, but I'm not even getting a file created, so the dump method does nothing, and of course there's nothing for the load to load.
I think, in theory, the Marshal method would be better and more reliable, so I'd apprecate you pointing me in the right direction!
Tim
- TimC
- Posts: 7
- Joined: Sat Dec 24, 2022 12:24 pm
13 posts
• Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 75 guests