Page 1 of 1
A big question
Posted: 08 Sep 2010 04:05
by darioit
I was going crazy about this issue
why this code works
Code: Select all
IF %REC4% EQU y (
CALL :check_total %2 %~nx2
) ELSE (
>> %REP%\%SEND%.%O%.%REP% ECHO.%BLABLA3%
CALL Routine_Info.BAT %1 %~nx2
>> %LOGS%\LOG_%DD0%.LOG ECHO 0 %DD2% %shh1%:%smm1%:%sss1%.%sms1% %~nx2 %DEAL% %MI% %O% %CX% %CP% %~nx2 %~t2 %~z2
MOVE /Y %nome_file_input% %SND%
)
instead this one doesn't work (the only differences is :: in the MOVE command
Code: Select all
IF %REC4% EQU y (
CALL :check_total %2 %~nx2
) ELSE (
>> %REP%\%SEND%.%O%.%REP% ECHO.%BLABLA3%
CALL Routine_Info.BAT %1 %~nx2
>> %LOGS%\LOG_%DD0%.LOG ECHO 0 %DD2% %shh1%:%smm1%:%sss1%.%sms1% %~nx2 %DEAL% %MI% %O% %CX% %CP% %~nx2 %~t2 %~z2
:: MOVE /Y %nome_file_input% %SND%
)
Thanks
Re: A big question
Posted: 08 Sep 2010 04:17
by jeb
In a paranthesis block it is not allowed to place a label as the last command.
a :: is used like a comment, but it is an uncallable label
If you use "rem" instead, it should work.
Re: A big question
Posted: 08 Sep 2010 04:21
by darioit
For shure I use a REM instead double point, I have learned a new thing
Best
Dario
Re: A big question
Posted: 08 Sep 2010 05:21
by orange_batch
Yes, :: should be used for text comments outside of brackets ().
rem should be used to disable a command for testing.
Re: A big question
Posted: 09 Sep 2010 13:55
by jeb
But, rem is "stronger" than ::
Code: Select all
rem one two three ^
echo This line is displayed
:: one two three ^
echo This line will not displayed
rem "This is one token"^
echo This line will not displayed
With :: or other labels, the multiline always work.
With rem, it only works with the first token.
And in both variants all percents are expanded and can create errors
Code: Select all
rem one two three %~q1
output:
Die folgende Verwendung des Pfadoperators zur Ersetzung eines Batchparameters
ist ungültig: %~q1
Re: A big question
Posted: 09 Sep 2010 15:31
by orange_batch
Yes, however I'm no fan of putting expandable variables or odd characters into comments unnecessarily. This shouldn't really be done.

If only DOS weren't rife with self-retardisms! lol
Re: A big question
Posted: 11 May 2011 00:26
by amel27
During experiments with labels and parentheses has come across the "magic" line of code, that "dements" CMD.EXE if it place at the end of BAT file without trailing CRLF.
I hope that somebody can explain such behavior.
Re: A big question
Posted: 13 May 2011 03:13
by jeb
Hi amel27,
amel27 wrote:During experiments with labels and parentheses has come across the "magic" line of code, that "dements" CMD.EXE if it place at the end of BAT file without trailing CRLF.
Code:
(.&:Any Text
It doesn't depend of CRLF it is an effect of the missing closing bracket.
A block with a missing closing bracket is completly ignored.
jeb
Re: A big question
Posted: 13 May 2011 04:06
by amel27
jeb wrote:It doesn't depend of CRLF it is an effect of the missing closing bracket.
A block with a missing closing bracket is completly ignored.
Hi jeb,
effect in the following: with CRLF at the end of this line/file script finished quickly... but without CRLF "hang" on seconds (on XP) or generate system error (on Windows 7). FileMon tool on XP show thousands attempts of read operations outside of a file before script end.
Re: A big question
Posted: 13 May 2011 05:34
by jeb
Ok,
in my last post I missed the point
But there is another interessting character effect with <NULL>.
If I place a <NULL> into my batch, the parser ignores some hundred characters after the <NULL> and restarts parsing later.
jeb