Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Issue with the print macro, setter links and strings

I am using SugarCube 2.7.2 on Twine 2.0.11

The passage in question contains the following for loop:

<<for $i to 1; $i <= $Total; $i++>>

Straightforward, and works fine in other passages. This for loop then contains the following print macro:


This appears to function just fine. But if I swap the second set macro from a number to a string, it no longer works:


"Error: <<print>>: bad evaluation: Unexpected identifier" is the error message in question.

$Item[$i].Property was set to 1 prior to this passage.

Setting the second setter link to "$Active.Property to "string"" did not solve the problem.

What am I missing?

Comments

  • You're trying to include double quotes within an existing pair of double quotes. That is not valid syntax, hence the error.

    You either need to exchange one of those sets for a pair of single quotes—inner or outer, it doesn't matter—or escape the inner double quotes. For example:

    Use alternate quotes:
    <<print "[[Text|Passage][$Active to $Item[" + $i + "]; $Item[" + $i + "].Property to 'string']]">>
    
    <<print "[[Text|Passage][$Active to $Item[" + $i + "]; $Item[" + $i + '].Property to "string"]]'>>
    

    Escape the inner quotes:
    <<print "[[Text|Passage][$Active to $Item[" + $i + "]; $Item[" + $i + "].Property to \"string\"]]">>
    
Sign In or Register to comment.