I have decision points that not only advance the story, but also change a variable. The code I've used so far helps me exit the if statement, but it doesn't permanently change the variable. I need to be able to track it over the course of the story.
Code:
(set:$1st to 1)
(if:$1st is 1)[
|choice>[
(link: "(A) \“Hello .... District\”")[
(set:$1st to 2)
(replace: ?choice)[“Hello ... District.”]]
(link: "\“Good .... cause.\”")[
(set:$1st to 2)
(replace: ?choice)[“Good .... cause.”]]
]](else:)[ERROR]
Comments
While Harlowe does support using a number as the first character of a variable's name, as @Chapel stated it is generally not a good idea to do so.
Your example does change the value of the $1st variable to 2 if either of those links are selected, and this can be demonstrated by adding a third markup link to the bottom of the code and then displaying the current value of $1st in the next passage.
eg. your example passage plus extra link. The Next passage: ... should display 2 if either of your 'choice' links are selected before selecting the 'Next' link.
The ERROR text in your example will never be displayed, even if you revisit that passage, because you are assigning a value of 1 to the $1st variable each time that passage is visited. If you move that initial assignment to an earlier passage (ideally your story's startup tagged passage) then your example passage with be able to display the ERROR text when the variable is not equal to 1.