0 votes
by (140 points)
Found (put: (prompt: "What's your name?") into $name) Your name is $name. on the web and it didn' work. Does someone have one?

2 Answers

+1 vote
by (63.1k points)
(put: (prompt: "What's your name?", "") into $name)
Your name is $name.

OR

(put: (prompt: "What's your name?", "Barry") into $name)
Your name is $name.

The (prompt:) macro requires two strings: the first is the question or prompt, the second is the default string for the answer, which you can make a default name or blank (by passing an empty string).

by (140 points)
Would it be possible to get a quick example?  I'm not much of a tech.
by (63.1k points)
edited by
?? There are two examples in my answer.
0 votes
by (159k points)

You need to use the Question Tags to indicate the name and full version number of the Story Format you are using, as answers can vary based on that information.

A. If you are using the 1.x series of Harlowe (eg. v1.2.4) then your example will work because that series only requires you to pass a single String parameter to the (prompt:) macro.

(put: (prompt: "What's your name?") into $name)
or
(set: $name to (prompt: "What's your name?"))

B. If you are using the 2.x series of Harlowe (eg. v2.0.1) then as explained in the (prompt:) macros documentation you need to pass two String parameters to that version of the macro.
There are two examples of how to use the 2,x series version of the (prompt:) macro in @Chapel's answer to your question.

notes:
1.  you can use either a (put:) macro or a (set:) macro to assign the returned value of the (prompt:) macro to a variable.
2. the 1.x series documentation for the (prompt:) macro incorrectly states you need two parameters.

This site has been placed in read-only mode. Please use the Interactive Fiction Community Forum instead.
...