sgp wrote:
> I discovered that validpath (relative_path) returns 1 when relative_path
> is in powerpro's currentdir. The issue is that one doesn't know where
> currentdir is! -- unless, of course, uses one of the methods listed in
> this thread, such as making powerpro the active window, or running cmd
> to find out, etc. I think that those solutions get the job done but are
> "expensive" or "less than ideal". I wish I had a window("currentdir",
> caption) available. I think a script shouldn't rely on the fact, of
> fiction, who knows?, that powerpro isn't changing dir while it's running.

Yes, window("currentdir",caption), or just currentdir(caption),
would be very nice, but meanwhile your own workaround:
local x=win.handle("active")
win.show("=powerpro")
win.debug(currentdir)
win.show(x)
doesn't look too ugly. Sean's solutions are even better because
they don't cause flashing title bars from a temporary change
of focus -- provided you run them from a hotkey or script,
not from clicking on a bar button.

By the way, even this works:
notepad.exe
wait for 200
win.debug("PowerPro's currentdir = " ++ currentdir)
window close new file - metapad

Which works because notepad inherits powerpro's working directory
unless told otherwise. I am not suggesting that as a practical
solution, it just demonstrates something: you could use almost
any program instead of cmd.exe. Sean's use of Cmd is a good choice
because it can report its own currentdir, and pipe it to a file
or variable, even though it has been started hidden.

-------------------------------------------------

In addition to these three:
- pprofolder function (where the current pcf resides)
- powerpro.exe's exepath
- powerpro's current directory
I should have added the path shown by the "scriptfolder" function
[not scriptpath!] which also affects some relative paths.

Many programs have their own private store of "current folders"
only one of which is the official "current directory" aka
"working directory" which is reported to external enquiries
such as sysinternals or pp's currentdir function.

For example an editor may start in a different folder for File Open
than for File SaveAs (for a new file).

PowerPro has several "private current dirs", including those listed
in the first paragraph above. Different ones are used as the root
of relative paths in different places (which is why I prefer to
make them all the same).
An external program can only enquire about one of them,
"the working directory".

------------------------------------------------------------

Although program A can set program B's curdir when starting it,
I have never seen an example of A changing B's curdir after B
has started. It seems a program can only change its own currentdir.

In the case of a cmd.exe window it seems like an external command
can change its curdir, but I think that can only happen by A
asking B to make the change. That requires B's cooperation
and can only work if program B contains code for accepting commands
(which PowerPro has via its command line) AND also has its own
internal code to execute the change (such as cmd's: cd c:\newdir)
which it seems PP does not have.
Therefore I think powerpro's currentdir is safe from any change.

-----------------------------------------------------------

Alec wrote:

> Just verified that if I cd to another folder in a command window then PE
> recognizes and reports the change. Can you just make PowerPro execute a cd
> command and trap the output?

That's what Sean suggested -- and he gave us three different ways to
do it, including:
> do("cmd",?"/c cd > C:\ppwork.txt","","hide")

I assume you are referring to a window of cmd.exe in 2000/XP,
which acts similar to a dos window in 95/98.

When you show a cmd window from this command in PP: cmd.exe
it inherits powerpro.exe's currentdir (as usual when program A
starts program B without specifying a working directory),
which is why Sean's methods work.

Changing that with CD c:\newfolder in the cmd window has no effect
on PowerPro's currentdir. If you close that cmd window and start
a fresh one, it is back to starting with pp's (permanent) currentdir.

Similarly if you do this in PP's tiny run box:
do("cmd",?"/c cd C:\folder")
it has no effect on powerpro's currentdir.

-------------------------------------------------------------




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/JV_rlB/TM
--------------------------------------------------------------------~-> 

Attention: PowerPro's Web site has moved: http://www.ppro.org 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/power-pro/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to