# GMLscripts.com

Discuss and collaborate on GML scripts

You are not logged in.

## #1 2009-04-07 12:44:36

xot
Registered: 2007-08-18
Posts: 1,201

### working_directory & program_directory - bug or feature? (GM5,6,7)

Ideaz over at GMC noticed what might be a bug concerning the working_directory read-only variable. If you are using the debugger and load or save watch expressions from the Watch menu, the working directory changes. This is true in GM5, GM6, and GM7.

And there is another wrinkle. If you read the linked thread, Calle says that this is probably normal because of something written about the program_directory read-only variable (introduced in GM7).

GM7 Help File wrote:

program_directory* Directory in which the game executable is stored. (Not including the final backslash.) When you run a standalone game this is normally the same as the working directory unless the game e.g. opens a file using the file selector. Note that when testing a game you are creating the program and working directory will be different. In that case the working directory is the place where the editable version is stored while the program directory is a temporary directory for testing.

But is this true? I couldn't seem to confirm this.

Abusing forum power since 1986.

Offline

## #2 2009-04-10 03:52:01

icuurd12b42
Member
Registered: 2008-12-11
Posts: 303

### Re: working_directory & program_directory - bug or feature? (GM5,6,7)

xot wrote:

Ideaz over at GMC noticed what might be a bug concerning the working_directory read-only variable. If you are using the debugger and load or save watch expressions from the Watch menu, the working directory changes. This is true in GM5, GM6, and GM7.

And there is another wrinkle. If you read the linked thread, Calle says that this is probably normal because of something written about the program_directory read-only variable (introduced in GM7).

GM7 Help File wrote:

program_directory* Directory in which the game executable is stored. (Not including the final backslash.) When you run a standalone game this is normally the same as the working directory unless the game e.g. opens a file using the file selector. Note that when testing a game you are creating the program and working directory will be different. In that case the working directory is the place where the editable version is stored while the program directory is a temporary directory for testing.

But is this true? I couldn't seem to confirm this.

It's not true. working directory (in gm7) stays to that of the of the Project Directory even if you change directory with a file dialog...

Starting from GM, the play Button
Work = GMK Directory
Prog = A temp Directory
Temp = Another temp directory (I don;t undrerstand that reason)
When starting a load or a save dialog, nothing changes

When double clicking the exe
Work = exe directory
Prog = exe directory
temp = some temp direcotry
When starting a load or a save dialog, nothing changes

If you start the exe while in another directory (Use the cmd prompt c:\test\test.exe), double clicking a file associated with the exe or the debugger in MSVC (Which is the current directory is the MSVC project and your) to debug a dll...
Work = the directory you are in/the file clicked was in, or your msvc dll project folder
Prog = exe directory
temp = some temp direcotry
When starting a load or a save dialog, nothing changes

Sprite: <no sprite>
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>

Draw Event:
execute code:

s = "Work: " +working_directory + "#Prog: " + program_directory + "#Temp: " + temp_directory

draw_text(10,10,s);

Key Press Event for <Space> Key:
execute code:

if(keyboard_check(vk_control))
{
f = get_open_filename("*.*|*.*","")
file_text_close(hf)
}
else
{
f = get_save_filename("*.*|*.*","")
hf = file_text_open_write(f)
file_text_close(hf)
}

Maybe by File selector they meant the wd_open_dialog_show() ???

Later...

Yep, it's with wd_open_dialog_show()

Offline

## #3 2009-04-10 09:57:36

xot
Registered: 2007-08-18
Posts: 1,201

### Re: working_directory & program_directory - bug or feature? (GM5,6,7)

Later...

Yep, it's with wd_open_dialog_show()

Yeah, I was thinking that, too, thanks for confirming it. That's part of the reason I'll willing to call this a feature. It may be standard operating procedure for all "well written" Windows applications. And Calle's explanation about the debugger being part of the application and therefore causing the change makes perfect sense. It's just a little unfortunate and should probably be documented somewhere.

Abusing forum power since 1986.

Offline

## #4 2009-04-11 00:21:40

icuurd12b42
Member
Registered: 2008-12-11
Posts: 303

### Re: working_directory & program_directory - bug or feature? (GM5,6,7)

Well, the help is wrong (not specific enough) if you ask me. File Selector makes me assume get_open_file.

perhaps working_directory was a obvious place holder to place the selected file directory in it. Since I see not _get_folder interface arround the dialog box though the filename_dir does provide the feature.

That file dialog extention is useless
wd_open_dialog_show()
wd_save_dialog_show()

it does not extend the get_open_file and get_save_file enough to warent it's existance... Yeah, ok, you can set it to confirm overwrite... Bid deal. I would rather they added support for multi file select.

Though the picture one, I think I'll use.

Last edited by icuurd12b422 (2009-04-11 00:28:18)

Offline

## #5 2009-04-11 04:23:04

xot
Registered: 2007-08-18
Posts: 1,201

### Re: working_directory & program_directory - bug or feature? (GM5,6,7)

Though the picture one, I think I'll use.

Yeah, I'd consider that myself for my jigsaw puzzle project. But the default file selector can show thumbnails, so it's largely moot.

Abusing forum power since 1986.

Offline

## #6 2009-04-11 21:29:36

icuurd12b42
Member
Registered: 2008-12-11
Posts: 303

### Re: working_directory & program_directory - bug or feature? (GM5,6,7)

xot wrote:

Though the picture one, I think I'll use.

Yeah, I'd consider that myself for my jigsaw puzzle project. But the default file selector can show thumbnails, so it's largely moot.

tga and a few others image formats files dont thumbnail though but the image dialog shows them. In GMModelFix, I'll definitively use it because many models use tga images.

Offline