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
0 registered members (), 1,173 guests, and 0 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
Page 2 of 2 1 2
Re: long WINAPI SetCurrentDirectory(long lpPathN) [Re: rstralberg] #189150
03/19/08 10:11
03/19/08 10:11
Joined: Apr 2005
Posts: 4,506
Germany
F
fogman Offline OP
Expert
fogman  Offline OP
Expert
F

Joined: Apr 2005
Posts: 4,506
Germany
It sets the directory to the engines path - but that will only work when its published.
But I need it in the development version also.

I´ll give you an example:

My GS folder is located at c:/ProgrammData/GStudio7

My project folder is located at d:/projects/project1


It should set the directory to the folder of the project, regardless if it´s published or not.
The predefined Lite-C string "work_dir" contains the path, maybe you can use it.

As it seems to be a littlebit piece of work, I would like to give you some bucks if you want.


no science involved
Re: long WINAPI SetCurrentDirectory(long lpPathN) [Re: fogman] #189151
03/19/08 10:18
03/19/08 10:18
Joined: Apr 2006
Posts: 66
Sweden
R
rstralberg Offline
Junior Member
rstralberg  Offline
Junior Member
R

Joined: Apr 2006
Posts: 66
Sweden
Hi again.

I can have a check on it later this afternoon.
I'm at work now.

And no bucks needed. At this level we need to
help each other. I'm curious my self and as I'm
a newbie on GameStudio I take it as steps in my
learning process.

I'll get back later.

Cheers

Last edited by rstralberg; 03/19/08 12:16.

Roland Strålberg Gamestudio/A7 Commercial rstralberg@msn.com
Re: long WINAPI SetCurrentDirectory(long lpPathN) [Re: rstralberg] #189152
03/19/08 16:05
03/19/08 16:05
Joined: Apr 2006
Posts: 66
Sweden
R
rstralberg Offline
Junior Member
rstralberg  Offline
Junior Member
R

Joined: Apr 2006
Posts: 66
Sweden
Thinking in public

The work_dir and exe_dir variables are set at runtime
and not usable for what you are after.

There seems to be two ways to solve this.

  • At compile-time save the project path in a file which is then is included
    in publish. At program start we then could read back the original project path
    from that file. Not a beatiful solution but i could work. But then the project path
    may point at let's say C:\project\test. If then the published files are installed on
    a D: drive, things will go wrong as the program will try to find the path in a C: drive ...
    Of course we could omit the drive info and get around the probelm that way.

  • If I can find an equivalent to the C preprocessor variable __FILE__, its possible
    to get the project directory from there at compile time. I have asked Conitec if
    such an equvivalent exist. However the problem with drive info at an installation
    remains here.


I'll give it some more thoughs later.


Roland Strålberg Gamestudio/A7 Commercial rstralberg@msn.com
Re: long WINAPI SetCurrentDirectory(long lpPathN) [Re: rstralberg] #189153
03/19/08 16:12
03/19/08 16:12
Joined: Apr 2005
Posts: 4,506
Germany
F
fogman Offline OP
Expert
fogman  Offline OP
Expert
F

Joined: Apr 2005
Posts: 4,506
Germany
Well, I´ve explained in the wrong way.

I need the path to the project, even if it´s published and located in a different folder.
Then I need the path to this folder, where the exe is located.

In develoment it´s my project folder d:\bla\bla
Published and installed it´s c:\programm_files\bla

Simply the folder where the project / the executable lies, published or not.

The predefined "work_dir" contains indeed this specific string.
I´m aware (and it´s logical) that it has to be different on other machines.

Edit: Here´s what I do:

I load a bitmap through a file open dialog. This bitmap is in a different folder than my app (published or not).
The file open dialog sets the current directory to this folder, thus allowing the engine to load the bitmap.

After that instruction I need to set the current directory back to my application directory, because I want to load
content from it.




no science involved
Re: long WINAPI SetCurrentDirectory(long lpPathN) [Re: fogman] #189154
03/19/08 21:53
03/19/08 21:53
Joined: Apr 2006
Posts: 66
Sweden
R
rstralberg Offline
Junior Member
rstralberg  Offline
Junior Member
R

Joined: Apr 2006
Posts: 66
Sweden
Hi again

Hope I did get it this time
As you suggested work_dir seems to make the trick.

The test program writes "exe.txt" in executable-folder, then switches
to root-folder and writes "root.txt" there. Then switches back to
executable folder and write "back.txt" there.

Running from SED, "exe.txt" and "back.txt" will be written to
the project folder (which is the executable folder) and
"root.txt" to root-folder.

Running for publish folder (anywhere), "exe.txt" and "back.txt"
will be written to the publish folder (where the exe is) and
"root.txt" to root-folder

Code:


//////////////////////////////
// Set working directory
// lite-C 7.06.1
// by rstralberg
//////////////////////////////

// GameStudio
#include <acknex.h>

// Std C
#include <stdio.h>


//////////////////////////////
// MAIN PROGRAM ENTRY
//////////////////////////////
function main()
{

// switch to executable directory
_chdir( work_dir.chars ) ;

// write a file there just to verify where we are
printf( "Writing the file exe.txt to executable directory to verify that we really are there" ) ;
FILE* fp = fopen( "exe.txt", "wt" ) ;
if( fp )
{
fputs( "It safe to delete me!", fp ) ;
fclose(fp) ;
}

// switch to another directory ( in this case root )
_chdir( "\\" ) ;

// write a file there just to verify where we are
printf( "Writing the file root.txt to root-directory to verify that we really are there" ) ;
fp = fopen( "root.txt", "wt" ) ;
if( fp )
{
fputs( "It safe to delete me!", fp ) ;
fclose(fp) ;
}

// switch to executable directory
_chdir( work_dir.chars ) ;

// write a file there just to verify where we are
printf( "Writing the file exe.txt to executable directory to verify that we really back\n" ) ;
fp = fopen( "back.txt", "wt" ) ;
if( fp )
{
fputs( "It safe to delete me!", fp ) ;
fclose(fp) ;
}

}





Roland Strålberg Gamestudio/A7 Commercial rstralberg@msn.com
Re: long WINAPI SetCurrentDirectory(long lpPathN) [Re: rstralberg] #189155
03/20/08 11:52
03/20/08 11:52
Joined: Apr 2005
Posts: 4,506
Germany
F
fogman Offline OP
Expert
fogman  Offline OP
Expert
F

Joined: Apr 2005
Posts: 4,506
Germany
That works / gives me enough information to extract a shorter version.
Thanks & enjoy your meal.




no science involved
Re: long WINAPI SetCurrentDirectory(long lpPathN) [Re: fogman] #189156
03/20/08 13:01
03/20/08 13:01
Joined: Apr 2006
Posts: 66
Sweden
R
rstralberg Offline
Junior Member
rstralberg  Offline
Junior Member
R

Joined: Apr 2006
Posts: 66
Sweden
Haha... Yes cookies and coffe ... Mmmmm..

Thanks a lot, I learned a lot


Roland Strålberg Gamestudio/A7 Commercial rstralberg@msn.com
Re: long WINAPI SetCurrentDirectory(long lpPathN) [Re: rstralberg] #240328
12/10/08 14:42
12/10/08 14:42
Joined: Aug 2006
Posts: 155
R
RyuMaster Offline
Member
RyuMaster  Offline
Member
R

Joined: Aug 2006
Posts: 155
Just wanted to say - THANKS, rstralberg! Your code really helped me with one particular problem.


What kills me not, that makes me stronger.

***Working on RPG/RTS***
Page 2 of 2 1 2

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