npocmaka
After the my little game here ->
Code: Select all
@echo off
::^
echo this will not be printed
::^
echo neither this
rem do not set empty line or other symbols at the end
::>(^
Code: Select all
@echo off
if 1 EQU 1 (
echo this will be printed
::this bellow is not exactly a comment /and this line will constantly print an error for not found device/
::)
) esle (
echo unfortunately this also
)
By the way
Code: Select all
:&
:>
:<
:|
Last edited by npocmaka (03 Nov 2012 12:48)
----------------------------
#2 04 Nov 2012 08:46
jeb
The simple cause, it's not possible as you created empty labels.npocmaka wrote:
By the way
I couldn't find a way to access line starts with these neither with goto nor with call (is it possible?).Anyway ^ at the end still can spoil everything .Code: Select all
:& :> :< :|
Like in ::, also &<>| are stop characters in a labelname, they do not belong to the name.
You can test it with.
Code: Select all
goto :myLabel
:myLabel&xyz
echo Label found
exit /b
----------------------------
#3 04 Nov 2012 14:37
Simon Sheppard
Whats happening here will affect any label. I think the command processor is expecting (not unreasonably) that a label will be followed by at least one command before the code block is ended with a closing bracket. That way if you jump to the label it will have something to execute.
Code: Select all
@echo off
if 1 EQU 1 (
Echo this will be printed
::this is a comment
:mylabel
Echo All done
) else (
Echo this wont print
)
Last edited by Simon Sheppard (04 Nov 2012 14:52)
----------------------------
#4 04 Nov 2012 18:38
npocmaka
Thanks Simon.
At least the error message can be avoided ( it's a potential place where break can be used :D ).
But my main ache keeps to be the broken brackets context..
Inside brackets this will work:
Code: Select all
rem comment )
Code: Select all
::comment )
(As i find this while I've tried to comment a nested IF - it could be confusing)
@Jeb:
So the they can be used as a comments with same success as semi columns ?Except that they will be not typed so fast.
Last edited by npocmaka (04 Nov 2012 19:06)
----------------------------
#5 04 Nov 2012 19:18
Simon Sheppard
And heres a strange thing
These will fail
Code: Select all
(
:label1
)
Code: Select all
(
:label1
)
But this will work
Code: Select all
(
:: any comment
:label1
)
#6 04 Nov 2012 19:32
npocmaka
here's jeb's explanation
https://ss64.org/viewtopic.php?f=2&t=118
----------------------------
#7 04 Nov 2012 23:01
carlos
:: (double dot)(double dot)
Technically it is not a comment, it is a empty label, that can be followed by text that is ignored, because a label occupies all the line.
In windows Nt the labels inside a batch file have a max length of 10 characters. It begin with the double dot (:) character and ends with a space character or the double dot(:) character.
A label call referenced by the name, optionally ending the name with a double dot (:) character.
If you use a label or empty label inside brackets you need followed it with a internal or external command.
Works:
Code: Select all
(
::empty_label_1
echo.inside
)
(
::empty_label_1
rem
::empty_label_2
echo.inside
)
Code: Select all
(
::empty_label_1
::empty_label_2
echo.inside
)
----------------------------
#8 04 Nov 2012 23:48
Simon Sheppard
I'm sure that under XP you can have labels over 100 characters longcarlos wrote:
In windows Nt the labels inside a batch file have a max length of 10 characters. It begin with the double dot (:) character and ends with a space character or the double dot(:) character.
goto :abcdefghijklmnopqrstuvwxyz
:abcdefghijklmnopqrstuvwxyz
echo abcdefghijklmnopqrstuvwxyz
Interesting about the : terminator, but also CR/LF will terminate the label.
----------------------------
#9 05 Nov 2012 01:44
carlos
I remember that in windows xp you can have a labels with more than 10 characters, but when you call it with goto or call it only read the first ten characters (in windows nt are 8), because it, in windows xp the labels:Simon Sheppard wrote:
I'm sure that under XP you can have labels over 100 characters long
goto :abcdefghijklmnopqrstuvwxyz
:abcdefghijklmnopqrstuvwxyz
echo abcdefghijklmnopqrstuvwxyz
Interesting about the : terminator, but also CR/LF will terminate the label.
:label67890
:label67890a
:label67890b
are the same, but apparently it was changed in windows 7.
Last edited by carlos (05 Nov 2012 01:46)
----------------------------
#10 05 Nov 2012 19:05
Simon Sheppard
I tested this on Windows 2008 and XP sp3, it looks like the limit for a label is 127 characters
Code: Select all
@echo off
goto abcdefghijklmnopqrstuvqxyzabcdefghijklmnopqrstuvqxyzabcdefghijklmnopqrstuvqxyzabcdefghijklmnopqrstuvqxyzabcdefghijklmnopqrstuv
echo start
:abcdefghijklmnopqrstuvqxyzabcdefghijklmnopqrstuvqxyzabcdefghijklmnopqrstuvqxyzabcdefghijklmnopqrstuvqxyzabcdefghijklmnopqrstuv1
echo middle
:abcdefghijklmnopqrstuvqxyzabcdefghijklmnopqrstuvqxyzabcdefghijklmnopqrstuvqxyzabcdefghijklmnopqrstuvqxyzabcdefghijklmnopqrstuv
echo end
Online