[Harlowe 3.1.0] Is there a macro to loop a set of commands until a boolean variable returns true?

Please specify version and format if asking for help, or apply optional tags above:
Twine Version: 2.3.5
Story Format: Harlowe 3.1.0

Hello, I’m starting out a project and one of the first questions is asking for name. I’m using (prompt:) to obtain that (thus getting the JavaScript popup box to collect user input), and then using (confirm:) to showcase the name and let the user confirm if they like that name or want to change it (storing the result in a boolean variable).

These macros are working more or less fine for me (the actual name in the confirm prompt is showing up as " " instead of the value collected in (prompt:) but it’s showing up correctly outside of (confirm:) so I’ll mess with it later), but what I would like to do is loop the two popups ((prompt:) and (confirm:)) until $confirmName returns true.

I tried using the (for:) macro (and swapped out (for:) for (loop:) since they appear to be interchangeable), but by the looks of it, (for:) was designed more with cycling through array values and datasets and less for what I’m intending. If it helps, the script I was attempting to execute with this macro looked something like this:

(set: $name to (prompt: "What is your name?" "name"))
(set: $confirmName to (confirm: $name. Is that correct?))

(for: _confirmCount where $confirmName is false)[
    (set: $name to (prompt: "What is your name?" "name"))
    (set: $confirmName to (confirm: $name. Is that correct?))

Your name is $name.

So what I’m trying to find out is if I can use the (for:) macro like a way I would use a loop in say Java and my syntax is just wrong, if this macro isn’t appropriate for my intended purpose and there’s another one that’s more appropriate (though I couldn’t find one in the documentation), or if I’m going to need two passages linked to each other with if/else statements and create the loop that way. Or if I could potentially build my own macro to plug in with JavaScript. Thanks!

First, there a couple of syntax errors in your example:

  1. the (prompt:) macro expects there to be a comma between the two String arguments.
  2. the (confirm:) macro expects the argument passed to it to be a String value.

You can combine a ‘child’ Passage, with a (display:) macro, a Named Hook, and a (replace:) macro to implement a ‘loop’ like structure.

The contents of the ‘child’ passage, I named it Ask Name in this solution.

(set: $name to (prompt: "What is your name?", "name"))
(set: $confirmName to (confirm: $name + ". Is that correct?"))

(unless: $confirmName)[
	(replace: ?askname)[(display: "Ask Name")]

The contents of the passage in which you want to ask the ‘name’ related questions.

(set: $confirmName to false)

|askname>[(display: "Ask Name")]

Oh, I didn’t even think to try that! I’ve still got a lot to learn about this program. Thank you!