C (136/178)

From:Alexander Niven-Jenkins
Date:26 Jul 2000 at 19:51:30
Subject:Re: PROGDIR:

Hiya Jack,

On 25-Jul-00, you wrote:

>> Is PROGDIR: set up on its own when a program is launched? Because it
>> doesn't seem to work! Open() just returns NULL.

> PMFJI, but I have wondered about this myself. I know what it's purpose is
> but whenever I use it, it is treated as a literal. So if I do something
> like
> sprintf ( filename, "PROGDIR:%s", "filename"); and then
> puts (filename);

> I get PROGDIR:filename displayed where I should be something like
> sys:filename.

> What am I missing?

Nothing, that's what you are meant to have!!! AmigaOS will automatically
know that any calls to PROGDIR:filename really means <programs
path>:filename.

e.g.

void main()
{
long handle = NULL;

if( handle = Open( 'PROGDIR:testfile.txt', MODE_NEWFILE ) )
{
Close( handle );
handle = NULL;
}
}

If you run this, you find an empty file called testfile.txt in which ever
directory the program ran from. Of course this might vary for CLI launched
programs as the OS might use the current directory rather than the
directory the program resides in, I can't remember.

But it definitely works from WB, I know I use it all the time :-)

Kind regards...

Alex



Cremlin Software - http://www.cremlinsoftware.org
Founder, lead programmer - ghandi@cremlinsoftware.org
Production, programmer - anj@cremlinsoftware.org

--------------------------------------------------------------------<e|-
It's the End Of The Line for My Shipping Broker.
http://click.egroups.com/1/5175/1/_/451227/_/964637780/
--------------------------------------------------------------------|e>-