Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Food for thought?

May
12,845
164
Comments welcome.

A command line DO?

Code:
v:\> cdo `i=1 to 2 ; do j=1 to 2 ; echos %i & echo %j ; enddo ; enddo`
11
12
21
22
If you don't like the default line separator, ";", specify your own:

Code:
v:\> cdo /! `i=1 to 2 ! do j=1 to 2 ! echos %i & echo %j ! enddo ! enddo`
11
12
21
22
The tail of the DO command must be in `backticks`, but ^k will get around that (at least in many cases):

Code:
v:\> cdo `i=1 to 2 ; do j=1 to 2 ; echos %i^k  ^k & echo %j ; enddo ; enddo`
1  1
1  2
2  1
2  2
Other things inside the `command` should be safe (?):

Code:
v:\> cdo `f in *.zip ; echo %f %@filesize["%f"] ; enddo`
4console.zip 5543374
4utils.zip 53817
a b.zip 119
gcolon.zip 5195737
ipv4.zip 404824
jlc.zip 123
jpnews.zip 14501646
There's no exotic technology at work here. CDO writes a batch file, executes it, and deletes it. As I said, comments welcome.
 
vefatica wrote:
| Comments welcome.
|
| A command line DO?
|
|
| Code:
| ---------
| v:\> cdo `i=1 to 2 ; do j=1 to 2 ; echos %i & echo %j ; enddo ;
| enddo` 11
| 12
| 21
| 22
| ---------
| If you don't like the default line separator, ";", specify your own:
|
|
| Code:
| ---------
| v:\> cdo /! `i=1 to 2 ! do j=1 to 2 ! echos %i & echo %j ! enddo !
| enddo` 11
| 12
| 21
| 22
| ---------
| The tail of the DO command must be in `backticks`, but ^k will get
| around that (at least in many cases):
|
|
| Code:
| ---------
| v:\> cdo `i=1 to 2 ; do j=1 to 2 ; echos %i^k ^k & echo %j ; enddo
| ; enddo` 1 1
| 1 2
| 2 1
| 2 2
| ---------
| Other things inside the `command` should be safe (?):
|
|
| Code:
| ---------
| v:\> cdo `f in *.zip ; echo %f %@filesize["%f"] ; enddo`
| 4console.zip 5543374
| 4utils.zip 53817
| a b.zip 119
| gcolon.zip 5195737
| ipv4.zip 404824
| jlc.zip 123
| jpnews.zip 14501646
| ---------
| There's no exotic technology at work here. CDO writes a batch file,
| executes it, and deletes it. As I said, comments welcome.

Sounds intriguing, esp. if there is a way to specify where the temporary
file is created, e.g., on a virtual disk. BTW, would you pls. give a
complete listing (including CRC and full path) of the current versions of
your plugins? I suspect I am way behind! If you could also include such
arcane details as the 4NT/TCC version required for each...
--
Steve
 
On Fri, 30 Oct 2009 06:32:13 -0500, Steve Fábián <> wrote:

|| There's no exotic technology at work here. CDO writes a batch file,
|| executes it, and deletes it. As I said, comments welcome.
|
|Sounds intriguing, esp. if there is a way to specify where the temporary
|file is created, e.g., on a virtual disk. BTW, would you pls. give a
|complete listing (including CRC and full path) of the current versions of
|your plugins? I suspect I am way behind! If you could also include such
|arcane details as the 4NT/TCC version required for each...

Is there a problem with a file existing in the current directory for (probably)
a split second?

I'm (naively) thinking that Rex could do the same (as CDO) for DO. If the first
word on a command line is "DO", instead of the "only in batch files" message,
the command line would be completely exempt from parsing (thus no backticks
needed) ... simply written to a file, executed, deleted. I know it's ugly but
it adds some functionality.

No. They change too often for me to keep track of. In a nutshell, those in the
"4plugins" folder should work with older versions and those in "4plugins/vc9"
should work with v11. There are exceptions. I've lost track of 4autotray, and
the special version made for you. It might be that some haven't been updated
for v11 because no one has mentioned thay they need to be updated. Any
significant changes will only be made to the ones in "vc9" and will be
announced. In general, there's no need to have "the latest".
--
- Vince
 
vefatica wrote:
| Is there a problem with a file existing in the current directory for
| (probably) a split second?

Yes - it may not be writable, e.g., a CD-ROM. Using %temp of %tmp would be
much safer.

| I'm (naively) thinking that Rex could do the same (as CDO) for DO.
| If the first word on a command line is "DO", instead of the "only in
| batch files" message, the command line would be completely exempt
| from parsing (thus no backticks needed) ... simply written to a
| file, executed, deleted. I know it's ugly but it adds some
| functionality.

Sounds good to me...

| No. They change too often for me to keep track of. In a nutshell,
| those in the "4plugins" folder should work with older versions and
| those in "4plugins/vc9" should work with v11. There are exceptions.

OK.

| I've lost track of 4autotray, and the special version made for you.

Works fine with V11. So does the SHRALIAS.EXE which saves tables in ASCII.

| It might be that some haven't been updated for v11 because no one
| has mentioned thay they need to be updated. Any significant changes
| will only be made to the ones in "vc9" and will be announced. In
| general, there's no need to have "the latest".

