I’m trying to select a file name and save or load files on a single filebutton
push - one button to save and one to load a file. Like the standard “Save As” or “Open” buttons.
I can use filebutton mode("save")...
to select or type in a file name for saving and filebutton mode("file")...
to select a file for loading. Then I can use chnget
and changed
or changed2
to trigger saving or loading events when the file names have changed. So this works fine when I try so save or load a file with a different name from the previous. But this method doesn’t work if I try to re-load or overwrite a file with the same name as previously obtained by chnget
.
Of course, filebutton
sends a string to the associated channel and not a 0/1 state as a button
does, so just pushing filebutton
can’t be used as a trigger. I though maybe a way around could be to change the file
property of filebutton
to some never used or empty string after changed
has been triggered. That way changed
would be ready to re-trigger when a “new name” is set.
However, it seems that I cannot do this:
chnset "file(\"any_name\")", "identchannel_name"
,
where
identchannel("identchannel_name")
is used with filebutton mode("file")...
or filebutton mode("save")...
In summary I have two questions:
(1) is there a way to use a single button to trigger loading/reloading OR saving/overwriting files
(2) is there a bug preventing to set file
property of filebutton
or am I doing something wrong?
I hope this description can be understood and I’ll be grateful for any ideas and lessons
Cabbage: 2.3.38 on MacOS 10.12.6