• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Question - General [SOLVED] get_open_filenames and get_open_filenames_ext

S

Sam (Deleted User)

Guest
I'm going to write a multiselect version of get_open_filename and get_open_filename_ext that works on Windows natively, Mac with AppleScript, and Linux with Zenity. I was wondering before I get started what everyone's thoughts are on how I should do it...

let's say i select multiple files.. They are all located in the folder "/home/owner/GameAssets/". The first file is called "File1.png", the second is "File2.png", and so on...

The standard way of doing delimiters is usually by using a null terminator character, which is "\0".

Would everyone prefer me to do it that way, or a new line character? i.e. "\n" or "\r"...

if i did a new line, the string returned for example would look like this:

"/home/owner/GameAssets/File1.png
/home/owner/GameAssets/File2.png
/home/owner/GameAssets/File3.png"

The above method is easier to parse for newer users, but is not the usual standard, and it requires a much bigger buffer size.


however, if done with a null terminator, it would look more like this:

"/home/owner/GameAssets/\0File1.png\0File2.png\0File3.png\0\0"

So what does everyone think I should do? Or do you have an alternative suggestion of your own that is worth me doing instead of these two examples?

Thanks.
Samuel
 
Last edited by a moderator:
I

immortalx

Guest
In .NET I think you could get back an array of strings if multiselect was set to true. I guess this is the best for users since it doesn't need any parsing.
 
H

Homunculus

Guest
Don't know much about native extensions, but as far as I know you can only return a real or a null terminated string (only option in this case), which isn't very user friendly.
You should probably return the string formatted however you prefer and provide a wrapper function that splits the result into a ds_list and returns it.
 
S

Sam (Deleted User)

Guest
Unfortunately I don't think that would be possible with a GameMaker extension; a DLL whether called from a GML script or through the newer extension system, you can only have one return value.

@Catan That sounds good. Except I've never used data structures lol I guess I'll consult the GM manual :)
 
H

Homunculus

Guest
Should be easy enough. If you go the null terminated way, you could even throw the string into a buffer and read one filename at a time with
Code:
filename = buffer_read(buffer, buffer_string);
 
S

Sam (Deleted User)

Guest
Should be easy enough. If you go the null terminated way, you could even throw the string into a buffer and read one filename at a time with
Code:
filename = buffer_read(buffer, buffer_string);
Thank you! Will do! :D
 
Top