1. Hey! Guest! The 34th GMC Jam will take place between August 22nd, 12:00 UTC (Thursday noon) and August 26th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

GMS 2 Referencing Included Files

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

  1. FacesOfMu

    FacesOfMu Member

    Joined:
    Jun 23, 2018
    Posts:
    59
    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:
    Code:
    var file = file_text_open_read("this_file_name.csv");
    
    BUT

    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:
    Code:
    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").
     
  2. blane todd

    blane todd Member

    Joined:
    Aug 11, 2019
    Posts:
    3
    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

    Joined:
    Jun 21, 2016
    Posts:
    144
    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