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