GMS 2 Referencing Included Files

Discussion in 'Programming' started by FacesOfMu, Feb 24, 2019.

  1. FacesOfMu

    FacesOfMu Member

    Jun 23, 2018
    Took me a while to figure this out as the docs was a little light on it. I'm posting it here in case any other users are searching for it and need it.
    To reference an included file your code might read:
    var file = file_text_open_read("this_file_name.csv");

    If you've put your Included Files into a sub-group, the file name will need the name of that group and two backslashes \\ after:
    var file = file_text_open_read("this group name\\this_file_name.csv");
    When we refer to other assets in GMS2, we don't have to worry about their group names, but as the file system creates a literal folder directory with the name of your sub-group, you need to add it to the file name and use the correct separators.
    Also, it's two backslashes as the first backslash tells the IDE that in this string there is a special character here, and the second backslash says that special character is a backslash (and not n for newline as in "\n" or t for tab as in "\t").
    Kezarus likes this.
  2. blane todd

    blane todd Member

    Aug 11, 2019
    Thank you for sharing this! There are a LOT of areas of the documentation that leave a bit to be desired. Glad i found this today.
    FacesOfMu likes this.
  3. Bart

    Bart Member

    Jun 21, 2016
    Just to add to this, do note that a forward slash "/" as the separator works equally well and also keeps your project compatible with other platforms.

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