Support

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.

For general discussion related FlowStone

Re: Help needed with .exe file issues.

Postby tulamide » Wed Mar 08, 2023 12:15 pm

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.

Postby Spogg » Thu Mar 09, 2023 7:44 am

@tulamide
That’s remarkable, to say the least! :o
Although I’ll never use it myself, I find that really impressive.
User avatar
Spogg
 
Posts: 3358
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England

Re: Help needed with .exe file issues.

Postby TimC » Wed Mar 22, 2023 3:21 pm

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
TimC
 
Posts: 7
Joined: Sat Dec 24, 2022 12:24 pm

Previous

Return to General

Who is online

Users browsing this forum: No registered users and 100 guests