Text input widget not visible if default string is blank

This:

;control text "Some text" string "" "xyz"

displays a text input widget on the form.

This, with the default string set to blank:

;control text "Some text" string "" ""

doesn’t display at all.

Is that a bug, am I doing something wrong, or is there some logic to it? If you want the user to enter a string of their choice, why would you enter something for them? It’s always going to be wrong.

You are one parameter short. Audacity will read that as:
“” which is one string but there needs to be two parameters separated by a space.
If you add a space at the end it will work.

Alternatively you could write:

;control text "Some text" string "<space>" "<space>"

or

;control text "Some text" string "" "" ""

or

;control text "Some text" string<space><space><space>

The correct syntax is:

;control variable-name "text-left" string "text-right" "initial-string"

(note that there is one space between each argument.)
See here: Missing features - Audacity Support

Now I’m confused. Does Audacity assume there must be something between double quotes, and therefore consume the other two?

Don’t be confused :wink: just use if you want two empty strings rather than

(which is the one that doesn’t work).

I can see your intention with
you are wanting to write:
but with so many escaped and non-escaped characters flying around it is difficult to work out exactly how Audacity will interpret

My assumption is that Audacity is interpreting
as one string.
This is held out by the following:

;control text "Some text" string """1""" "2"

All of the “extra” double quote pairs around the “1” are stripped out and it behaves the same as:

;control text "Some text" string "1" "2"

It’s a bug in the “;control …” string parser of the Audacity Nyquist interface. Empty strings (two double-quotes in a row with no other character in-between) are not recognized as strings and silently removed from the token list.

audacity/src/effects/nyquist/Nyquist.cpp, function EffectNyquist::Parse, lines 195…197

   if (tok != wxT("")) {
      tokens.Add(tok);
   }

This means that “” is ignored and if you want a blank string then you must write two double-quotes with minimum one space character in-between.

  • edgar

Thanks for that. The workarounds above seem to work ok, although it makes the code a bit obscure if you don’t know.