Search found 917 matches

by jeb
13 Sep 2017 07:02
Forum: DOS Batch Forum
Topic: Variable expansion inside :: comments?
Replies: 10
Views: 2624

Re: Variable expansion inside :: comments?

Is there any way to catch such errors and take remedial action? I see no way to catch the error with batch itself, as this kind of syntax errors stops the batch file immediately, even the setlocal stack remains unchanged. This can enable delayed expansion for the command line! To catch it you can u...
by jeb
30 Aug 2017 05:14
Forum: DOS Batch Forum
Topic: string extraction from number N to the end of string, must handle % \ , . :: " :
Replies: 10
Views: 2028

Re: string extraction from number N to the end of string, must handle % \ , . :: " :

The strlen function works and it's being right to say "6". As SET IN=%C1%\12345 results into setting \12345 to "IN". The %C1% will be expanded to the content of the C1 variable, but in your case it seems to be empty. To set the variable use this set "IN=%%C1%%\12345" I ...
by jeb
12 Jun 2017 05:21
Forum: DOS Batch Forum
Topic: Unexepected output from Timeout command
Replies: 6
Views: 1634

Re: Unexepected output from Timeout command

There is also a flaw in the timeout implementation, when the time/date is changed while the countdown is running, then the remaining seconds are changed. Obviously the remaining seconds is calculated by something like remaing_sec=stop_timestamp - current_time On a Windows7 you can produce simply big...
by jeb
28 May 2017 09:17
Forum: DOS Batch Forum
Topic: Move cursor to *any position* using just ECHO command
Replies: 10
Views: 10800

Re: Move cursor to *any position* using just ECHO command

Fascinating! I didn't recognized the originial thread before. But it's so easy with the TAB character. I'm astonished that nobody tries this before, many thankst to nerobin @Aacini I tried your tab creation with reg.exe, but it doesn't work for me with XP32-German. But I build a version with shutdow...
by jeb
31 Mar 2017 09:38
Forum: DOS Batch Forum
Topic: doskey history behaviour across cmd instances
Replies: 4
Views: 1693

Re: doskey history behaviour across cmd instances

I'm using Windows 7 x64, and it's all reliable reproducable for me.

I always open a new cmd window and paste the complete text into the window.

jeb
by jeb
31 Mar 2017 06:22
Forum: DOS Batch Forum
Topic: doskey history behaviour across cmd instances
Replies: 4
Views: 1693

doskey history behaviour across cmd instances

Npocmaka asked an interessting question SO: Why `cmd /k` and `cmd /c` remember the history of already finished cmd sub-processes? The answer seems to be well-founded, but it doesn't explain some of the behaviour I saw in my experiments. echo Main cmd /k echo sub1 echo sub2 doskey /history exit doske...
by jeb
30 Mar 2017 11:07
Forum: DOS Batch Forum
Topic: Examination of Linefeeds with CALL
Replies: 18
Views: 6165

Re: Examination of Linefeeds with CALL

Actually, results 1 and 3 are exactly what I expect. Maybe the language could be improved, but I don't think the Percent expansion logic needs to change. Okay, after reading it again, I see your point. Side note - I never saw any feedback from you regarding my attempted extension of the SO answer t...
by jeb
22 Mar 2017 09:45
Forum: DOS Batch Forum
Topic: Examination of Linefeeds with CALL
Replies: 18
Views: 6165

Re: Examination of Linefeeds with CALL

I'm still thinking that this is true. A phase 0.5 can't exists, but my best guess is that the percent phase must be combined with phase 0.5 1) Phase(Percent): S1: Read next character from input stream (File or CALL-Buffer) S2: If the character is a line feed stop reading S3: If the character is a pe...
by jeb
21 Mar 2017 03:21
Forum: DOS Batch Forum
Topic: Examination of Linefeeds with CALL
Replies: 18
Views: 6165

Re: Examination of Linefeeds with CALL

(The possible seperation of the delayed expansion of command "call" and its argument string shouldn't effect the result, because the caret isn't present when needed.) First, I thought this is the cause, too. But as shown in Test9, 10 and 11 this can't be true. @echo off (set \n=^ %=empty=...
by jeb
21 Mar 2017 03:01
Forum: DOS Batch Forum
Topic: Delayed expansion fails in some cases
Replies: 18
Views: 6200

Re: Delayed expansion fails in some cases

penpen wrote:There could also be either an internal switch to avoid delayed expansion or the exclamation marks must be escaped, see "test.bat":

Your results are the expected ones, as delayed expansion is done only once, in the phases of the CALL there isn't any delayed expansion at all.

jeb
by jeb
20 Mar 2017 03:17
Forum: DOS Batch Forum
Topic: Examination of Linefeeds with CALL
Replies: 18
Views: 6165

Examination of Linefeeds with CALL

Hi, this is a split of the thread Delayed expansion fails in some cases . As there are multiple different strange things to examine. Here I want to examine the strange behaviour of linefeeds with CALL statements. There exists the rule, that an unescaped line feed in the special charater phase will s...
by jeb
19 Mar 2017 15:52
Forum: DOS Batch Forum
Topic: Delayed expansion fails in some cases
Replies: 18
Views: 6200

Re: Delayed expansion fails in some cases

Thanks Dave, you get my points. I'm sorry to choose a really bad example for 1) Why does delayed expansion fail when a batch executes (without CALL) another script? I should have choose an example with a plain simple variable, not with a line feed 2) Why does CALL strip all content after the first n...
by jeb
18 Mar 2017 16:20
Forum: DOS Batch Forum
Topic: Delayed expansion fails in some cases
Replies: 18
Views: 6200

Delayed expansion fails in some cases

Hi, while evaluating a question from SO: Im passing a multi line text as argument which will be saved in a variable and then the file created has only 1 Lline I found a curious behaviour. @echo off setlocal EnableDelayedExpansion (set \n=^ %=empty=% ) receveiver.bat "Line1!\n!line2" And Re...
by jeb
17 Mar 2017 08:22
Forum: DOS Batch Forum
Topic: how to use code to create a Pyramid
Replies: 30
Views: 5372

Re: how to use code to create a Pyramid

The modified version needs only 63 bytes @set\= A :\ @set\=%\:~1%AA&2>nul echo%\%&&goto\ But the last of your modifications is quite different than the starting pyramid, it outputs one line less than the original. This can be corrected by adding one space to the first set My own experime...
by jeb
15 Mar 2017 06:52
Forum: DOS Batch Forum
Topic: Using many "tokens=..." in FOR /F command in a simple way
Replies: 59
Views: 20391

Re: Using many "tokens=..." in FOR /F command in a simple way

Hi Dave, very nice and exhaustive examination of the parameters. I have only one small suggestion: Add a caret before the %char% to avoid problems when you begin with 22 or 5E (" ^) for %%%% in ("") do for /f "tokens=1-31*" %%^%char% in ( Currently I'm trying to access the 0...