- 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.
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:
The first command should have turned into
Here's what happens when the order of the two commands is reversed.
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:
Reversing the order gives:
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.
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?
Those spaces are not normally required (see below), so I think there is some kind of bug.
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".]
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".]