1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice
  2. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GMS 2 Span String Argument Over Multiple Lines

Discussion in 'Programming' started by TheMagician, May 16, 2017.

  1. TheMagician

    TheMagician Member

    Joined:
    Jun 20, 2016
    Posts:
    59
    In GMS 1.4 you could span a String argument over multiple lines which enabled nice things like creating a map using JSON formatting:

    Code:
    map_game = ds_map_create();
    
    map_game = json_decode('
    {
      "Player":
      {
        "x":0,
        "y":0,
        "Inventory":
        {
          "0":"Rope",
          "1":"Money",
          "2":"Flower"
        }
      }
    }
    ');
    Now in GMS 2 there are multiple problems:
    1. You can't use ' anymore to define a string, only " works
    2. If you use more than one line for the string you get the error "Unterminated String Literal"
    Are there any plans to bring this functionality back?
     
  2. YellowAfterlife

    YellowAfterlife ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    2,430
    It's via @"" or @'' strings.
    Code:
    map_game = json_decode(@'
    {
        "Player":
        {
            "x":0,
            "y":0,
            "Inventory":
            {
                "0":"Rope",
                "1":"Money",
                "2":"Flower"
            }
        }
    }
    ')
     
    TheMagician likes this.
  3. TheMagician

    TheMagician Member

    Joined:
    Jun 20, 2016
    Posts:
    59
    Wow, thanks! Never would've thought of that!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice