, return "cancel" string?

Renoise 3.1.1 x64 W10 x64:

I think there is a small problem with the following case of aplication:

– Opens a modal dialog to query an existing directory from the user.
-> [valid path or empty string]

There is no way to return nil or a boolean, or string “Cancel” to identify if the user presses the “Cancel” button.

The specific problem is that, apparently the return of an empty string (""), returns the path C:/, a valid path. The issue is that some form of being able to continue with the function without resorting to the empty string is necessary. What happens is that if you use the empty string to continue with the function, the “Accept” button will do nothing, if you use the empty string as a condition to continue with the function (if path == “” then …)

The expected thing would be, to return

  1. non-empty string or empty string (both)
  2. nil …or “cancel” string.

That is, it is not possible to use the empty string for the Cancel button. If so, the OK button will not be able to take the empty string as a possible route. It forces the user to change the route in the pop-up window, when it should not be like that. C: / is also a valid path to save folders.

1 Like

Not sure I get it. The function returns an empty string when the user pressed cancel, so you can identify already if the user cancelled the dialog.

1 Like

I think that, if the user does not change the path in the window, simply click on open the dialog and then “Accept”, returns an empty string, which by default takes “C: /” (which is to save on this computer). Then, you need another way to alert the function when you press the cancel button.

To test it open this dialog box to determine the path and simply press the “Accept” button without changing the path. If you print in the terminal it will return an empty string, that is, nothing.

local function mpt()
  print("prompt:",prompt)  --??? ... prompt = a empty string, pressing Accept

That is, by clicking “Accept”, should never return an empty string, should always return a valid route.

i like “false” btw. Best comment ever.

It can’t, if you for example select the “Libraries” folder or “My Computer” in the dialog.

But there indeed is a little quirk on Windows 8 (that’s what you’re using, right?) in the Windows directory prompt: It should return “C: /”, when initially the “C: /” drive is selected. Will fix that.

Top part of Raul’s initial post:

I think I’m using the latest updated version of Windows 10 x64 (1809, version 17763.437).

Maybe it’s a specific case of this operating system and I think the operating system works the way it should. That is, if the user opens the dialog box and clicks “OK” and does nothing else, the function returns an empty string, and in this case, Windows 10 will take C: /, because the user has not changed the path .

Then the empty string does not cover all cases to use it as an “Cancel” indicator.

As far as I know there are 4 possible cases:

  1. “Cancel”. (work ok)

  2. “Accept” with an invalid route. The window warns the user that he must enter a valid route. It does not allow to advance while that does not happen. (work ok)

  3. “Accept” with a valid route. In this case the user must select a route different from the default one. (work ok)

  4. "Accept" without the user changing the path in the dialog box. In this case it is where the problem is, because it returns the empty string, when it should return the path “C: /” or return something other than an empty string. (problem)

Conclusion, there is a case (4) that returns an empty string when the user clicks “Accept”. Then, the empty string does not cover all cases for the “Cancel” button. That’s why I suggested another way to detect when the user clicks “Cancel”, or to fix the specific case.

This is a bit annoying because it is quite common for the user to open the dialog box and press “Accept” without changing the path and then the function does not do anything, it does not save a folder or a file, which is what it should do, because the condition of the empty string is used for “Cancel”: if (prompt == “”) then

This could be a typical use function to save an existing folder inside the tool. It could be used to reproduce the problem:

local function chd_backup_all_banks()
  --check if exist main_folder
  local origin_main_folder="chord_banks"
  if io.exists(origin_main_folder) then
    --create destiny main folder
    local path=rna:prompt_for_path("Choose a destination path to save a backup folder of all the banks.")
    if (path=="") then
      return --to Cancel button
      --to Accept button

Obviously, the folder to be copied must already exist.

I see. Sorry for the confusion.

“My Computer” (“Este equipo”) is not “C:/” - it’s a node which lists all locally connected hard drives. It’s not a valid file system path. Just like “Libraries” (“Bibliotecas”) and some other nodes.

So it should not be possible to select such items and hit “Ok” (Aceptar), so you are forced to select a valid folder or should explicitly cancel the dialog.

The dialog is a standard Windows Explorer dialog. We haven’t made it. But I’ll check if we nevertheless can somehow change/improve this.


I suppose that the correct operation would be, if the user selects “Este Equipo” or “Librerías” (or any similar case) the pop-up window of “Invalid path” should appear when clicking Accept, not allowing it to return an empty string…