DosTips.com

A Forum all about DOS Batch
It is currently 25 Jun 2017 04:21

All times are UTC-06:00




Post new topic  Reply to topic  [ 13 posts ] 
Author Message
PostPosted: 11 Feb 2017 06:16 
Offline

Joined: 24 Jun 2013 17:10
Posts: 429
Location: Bulgaria
these variables are not accessible - CMDCMDLINE , TIME , DATE , RANDOM , ERRORLEVEL , CMDEXTVERSION , CD (but __CD__ is still there)


COLOR command is not working.


Last edited by npocmaka_ on 11 Feb 2017 09:42, edited 1 time in total.

Top
   
PostPosted: 11 Feb 2017 07:07 
Offline

Joined: 23 Jun 2013 06:15
Posts: 1337
Location: Germany
The following is not undocumented - but the documentation is just wrong (at least the german version).

The setlocal always accepts the command line arguments (even if extensions are disabled):
- "enableExtensions" and
- "enableDelayedExpansion".


penpen


Top
   
PostPosted: 11 Feb 2017 07:11 
Offline
Expert

Joined: 22 Jan 2010 18:01
Posts: 2672
Location: Germany
It's interesting that the color command doesn't work :?

As to the dynamic variables - actually it's documented behavior. Have a look at the help message of SET. The explanation of these variables begins with "If Command Extensions are enabled ...".
http://www.dostips.com/DosCommandIndex.php#SET

Steffen


Top
   
PostPosted: 11 Feb 2017 09:47 
Offline

Joined: 24 Jun 2013 17:10
Posts: 429
Location: Bulgaria
aGerman wrote:
As to the dynamic variables - actually it's documented behavior. Have a look at the help message of SET. The explanation of these variables begins with "If Command Extensions are enabled ...".
http://www.dostips.com/DosCommandIndex.php#SET

Steffen


I should read the documentation more carefully.
Though for the color I've found nothing.


Top
   
PostPosted: 11 Feb 2017 11:30 
Offline

Joined: 08 Jan 2014 07:29
Posts: 23
COLOR, ASSOC and FTYPE are associated to command extensions but are not documented as dependent on them.


Top
   
PostPosted: 11 Feb 2017 14:25 
Offline

Joined: 24 Jun 2013 17:10
Posts: 429
Location: Bulgaria
mcnd wrote:
COLOR, ASSOC and FTYPE are associated to command extensions but are not documented as dependent on them.

So assoc and ftype will not work also?

EDIT
Just tried. They are not working. Thanks for the info.


Top
   
PostPosted: 12 Feb 2017 11:18 
Offline

Joined: 01 Oct 2012 13:32
Posts: 176
Location: Ireland
Hello All! :)

Interesting discussion. I’d like to add the following observations made while extensions were disabled.

The PROMPT command doesn’t work. Neither does:

Code: Select all
set "prompt=@"


Otoh…

Code: Select all
set prompt=@


does work. :?

And another thing I’ve noticed is that if there are 2 labels with the same name, GOTO will jump to the 2nd label. Yet another example of CMD’s eccentric behaviour.

BFN!

- SB


Top
   
PostPosted: 12 Feb 2017 12:50 
Offline
Expert

Joined: 30 Aug 2007 08:05
Posts: 825
Location: Germany, Bochum
Code: Select all
set "prompt=something"

Fails as the extended SET-syntax is no longer valid in the disbaled extension context.

I can't reproduce your goto :label problem.
I can't believe it, as any goto normally starts a search from the current file position to the first matching label.

Code: Select all
@echo off
setlocal DisableExtensions

goto :myLabel

:myLabel
echo First
goto :eof

:myLabel
echo Second
goto :eof

:eof


This outputs, as expected, "First".

Btw. You need to define the :eof label, as it doesn't exists without extensions.
Curious is the error message of "exit /b" in this context.
Free translation from german wrote:
The label - :EOF can't be found


Top
   
PostPosted: 12 Feb 2017 14:20 
Offline

Joined: 24 Jun 2013 17:10
Posts: 429
Location: Bulgaria
jeb wrote:

Btw. You need to define the :eof label, as it doesn't exists without extensions.
Curious is the error message of "exit /b" in this context.
Free translation from german wrote:
The label - :EOF can't be found


So exit uses goto to find the end of the file?

Should this mean that goto :eof works faster than exit /b ?


Top
   
PostPosted: 12 Feb 2017 14:30 
Offline
Expert

Joined: 22 Jan 2010 18:01
Posts: 2672
Location: Germany
npocmaka_ wrote:
Should this mean that goto :eof works faster than exit /b ?

Most likely. Since you can pass a return value to exit /b the cmd has to evaluate a potential 3rd argument.

Steffen


Top
   
PostPosted: 12 Feb 2017 15:23 
Offline

Joined: 01 Oct 2012 13:32
Posts: 176
Location: Ireland
Hi Again! :)

I noticed the GOTO glitch when playing around with the code developed in the Foolproof Counting of Arguments topic. I’ve boiled it down to this:

Code: Select all
@echo off & setlocal enableextensions disabledelayedexpansion

(
goto skip
:skip
echo(first label
)

:skip
echo(second label

endlocal & goto :eof


The first ECHO statement is skipped, but change the second label name and both ECHO statements will be executed! :o

Btw, I had to revise this post with simpler code… twice! I now realise this phenomenon has nothing to do with disabled extensions. :oops:

- SB


Last edited by Sponge Belly on 14 Feb 2017 12:58, edited 1 time in total.

Top
   
PostPosted: 12 Feb 2017 17:22 
Offline

Joined: 23 Jun 2013 06:15
Posts: 1337
Location: Germany
Sponge Belly wrote:
The ampersand (&) can’t be used as command separator when extensions are disabled.
What do you mean, by saying the above?
The following should work as always: "&", "&&", "|", "||".


The command line interpreter must read the complete "for"-loop before it is able to execute it.
Because of that the filepointer is in the line after the ")", and the next ":skip" label is the second in the batch.

If you change the second label, then the cli will find the only ":skip"-label in this batch, because it is not in the same line as the ")" line.


penpen


Top
   
PostPosted: 14 Feb 2017 13:11 
Offline

Joined: 01 Oct 2012 13:32
Posts: 176
Location: Ireland
Hi Penpen,

Thanks for explaining GOTO’s mysterious behaviour. And you don’t need the body of a FOR loop or an IF block. An unconditional parenthesized block will do. See my previous post for a simplified code example.

And you’re right about the ampersand as command separator. I don’t know what I was thinking. I've removed the erroneous postscript from my previous post. :oops:

Finally, GOTO :EOF will work with extensions disabled, but :EOF must be in capitals.

- SB


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 13 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: mogodan2008, Yahoo [Bot] and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited