Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SY() help.. 1

Status
Not open for further replies.

Neil Toulouse

Programmer
Mar 18, 2002
882
0
0
GB
Is there a SYS() function that will give the folder from where the EXE being run is residing?

Example:

Running in C:\APPS\MyAPP\MyEXE.EXE

Want to return C:\APPS\MyAPP\

Thanks

I like work. It fascinates me. I can sit and look at it for hours...
 
Try

JUSTPATH(SYS(16))

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
thanks Griff, not sure how I missed that one :)

I like work. It fascinates me. I can sit and look at it for hours...
 
Actually, if you want to have this "\" at the end of the returned string, it's gotta be

lcPath = ADDBS(JUSTPATH(SYS(16)))

but that's just a minor technicality, really! ;-)

Regards,

Ilya
 
For older VFP version without JUSTPATH
Code:
lcPath = LEFT(SYS(16),RAT('\',SYS(16)))
Tom.
 
<< For older VFP version without JUSTPATH >>

Or just the version in FoxTools. Regardless, it shouldn't be much of an issue anymore, as JUSTPATH() and its friends were added in VFP 6.

Tamar
 
Just to end this thread, I discovered I need to add ',0' to the function to get it to return a value in the EXE. Otherwise it just returned a blank value.

Code:
JUSTPATH(SYS(16,0))

I like work. It fascinates me. I can sit and look at it for hours...
 
That's interesting, I don't need to add the ,0 to get the path to the .exe...

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Interesting...

I can't really explain it anymore than that! With the ",0" a path, without nothing.

The app is in VFP8 running under Windows 7 64-bit if that has any bearing on it at all?

Anyways, not to worry cuz it is now working :)


Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
Neil,

I think the reaason you need add the zero is that you are calling the function from other than your main program (your "root" program).

The point is that SYS(16) returns the name of the currently executing program, and this might be further down the calling stack. That's true whether you are running in development or from an EXE.

I call JUSTPATH(SYS(16)) (without the zero), but always from my main.prg. I use it as the basis for setting the default directory and search path in my apps.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
thanks Mike, that is the reason, I am not calling it from the main PRG.

Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top