Either and the Goto Command

I’m a bit stuck on how to have goto function make a choice randomly to select two passages.

<<goto either ("passage1", "passage2")>>

I’m getting error messages when I try using ‘either’ or ‘or’ (inside the () etc.

Checking <<goto>> in the Sugarcube Documentation, it doesn’t seem to accept either like that. But you can always use either to set a temporary variable which will determine your target passage:

<<set _targetpassage to either("passage1", "passage2")>>
<<goto _targetpassage>>
3 Likes

Hmm, two things.

  1. It’s <<goto either(“passage1”, “passage2”) >>, without the space after either.
  2. The whole expression starting at either and ending at the closing bracket, to be counted as a single argument, needs to be surrounded by backticks (the ` sign).
    Do this, and it will work.
2 Likes

I didn’t know about the backtick trick, but this indeed does work!

1 Like

I’ve only recently started using it myself, haha. Basically, if you want SC to treat the result of an expression of arbitrary complexity as a single argument, you backtick. It’s been very useful for some of my custom widgets.

2 Likes

Is _ what you mean by ‘backtick’?

No, I showed it in the parentheses: ` ← this little flea-like thingy that looks like a quote but isn’t.

3 Likes

The reason is because of how macro arguments work. I suggest reading the whole section—it’s short—but the relevant subsection is argument type macros: passing an expression as an argument.

2 Likes

Oh, I call those quote-marks / speech marks. Now I see what you mean.

Eh, there are, I think, six types of those: ', ", `, ´, ‘,’. That’s why they have different names, and it’s important to know which is the one that does the job.

1 Like

Sure, but in my realm we don’t call it a ‘back-tick’, just a difference of terminology is all.
Good day. :slight_smile:

As there a many different types of quotation marks (both straight and curvy varieties), the fact that some of them (like the backtick character) are known by multiple official names (like backquote , grave , or grave accent) can be confusing.

I personally use the term back-quote, because I along history in computing in a country that uses English as their primary (written) language. But I understand why anyone who comes from a country whose primary language includes accented characters would likely use the term “grave accent” (or just grave).

1 Like

I’m born and raised in the country that is the home of the English language and I can assure you that ‘backtick/back-quote’ is news to me. :smiley:

At school we called them speech marks or quotations - open quote, close quote.

I’m not gainsaying your experience, but that is a bit surprising, because those are usually not the same as the backtick (and not the same as each other, in the curly typographical versions).

Admittedly, the whole thing is complicated, as was said above, both because a) various languages have various signs, and b) there are limitations and mappings imposed by typewriters/keyboards and character encodings.

For most purposes, the important things to keep in mind are:

  • standard single quotes are produced by typing the apostrophe ' (which then may or may not be converted by software into typographical curly quotes, where the opening is differently curled from the closing mark; and both are not the same as the backtick); or by entering the Unicode codes for the opening and closing quotation marks directly

  • backticks are produced by typing, well, the backtick sign, which is also the grave accent sign ` (the same as in à la carte or La Bohème); on US and UK keyboards, the key to the left of the 1 key

I’m curious.
So you would call each of the following different types of quotation mark characters by the same general term?

'
"
`
“
”
‘
’

And what about « » ?

'
"
`
“
”
‘
’

Some of those weren’t even taught at school back in the 80s.

‘Straight Apostrophe’ but not taught at the time as they weren’t drawn that way. They were ‘`’
Speech Mark Open or Closed
Apostrophe
Open Speech Mark (this was considered the exact same but just a different style of writing it)
Closed Speech Mark
Quotation open
Quotation closed

I can tell my audience is probably no older than Millenial so this is like Boomer story hour right now, lol.

That wouldn’t have been taught either.
< Lesser than. > Greater than. But my dyslexia probably might have that the wrong way around.

Those are actually pretty often used as quotes in the older editions of books in my country. (They might be a Cyrillic thing.)