[Date Prev][Date Next][Subject Prev][Subject Next][ Date Index][ Subject Index]

Re: Programming Query: Stripdir



Reply to note from Patricia M Godfrey  Sun, 31
Oct 2004 15:20:56 -0500

Patricia:

> It works fine if I follow Run myprog.pgm by hitting the
> Return/Enter key. But if I hit F9, I get an error message,
> "File not found"--and the filename being sought is a
> reiteration of the directory name. For example, say my Stripdir
> result window shows, among other files, one called
> E:\xyinfo\2004\myposts\zvread.rtf the "File not found" is
> listed as e:\xyinfo\2004\myposts\e:\xyinf.200
>
> I suspect some variable-contents conflicts, but cannot figure
> out what.

It's not a Save/Get conflict. Remember that the screen that
STRIPDIR displays -- even after STRIPDIR edits it -- is still a
DIRectory (VA$WS=2). What you're seeing is a bad interaction
between STRIPDIR and the "point-and-shoot" capability of DIRectory
screens. By "point-and-shoot", I mean, for example, when you put a
bare CA command on the CMline, point at a filename in a DIRectory
and hit the eXeCute key, and the file is opened for editing. To do
this, Editor grabs the filename from the DIR list, using an internal
call to VA$DR. But, in your example, the modification by STRIPDIR
causes VA$DR to misinterpret the filename.

You can verify this with a little experiment. Issue a DIR command,
put the cursor on a filename, and issue (on the CMline): VA/NV $DR.
The (correct) fully-qualified path and filename is returned on the
PRompt line. Now run STRIPDIR P against that DIR listing,
put the cursor on the same filename and issue VA/NV $DR again. This
time, Editor mangles the filename -- the same sort of error you
encountered. Bottom line: VA$DR can't handle a DIR listing that's
been modified by STRIPDIR.

But you don't need STRIPDIR, Patricia, to do what you want to do.
Simply use VA$DR to lift the path and filename from the DIRectory
screen. Here's an example. Suppose you want to CAll a file from a
DIRectory list. Issue the DIR command and position the cursor on
the filename. Then do:

BC caXC ;*;

or, even better:

>BX ca Q2 ;*;

The latter is preferable because it uses BX instead of BC. BX is
faster, and doesn't destroy any existing CMline.

To answer your first question: STRIPDIR wasn't really designed to be
used as a subroutine, but if you ever need to use it that way,
here's how. Note that the argument (F or P) is passed via Save/Get
50:

BX dirQ2 JM 2.stripdirQ2 ;*;

Here's the same thing in "live" XPL, in case you want to see it in
action. Import the block of code below into XyWrite, DECODE it,
DeFine the resulting XPL code, and issue RUNCODE.

XPLeNCODE v2.0
b-gin [UNTITLED]
[BX_]dir[Q2_]{<}SV50,P{>}[JM_]2.stripdir[Q2_]{<}EX{>};*;[cr|l
f][cr|lf]
-nd
XPLeNCODE

Hope this helps.

--
Carl Distefano
cld@xxxxxxxx