Cabbage Logo
Back to Cabbage Site

What is the textbox example supposed to do? Texteditor/textbox questions

My endgoal is to have a box in the GUI into which the user can type csound code, and then press a “compile” button and have it compiled on-the-fly with compileorc.

This led me to checking out the texteditor / textbox widgets but I am highly confused. First of all, there’s no textbox entry in the docs, although there is an example under File>Examples>Widgets>textbox. I don’t understand what this example is supposed to be doing. Is Csound somehow receiving the text I type as a string? Is it being written to the text file? I can edit the text in the box, but I can’t add a newline by pressing enter, Ctrl+Enter, Shift+Enter, or Alt+Enter (I’m using Windows).

The docs entry for texteditor mentioned multiline vs. singleline mode but there is no information on how to to set this mode. I do see how the up/down buttons work in the texteditor example to scroll through the previous strings. I suppose one could use this functionality to rig Csound to recieve the code one line at a time, each time in a new string variable, and concatenate them to create the file, but this wouldn’t be very helpful if I wanted to go back in and change a previous line…

I already have created some very useful standalones that do what I want using a textfile: I edit the textfile in notepad while the program is running, and when I press the compile button, compileorc is called to read the text file. This works great, its just I don’t want to have to use notepad. I want to be able to edit the code right in the GUI window.

Actually the most useful thing would be to have the multiline text that I enter into the widget get saved as a text file, and then immediately compiled with compile orc. That way the code I write would get saved.

Another confusing thing about the texteditor docs is that the example makes use of a file() identifier, but this identifier isn’t mentioned or explained in the list of identifiers.

file() will let you load a particular file to the text editor on startup. And yes, the docs do need some work :slightly_frowning_face:

I’ve attached an example that will let you do what you want, but I can’t get the compileorc bit to work, even though it seems to be passing a valid string. You need to press Cmd+Enter to send the entire string.

compileOrc.csd (660 Bytes)

Let me know if you get this to work. I can’t see why compileorc is not working, I’m not even getting a compile value printed?

Your example works, you just need to use compilestr to do it that way. compileorc expects to receive a the name or path of a text file.

Thanks for the help!

Thanks for pointing the fix :wink: