Howdy, Stranger!

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

Error for IF statements in Sugarcube

Sorry for all the questions today but I'm trying to move from harlowe to Sugarcube and I have so many questions. Okay. First:

In Harlowe I set a variable: $preference: "Blue" for instance.
{(if: $preference is "blue")[Awesome](if: $preference is "red")[Yup](if: $preference is "both")[sweet]}
!

Now. In Sugarcube I'm not sure that I can remove the whitespace(?) which is accomplished by the curly braces in Harlowe. If I can't, I will have to figure out another solution. As that would make the entire formatting in Sugarcube visually appalling. (How would I do such a thing?)

Next, the code I've written in sugarcube keeps kicking errors to me.

Error: cannot find a closing tag for macro <<if>>
<<if $preference is "men">>him
<<if $preference is "women">>her
<<if $preference is "both">>him<</if>

also tried
<<if $preference is "men">>him<</if>
<<if $preference is "women">>her<</if>
<<if $preference is "both">>him<</if>

Thanks for all your help. #sigh


Comments

  • → Creating a gender pronoun widget
    <<widget "he">><<if $pcSex eq "male">>he<<elseif $pcSex eq "female">>she<<else>>it<</if>><</widget>>
    
    
    Put this in a passage with a tag named widget.

    Use this in the passage where you call the widget
    "Are you sure that <<he>> can be trusted?"
    
  • Ahhhhh. @spaceranger123 awesome. TY!!!!
  • FIF wrote: »
    In Harlowe I set a variable: $preference: "Blue" for instance.
    {(if: $preference is "blue")[Awesome](if: $preference is "red")[Yup](if: $preference is "both")[sweet]}
    
    !
    You really should have been using (elseif:) for the follow up cases, not three separate (if:) macros.

    FIF wrote: »
    Now. In Sugarcube I'm not sure that I can remove the whitespace(?) which is accomplished by the curly braces in Harlowe. If I can't, I will have to figure out another solution. As that would make the entire formatting in Sugarcube visually appalling. (How would I do such a thing?)
    AFAIK, the braces remove line breaks, specifically, not whitespace in general. The equivalent construct in SugarCube would be the <<nobr>> macro. That said, SugarCube has several line break control mechanisms: line continuations, <<nobr>> macro, and nobr special tag.

    FIF wrote: »
    Next, the code I've written in sugarcube keeps kicking errors to me.

    Error: cannot find a closing tag for macro <<if>>
    <<if $preference is "men">>him
    <<if $preference is "women">>her
    <<if $preference is "both">>him<</if>
    

    also tried
    <<if $preference is "men">>him<</if>
    <<if $preference is "women">>her<</if>
    <<if $preference is "both">>him<</if>
    
    In your first example:
    • The first and second <<if>> macros are missing their closing <</if>> tags.
    • The third <<if>> macro's closing <</if>> tag is missing a right angle bracket.
    In your second example:
    • All three <<if>> macros' closing <</if>> tags are missing a right angle bracket.

    You should be using <<elseif>> tags on the follow up cases anyway. Try something like:
    <<if $preference is "men">>him
    \<<elseif $preference is "women">>her
    \<<elseif $preference is "both">>him
    \<</if>>
    

    That said, I'd probably suggest a <<switch>> macro in this case, since $preference is limited to a single state at a time:
    <<switch $preference>>
    \<<case "men">>him
    \<<case "women">>her
    \<<case "both">>him
    \<</switch>>
    

    NOTE: The backslashes are the line continuation markup. You could use one of the other line break control mechanisms instead if you prefer. All are linked above.
  • FIFFIF
    edited January 2017
    You are awesome. Thank you for everything!
Sign In or Register to comment.