Howdy, Stranger!

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

Displaying arrays in Harlowe

edited August 2015 in Help! with 2.0
Let's say I have an array
(set $arr: (a: "something", "something else"))

If I try to show its contents on the page with
$arr
I get this:
something,something else

Not very pretty. Same thing happens with
(print: $arr)
and
(text: $arr)
Is there a simple way to print an array with comma-space instead of just comma as the separator?

Comments

  • You can use javascript to turn the array into a string. Using the join function lets you specify the separator.

    To get a comma space between each element, you'd use
    (print: $arr.join(", "))
    
  • Thanks!

    I had no idea JavaScript was accessible in that way, from a normal passage. Can I just do anything with arrays that I could in JS?
  • Yes, AFAIK any array method can be used as a parameter for a macro.
Sign In or Register to comment.