Cabbage Logo
Back to Cabbage Site

Changing file button Directory

Is there a way to change a file button directory?I am trying
chnset "Bounce", ""
and
cabbageSet 1, "Bounce", sprintfk("%s", "")

but it doesn’t seem to take. my code is below. this is basically instancing a recorder instr that bounces output to file. I can get it to work once but the directory never changes so it doesn’t work on subsequent tries. I know I’ve gotten this to work before but I’m wondering if something changed?

    gSdir chnget "Bounce"
    kstop chnget "Stop"
    kstrlen strlenk gSdir
    if (changed:k(gSdir)== 1) && (kstrlen > 0) then          ;check that dir was changed from null (''')
        event "i", 100, 0, 500000
    endif
    if kstop==1 then        
            turnoff2 100, 0, 0
            cabbageSet 1, "Bounce", sprintfk("%s", "")
            chnset "Bounce", ""
        endif

Set file() to empty straight after you access the file. This will cause changed to trigger again even if the user selects the same file. :+1:

Thanks Rory - not totally sure what you mean. “Bounce” is set to “directory” mode so when the directory changes AND the length of the directory string is > 0, it begins recording. I thought I could make the directory string empty after the recording starts. I don’t see a “file()” attribute for the filebutton though…

yes, that’s what I was trying to suggest, albeit not as succinctly. file() might not be documented, but it should work for the filebutton.

1 Like

Ahhh - ok I got it I think!
cabbageSet "Bounce", "file(\"\")"

I didn’t see file() in the docs for filebutton but maybe I didn’t look hard enough…

That’s it. Check this example here. ‘open’ is a filebutton.