Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (TipmyPip, AndrewAMD), 1,151 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
file_open_write and dialog #239806
12/07/08 14:26
12/07/08 14:26
Joined: Aug 2006
Posts: 155
R
RyuMaster Offline OP
Member
RyuMaster  Offline OP
Member
R

Joined: Aug 2006
Posts: 155
Hi! I'm getting very odd behavior. I think it might be a bug.
I'm using this script for calling FileOpenDialog, Lite-C;

Quote:
OPENFILENAME ofd;
STRING FileName = str_create(#255);
FileName.chars=0; VERY IMPORTANT
FillMemory(&ofd,sizeof(ofd),0);
ofd.Flags=OFN_PATHMUSTEXISTOFN_FILEMUSTEXIST;
ofd.lStructSize=sizeof(ofd);
ofd.hwndOwner=hWnd;
ofd.lpstrFilter =All Files0.00;
ofd.lpstrInitialDir = _chr(work_dir);
ofd.lpstrFile=FileName.chars;
ofd.nMaxFile=255;
ofd.lpstrTitle=Open;
if (GetOpenFileName(&ofd))
{
process_entry(ofd.lpstrFile);
}


Now, I have this load-level script.

Quote:
if (key_f6) // Quick Save Level map data
{
var filehandle;
int j = 0;
STRING* temp = "#255";
str_cpy(save_dir,"");

filehandle = file_open_write("objects\\lab.txt"); // opens the file address.txt to read



and bla bla bla


If I load file, WITHOUT USING FILE DIALOG TO OPEN SOME FILE PRIOR TO IT, file "lab.txt" is loaded from root directory.
If I load file, BY LOADING SOME FILE WITH FILE DIALOG FROM FOLDER "objects", file "lab.txt" is loaded from "objects" directory.

Now, changing save_dir does absolutely nothing. I may delete it, or change to some value. It looks like absolutely irrelevant?
Also, I have this at script start:


Quote:
#define PRAGMA_PATH "D:\quntummist\lab\game";
#define PRAGMA_PATH "D:\quntummist\objects\props";
#define PRAGMA_PATH "D:\quntummist\objects\walls";
#define PRAGMA_PATH "objects";
#define PRAGMA_PATH "D:\quntummist\objects";



Last edited by RyuMaster; 12/07/08 14:29.

What kills me not, that makes me stronger.

***Working on RPG/RTS***
Re: file_open_write and dialog [Re: RyuMaster] #239809
12/07/08 15:38
12/07/08 15:38
Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
Tobias Offline

Moderator
Tobias  Offline

Moderator

Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
Maybe, you changed the directory in the dialog?

Re: file_open_write and dialog [Re: Tobias] #240161
12/09/08 19:21
12/09/08 19:21
Joined: Aug 2006
Posts: 155
R
RyuMaster Offline OP
Member
RyuMaster  Offline OP
Member
R

Joined: Aug 2006
Posts: 155
No, I'm tracing save_dir and work_dir in debug window. They do not change. But file_write supposed to write into save_dir folder.


What kills me not, that makes me stronger.

***Working on RPG/RTS***
Re: file_open_write and dialog [Re: RyuMaster] #240277
12/10/08 11:15
12/10/08 11:15
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Originally Posted By: manual
If a path is given with the file name, the file is opened from that path instead of the save_dir or work folder.

Your poor computer just tries to please you by doing what you told it. When you give a subfolder, it tries to open the file from that subfolder of the current directory. Window's file open dialogs change the current directory. If that's bad for your project, you must change it back.

That's why we suggest not to use paths in file names. When you leave the protected room of engine functions and wander into the open field of the Windows API, don't complain about the cold wind of real programming blowing into your face.

Re: file_open_write and dialog [Re: jcl] #240299
12/10/08 12:53
12/10/08 12:53
Joined: Aug 2006
Posts: 155
R
RyuMaster Offline OP
Member
RyuMaster  Offline OP
Member
R

Joined: Aug 2006
Posts: 155
Thanks for answering!

You say I can change current dir back? That was first ideas I came into.

But, work_dir and save_dir stays the same, while "lab.txt" is accessed from "objects" folder, as I wrote.

So, current_dir is some variable which is stored outside of 3DGS engine and can be traced only from within windows API?
But if 3DGS uses it, maybe it stores current_dir somewhere also, so I could change it?



Regards,
Konstantin.

Last edited by RyuMaster; 12/10/08 13:11.

What kills me not, that makes me stronger.

***Working on RPG/RTS***
Re: file_open_write and dialog [Re: RyuMaster] #240301
12/10/08 13:02
12/10/08 13:02
Joined: Apr 2008
Posts: 586
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 586
Austria
Hi Ryumaster, work_dir is not a folder. It is a string pointer.

Originally Posted By: manual
work_dir

Type:
string*, read-only

For changing a string you need functions like str_cpy, but in case of work_dir you probably can't change it at all because its marked as read-only and thus not changed at runtime.

In Windows, you change the current folder with a function like "_chdir". As I understand the manual the string work_dir contains the name of your original game folder and will almost certainly have no effect on your current directory!

Hope this helps!


Re: file_open_write and dialog [Re: Petra] #240303
12/10/08 13:13
12/10/08 13:13
Joined: Aug 2006
Posts: 155
R
RyuMaster Offline OP
Member
RyuMaster  Offline OP
Member
R

Joined: Aug 2006
Posts: 155
In Windows, you change the current folder with a function like "_chdir"

Thanks a lot. I think I'll try changing current_dir from WINAPI, I hope this would not bring any more errors.


What kills me not, that makes me stronger.

***Working on RPG/RTS***

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1