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:
    57
    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,404
    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:
    57
    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