You did announce some new features which I may not have downloaded, which is
why I asked what's current. I'll just download anything newer than I have.

Thanks!
--
Steve
 
On Fri, 30 Oct 2009 09:58:42 -0500, Steve Fábián <>
was claimed to have wrote:


>vefatica wrote:
>| Is there a problem with a file existing in the current directory for
>| (probably) a split second?
>
>Yes - it may not be writable, e.g., a CD-ROM. Using %temp of %tmp would be
>much safer.

Or it might be a slow network drive, or worse, I might have write
permissions but not delete permissions.
 
On Fri, 30 Oct 2009 11:31:08 -0500, thedave <> wrote:

|---Quote---
|>vefatica wrote:
|>| Is there a problem with a file existing in the current directory for
|>| (probably) a split second?
|>
|>Yes - it may not be writable, e.g., a CD-ROM. Using %temp of %tmp would be
|>much safer.
|---End Quote---
|Or it might be a slow network drive, or worse, I might have write
|permissions but not delete permissions.

Not wanting to complicate the command line, I could use GetTempPath() which
works like this:

Remarks
The GetTempPath function checks for the existence of environment variables in
the following order and uses the first path found:

The path specified by the TMP environment variable.
The path specified by the TEMP environment variable.
The path specified by the USERPROFILE environment variable.
The Windows directory.
Note that the function does not verify that the path exists.

Symbolic link behavior—If the path points to a symbolic link, the temp path name
maintains any symbolic links.

Another thought ... with a plugin keystroke handler, I could look for <Enter>.
If <Enter> is found and the first word on the command line is "DO" I could

1. write the command line to a batfile
2. change the command line to the name of the batch file
3. return, indicating that the command (now the batfile name) should be executed

With this approach, the user could use "DO" and wouldn't have to worry about the
command line being parsed (so no need for backticks). But I'm not sure how I'd
delete the batch file when it's all over.
--
- Vince
 
vefatica wrote:
| Not wanting to complicate the command line, I could use
| GetTempPath() which works like this:
|
| Remarks
| The GetTempPath function checks for the existence of environment
| variables in the following order and uses the first path found:
|
| The path specified by the TMP environment variable.
| The path specified by the TEMP environment variable.
| The path specified by the USERPROFILE environment variable.
| The Windows directory.
| Note that the function does not verify that the path exists.
|
| Symbolic link behaviorIf the path points to a symbolic link, the
| temp path name maintains any symbolic links.

Seems perfect. AFAIK there are many programs which use TMP and TEMP. Unless
the user either deleted the variables or changed them to point into the
abyss, they are always defined and point to a fullly accessible directory.
CAVEAT EMPTOR!

| Another thought ... with a plugin keystroke handler, I could look
| for <Enter>. If <Enter> is found and the first word on the command
| line is "DO" I could
|
| 1. write the command line to a batfile
| 2. change the command line to the name of the batch file
| 3. return, indicating that the command (now the batfile name) should
| be executed
|
| With this approach, the user could use "DO" and wouldn't have to
| worry about the command line being parsed (so no need for
| backticks). But I'm not sure how I'd delete the batch file when
| it's all over.

Not KISS! Your original idea is just fine. BTW, on my desktop system TMP
sometimes points to a directory on a virtual drive, so it is cleared on
every restart.
--
Steve
 
I agree that GetTempPath ought to be a good place to put it.

On Fri, Oct 30, 2009 at 10:38 AM, Steve Fábián <> wrote:

> vefatica wrote:
> | Not wanting to complicate the command line, I could use
> | GetTempPath() which works like this:
> |
> | Remarks
> | The GetTempPath function checks for the existence of environment
> | variables in the following order and uses the first path found:
> |
> | The path specified by the TMP environment variable.
> | The path specified by the TEMP environment variable.
> | The path specified by the USERPROFILE environment variable.
> | The Windows directory.
> | Note that the function does not verify that the path exists.
> |
> | Symbolic link behaviorIf the path points to a symbolic link, the
> | temp path name maintains any symbolic links.
>
> Seems perfect. AFAIK there are many programs which use TMP and TEMP. Unless
> the user either deleted the variables or changed them to point into the
> abyss, they are always defined and point to a fullly accessible directory.
> CAVEAT EMPTOR!
>
> | Another thought ... with a plugin keystroke handler, I could look
> | for <Enter>. If <Enter> is found and the first word on the command
> | line is "DO" I could
> |
> | 1. write the command line to a batfile
> | 2. change the command line to the name of the batch file
> | 3. return, indicating that the command (now the batfile name) should
> | be executed
> |
> | With this approach, the user could use "DO" and wouldn't have to
> | worry about the command line being parsed (so no need for
> | backticks). *But I'm not sure how I'd delete the batch file when
> | it's all over.
>
> Not KISS! Your original idea is just fine. BTW, on my desktop system TMP
> sometimes points to a directory on a virtual drive, so it is cleared on
> every restart.
> --
> Steve
>
>
>
>
>



--
Jim Cook
2009 Saturdays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
Next year they're Sunday.
 
Back
Top