Home › Forums › General › Programming › saving/loading data to a file
- This topic has 47 replies, 8 voices, and was last updated 7 years, 9 months ago by goodweather.
-
AuthorPosts
-
June 14, 2013 at 4:08 am #9922
Thanks so much atom. It’s all working now. Hey I got that parcel out today~!
Monstrum Media | Music, Sound & Software Design, Chicago / San Francisco listen
June 15, 2013 at 4:19 am #9964So my only question now is after exporting the panel as a restricted instance, When I open the app or exe I get prompted to save a file and open a file at launch. If I cancel ctrlr locks up/crashes on osx.. i dont think it crashes on windows.
I’m not getting this when I open the bpanelz file in ctrlr. I don’t get prompted to save or load until I hit the button where the calls to those scripts are made from… as it should function.
I have both “Mute” and “Don’t Send” checked for “modulator does not output any MIDI..” and “Don’t send this modulator during snapshots”.. I’m actually at a loss for anything to put in the scripts to prevent them from being fired unless the button is pressed that wouldn’t stop it from working when the button IS pressed..
How do I prevent these save/load to file buttons from triggering their scripts when the panel is opened as a standalone instance?
Monstrum Media | Music, Sound & Software Design, Chicago / San Francisco listen
June 11, 2016 at 5:13 pm #69420configFile = File(File("").getSpecialLocation(File.userHomeDirectory):getChildFile(String("myConfig.ini")))
Returns a ERROR: [string “_runtime”]:1: attempt to call field ‘getSpecialLocation’ (a nil value) in the console.
June 12, 2016 at 10:38 am #69422This worked for me maybe it is of some use for you:
currentRecallDir = File.getSpecialLocation(File.globalApplicationsDirectory):getFullPathName() patchToWrite=MemoryBlock(RecallPatchData) recallToWrite = File(currentRecallDir.."/".."recallPatch.rec") recallToWrite:create() recallToWrite:replaceWithData(patchToWrite)
June 16, 2016 at 4:29 pm #69438I’m working on the same panel as Kunka, and I’ve come up against a bit of a road block.
I have a large table of strings (previously declared and populated)
prgName[1]=”: Program 1″
prgName[2]=”: Program 2″
prgName[3]=”: Program 3″
prgName[4]=”: Program 4″
prgName[5]=”: Program 5″
…
prgName[4223]=”: ”This is used to populate a uiListBox and it works well.
What I want to do is save the prgName table to a file so I don’t have to do 4223 dumps every time I open the panel, but can instead just load it from disk, and update small sections of it by dumping single objects.
I’m trying to use the saveContentAsData method from the demo panel but get this error.
At line [-1]: [C]
Error message: std::exception: ‘unable to make cast’
I’m sure it’s because I’m trying to convert the table of strings to binary data with
mbList = MemoryBlock (prgName)
Anyone know how I can convert the table of strings into something I can save and later reload into the same table?
The Puppeteer
http://godlike.com.auJune 16, 2016 at 9:35 pm #69442To save 256 patchnames from uiLabels to disk I used this code. Maybe you could use some parts of it:
for z=1,256 do PatchName=L(panel:getModulatorWithProperty("modulatorCustomIndex",z):getComponent():getProperty("uiLabelText")) char1 =string.byte(PatchName, 1) char2 =string.byte(PatchName, 2) char3 =string.byte(PatchName, 3) char4 =string.byte(PatchName, 4) char5 =string.byte(PatchName, 5) char6 =string.byte(PatchName, 6) char7 =string.byte(PatchName, 7) char8 =string.byte(PatchName, 8) char9 =string.byte(PatchName, 9) char10=string.byte(PatchName,10) -- Check for empty chars and put each char value in PatchNameTab1, PatchNameTab2.. PatchNameTab256 _G["PatchNameTab"..z]={} if char1 == nil then char1 =32 end _G["PatchNameTab"..z][1] =string.format("%.2x", char1) if char2 == nil then char2 =32 end _G["PatchNameTab"..z][2] =string.format("%.2x", char2) if char3 == nil then char3 =32 end _G["PatchNameTab"..z][3] =string.format("%.2x", char3) if char4 == nil then char4 =32 end _G["PatchNameTab"..z][4] =string.format("%.2x", char4) if char5 == nil then char5 =32 end _G["PatchNameTab"..z][5] =string.format("%.2x", char5) if char6 == nil then char6 =32 end _G["PatchNameTab"..z][6] =string.format("%.2x", char6) if char7 == nil then char7 =32 end _G["PatchNameTab"..z][7] =string.format("%.2x", char7) if char8 == nil then char8 =32 end _G["PatchNameTab"..z][8] =string.format("%.2x", char8) if char9 == nil then char9 =32 end _G["PatchNameTab"..z][9] =string.format("%.2x", char9) if char10== nil then char10=32 end _G["PatchNameTab"..z][10]=string.format("%.2x",char10) end -- concatenate all Tablevalues of each Table for p=1,256 do _G["PatchNameSt"..p]=table.concat(_G["PatchNameTab"..p]," ",1,10) end for p=1,256 do AllPNames=AllPNames.." ".._G["PatchNameSt"..p] end dataToWrite=MemoryBlock(AllPNames)
June 17, 2016 at 12:15 am #69443Thanks,
Looking at this and the MiniAk panel, I think I may need to convert it all to text, save that, and then deceipher the text to rebuild the table.
Was hoping to avoid that and keep the structure in place in the file.
The Puppeteer
http://godlike.com.auJune 19, 2016 at 12:40 pm #69452Hi guys, hope you are well 🙂
It was good you explained what you wanted to achieve, Puppeteer…
On my Pro 2 panel, I have same kind of stuff but I keep everything separated:- Factory banks are just tables of names in the panel. THey are declared as
F5Bank = {"SquareBass", "Cascades", "Pro Soloist", ... }
When you turn the Bank and Program buttons, you can navigate in the Factory bank programs. When you decide to Load, it is taken from the synth. - Disk banks are on the PC disk. They are fully loaded on user request in a MB. The corresponding listbox is ppopulated with names that are extracted with getRange
- user banks are on the synth with also a corresponding bank on the PC. Similar as Disk banks but interaction with the synth on Load/Save
As Ctrlr is meant to be used with a synth, I think it is important to keep things separated and try to avoid loading everything.
I came to that conclusion when I put all Factory bank data in memory blocks that I was loading on Panel init. Starting the panel took several minutes… and thus was not very user friendly. So, I keep separated and load on request.
I do all the interactions with memory blocks (easy to replace/append/read piece by piece then write on disk when needed). - Factory banks are just tables of names in the panel. THey are declared as
-
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.