Jump to content


animesavour

Member Since 22 Mar 2009
Offline Last Active Nov 23 2012 01:47 AM

Posts I've Made

In Topic: Creating File

22 November 2012 - 09:49 PM

I think string_copy(filename,string_length(filename)-9,9)
Try that in the debugger or something to make sure this is what you want... you might need to change it to string_copy(filename,string_length(filename)-8,9).  Like I said before, GameMaker has a weird way of numbering the character positions and it confuses me...

So anyway, your whole code would be

filename = get_open_filename("DG files|*.dg|All files|*.*","");
if(string_replace(string_copy(filename,string_length(filename) - 9, 9), "/", "\") == "\blank.dg"){
    // DO SOMETHING
}


Awesome it worked :D
Thank you very much!

In Topic: Creating File

22 November 2012 - 11:39 AM

Edit - for future reference, the reason string_copy() was not working is because it does not actually change the string. All it does is returns a copy of the string and it's up to you to set the string as the copy afterwards. Also, the way you had it won't work anyway because that would get the first 9 characters, not the last 9.


Alright, so how would I do this?

In Topic: Creating File

22 November 2012 - 02:07 AM

To make a file,

var f;
f = file_bin_open("blank.dg",2);
file_bin_close(f);
To let the user search for it, I use
filename = get_open_filename("DG files|*.dg|All files|*.*","");
(I'm not sure what that last argument should be... I just use a blank string and it seems to work).
Anyway, so after that then the filename variable will be a string containing the path to the file that the player has selected... so to find out if the player has selected "blank.db" then use string_copy() to get the last 9 characters.  If it is "\blank.db" then do whatever.

Wait how do I do the if statement? I have been trying with

if filename_pos("\blank.dg",filename) 
{

// DO SOMETHING

}
and
if filename = "\blank.dg"
{

// DO SOMETHING

}

Thanks in Advanced

Before that I have
filename = get_open_filename("DG files|*.dg|All files|*.*","");
string_copy(filename,1,9)

In Topic: Creating File

21 November 2012 - 05:40 PM

To make a file,

var f;
f = file_bin_open("blank.dg",2);
file_bin_close(f);
To let the user search for it, I use
filename = get_open_filename("DG files|*.dg|All files|*.*","");
(I'm not sure what that last argument should be... I just use a blank string and it seems to work).
Anyway, so after that then the filename variable will be a string containing the path to the file that the player has selected... so to find out if the player has selected "blank.db" then use string_copy() to get the last 9 characters.  If it is "\blank.db" then do whatever.


Awesome Thank You Very Much :D

In Topic: Creating File

21 November 2012 - 03:05 PM

Are you using game makerstudio or an earlier gamemaker version?
The file functions have changed in studio.


Gamemaker 8.0