Welcome!

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

SignUp Now!

WAD Compound Commands Not Expanded Properly with FOLDERMONITOR

Jun
760
16
The material below was written but could not be sent because the forum software went down. It shows the stream of experiments I did to try to figure out what was going on. The final answer is that something is wrong with the way a compound command is handled by FOLDERMONITOR. If there is a space after the opening left parenthesis and before the closing right parenthesis, the command is processed correctly. When those spaces are absent, strange things happen. This problem does not exist with the similar DATEMONITOR command.



When the command to be executed by FOLDERMONITOR is a compound command, commands after a command separator are not processed the way the first command is.

foldermonitor folder ... (cmd1 & cmd2)

Most noticeably, percent signs in the first command are interpreted, while those in the second command are not. So those in the first command have to be doubled if meant literally, while those in the second command must not be doubled.

Actually, I'm not sure that either command is interpreted properly in a compound command. Here's an example:

Code:
TCC33.00.20 C:\temp>fm /c & fm %_cwd created (beep 440 %%tbeep & set tbeep=8) & fm
C:\temp   created (beep   (0/440)   %tbeep & set tbeep=8)

The first command should have turned into beep 400 %tbeep (tbeep had been set to 8 previously). Instead it became beep (0/440) %tbeep, which pops an error message about "8" not being a valid command when it executes.

Here's what happens when the order of the two commands is reversed.

Code:
TCC33.00.20 C:\temp>fm /c & fm %_cwd created (set tbeep=8 & beep 440 %%tbeep) & fm
C:\temp   created (set tbeep=8 & beep   (0/440)   %%tbeep)

Now the %%tbeep comes through with the percent signs left as entered. Again the command pops an error message, but this time it objects to the command "8))".

If I enter the compound command as described in the help, I get this:

Code:
TCC33.00.20 C:\temp>fm %_cwd created deleted forever (
More? set tbeep=8
More? beep 400 %%tbeep
More? )
TCC33.00.20 C:\temp>fm
C:\temp   created deleted   (0/FOREVER)   ( set tbeep=8 & beep 400 %%tbeep )

Reversing the order gives:

Code:
TCC33.00.20 C:\temp>fm %_cwd created deleted forever (
More? beep 440 %%tbeep
More? set tbeep=8
More? )

TCC33.00.20 C:\temp>fm
C:\temp   created deleted   (0/FOREVER)   ( beep 440 %%tbeep & set tbeep=8 )

Ah, this time there is no difference (and apparently one need not double the percent signs). The problem seems to arise when a compound command is entered on the command line. One can enter multiple commands, so that's not the issue.

Code:
TCC33.00.20 C:\temp>fm %_cwd created deleted forever (
More? set tbeep=8 & beep 440 %tbeep
More? )

TCC33.00.20 C:\temp>fm
C:\temp   created deleted   (0/FOREVER)   ( set tbeep=8 & beep 440 %tbeep )

Aha! The compound command can be entered on the command line provided there are spaces separating the commands from the parentheses. Those spaces displayed by the command with no argument are apparently not just just for readability. But why are the spaces needed?

Code:
TCC33.00.20 C:\temp>fm %_cwd created deleted forever ( set tbeep=8 & beep 400 %tbeep )

TCC33.00.20 C:\temp>fm
C:\temp   created deleted   (0/FOREVER)   ( set tbeep=8 & beep 400 %tbeep )

Those spaces are not normally required (see below), so I think there is some kind of bug.

Code:
TCC33.00.20 C:\temp>do i = 1 to 3 (echos one & echo two)
onetwo
onetwo
onetwo

TCC33.00.20 C:\temp>for %i in (1 2 3) do (echos one & echo two)
onetwo
onetwo
onetwo

TCC33.00.20 C:\temp>if a EQ a (echos one & echo two)
onetwo

I experimented with the similar DATEMONITOR command, and it does not have this problem. Command groups can be entered with no extra spacing around the parentheses. When the command is built using multi-line input, the display when DATEMONITOR is entered with no arguments does have the extra spaces, but they are not needed for the compound command to work correctly.

[There's a teeny mistake in the help for DATEMONITOR. The second "Format" line has "yyyy-m-dd" instead of "yyyy-mm-dd".]
 
This example and another in your last post are missing the n|FOREVER.

TCC33.00.20 C:\temp>fm /c & fm %_cwd created (beep 440 %%tbeep & set tbeep=8) & fm C:\temp created (beep (0/440) %tbeep & set tbeep=8)
 
The material below was written but could not be sent because the forum software went down. It shows the stream of experiments I did to try to figure out what was going on. The final answer is that something is wrong with the way a compound command is handled by FOLDERMONITOR. If there is a space after the opening left parenthesis and before the closing right parenthesis, the command is processed correctly. When those spaces are absent, strange things happen. This problem does not exist with the similar DATEMONITOR command.

Not reproducible here. I suspect that either your alias (I presume you're aliasing fm to foldermonitor?) is incorrect, or you are not using the correct syntax for FOLDERMONITOR.

Your first two examples are missing the count (i.e., n or FOREVER) which will throw off the parsing (and result in part of the command being interpreted as a count).

The command grouping parsing is global (not specific to FOLDERMONITOR).
 
Sorry, but I don't think that this is normal behavior.

Code:
TCC33.00.20 C:\temp>alias fm
foldermonitor

TCC33.00.20 C:\temp>fm /c & fm c:\temp\ created forever (echo %%tbeep & echo %%tbeep) & fm
c:\temp\   created   (0/FOREVER)   (echo %tbeep & echo %%tbeep)

In the first command, %% becomes %, but not in the second command. I thought that it worked when spaces were added, but that doesn't seem to be the case now.

Code:
TCC33.00.20 C:\temp>fm /c & fm c:\temp\ created forever ( echo %%tbeep & echo %%tbeep ) & fm
c:\temp\   created   (0/FOREVER)   ( echo %tbeep & echo %%tbeep )

And, indeed, DATEMONITOR behaves the same way.

Code:
TCC33.00.20 C:\temp>datemonitor 2024-12-30 00:49 forever (echo %%tbeep & echo %%tbeep)

TCC33.00.20 C:\temp>dm
2024-12-30 00:49   (0/FOREVER)   (echo %tbeep & echo %%tbeep)

Am I misunderstanding something here? My brain has been in a bit of a fog for the past few days.

This is not the general behavior of compound commands.

Code:
TCC33.00.20 C:\temp>if a eq a (echo %%tbeep & echo %%tbeep)
%tbeep
%tbeep

Both double percents became single percents. With FILEMONITOR and DATEMONITOR the first one echos "8", while the second one echos "%tbeep".
 
I was correct when I said that the behavior is different when the commands are entered on separate lines.

Code:
TCC33.00.20 C:\temp>fm c:\temp\ created forever (
More? echo %%tbeep
More? echo %%tbeep
More? )

TCC33.00.20 C:\temp>fm
c:\temp\   created   (0/FOREVER)   ( echo %%tbeep & echo %%tbeep )

Ah, but the problem does appear when multiple commands are entered at the "More?" prompt.

Code:
TCC33.00.20 C:\temp>fm /c & fm c:\temp created forever (
More? echo %%tbeep & echo %%tbeep
More? )

TCC33.00.20 C:\temp>fm
c:\temp   created   (0/FOREVER)   ( echo %tbeep & echo %%tbeep )

So it does seem to be related to multiple commands in a string.
 
Back
Top