Search found 964 matches

by jeb
22 Jun 2020 00:43
Forum: DOS Batch Forum
Topic: caret removes the first command after opening parenthesis if its concat'd to the first token of command without space
Replies: 4
Views: 190

Re: caret removes the first command after opening parenthesis if its concat'd to the first token of command without spac

Btw. the @ has also sme impact.

Code: Select all

@echo on
cls
(
echo Start

@ ec^
ho #1: Works
@ec^
ho #2: Fails

@@^
@@ ec^
ho #3: Works

xyz@@^
@@ ec^
ho #4: Works
)

echo End
by jeb
22 Jun 2020 00:38
Forum: DOS Batch Forum
Topic: Pass multiple lines(through stdin) from batch to powershell
Replies: 4
Views: 176

Re: Pass multiple lines(through stdin) from batch to powershell

Hi lockedscope, you found already the relevant posts on SO. Pipes (mostly) creates a child cmd.exe instance on both sides. The command itself will be executed in the child instance, but the first expansion occurs in the parent instance. The parent instance will use the percent expansion, but the del...
by jeb
22 Jun 2020 00:30
Forum: DOS Batch Forum
Topic: How batch parsing phases work?
Replies: 4
Views: 258

Re: How batch parsing phases work?

Hi,

your first analysis is correct, but not the second one.

the line: set c=^^^!text^^^!
assigns !text! to c

Therefore the line: echo %c%

only has to expand !text! to "my"
by jeb
22 Jun 2020 00:20
Forum: DOS Batch Forum
Topic: caret removes the first command after opening parenthesis if its concat'd to the first token of command without space
Replies: 4
Views: 190

Re: caret removes the first command after opening parenthesis if its concat'd to the first token of command without spac

Hi lockedscope, nice finding :!: I didn't knew that and never tested it. The rule seems to be: - In paremthesis: - If a caret+line feed splits the command token (usually the first token), then only the part after the last LF is used - This rule is true for any position in the parenthsis, not only th...
by jeb
16 Jun 2020 00:09
Forum: DOS Batch Forum
Topic: How batch parsing phases work?
Replies: 4
Views: 258

Re: How batch parsing phases work?

Hi lockedscope, it's quite correct. But my first rule is: Always monitor variables unmodified :!: You can use delayed expansion for that or the SET command, but never percent expansion, that only confuses the result 8) If you add set b after the line set "b=%a%" you see that the content of <b> is "^...
by jeb
15 Jun 2020 07:17
Forum: DOS Batch Forum
Topic: Dynamic loop code over multiple lines causes extra quotes
Replies: 7
Views: 366

Re: Dynamic loop code over multiple lines causes extra quotes

Hi lockedscope, So, how could that 10/11 carets works? The problem is, in your case there are multiple escape phases! Start: "for... "^^^^^^^^^^!text^^^^^^^^^^! ...." phase2: "for... "^^^^^!text^^^^^! ..." phase5: "for... "^^!text^^! ..." CALL doubling: "for... "^^^^!text^^^^! ..." Restart parsing p...
by jeb
13 Jun 2020 10:31
Forum: DOS Batch Forum
Topic: How delayed expansion works?
Replies: 3
Views: 281

Re: How delayed expansion works?

Hi lockedscope,

yes your eplanation is correct.
Percent expansion is always the first one and can't be suppressed.
Then the for-variables expansion occurs.
And the last expansion can be the delayed expansion, if enabled.

jeb
by jeb
11 Jun 2020 05:27
Forum: DOS Batch Forum
Topic: Is there a way to split a string to new lines in file by delimiter
Replies: 4
Views: 340

Re: Is there a way to split a string to new lines in file by delimiter

Hi brentonv, you link to SO Split values into separate lines for each delimiter - batch shows already a working solution :D @echo off setLocal EnableDelayedExpansion for /f "delims=" %%a in (string.txt) do ( set "line=%%a" echo reading line: !line! for /F "delims=" %%C in (""!line:^:^=^"^ "!"^") do ...
by jeb
15 May 2020 00:00
Forum: DOS Batch Forum
Topic: Debugging / syntax checksing tools for batch
Replies: 21
Views: 1295

Re: Debugging / syntax checksing tools for batch

Hi Yanta, if you don't know the line where the error occurs, you could add markers like echo Line: 123 >> debug.txt ... echo Line: 456 >> debug.txt Add these markers until you know the exactly line number. The rest should be easy. It should be possible to add the markers automatically with JREPL to ...
by jeb
11 May 2020 00:38
Forum: DOS Batch Forum
Topic: able to run functions from another script?
Replies: 4
Views: 699

Re: able to run functions from another script?

Hi deusery, yes you can. There are different solutions to build a batch library, but no perfect one. 1) You can use a HACK/bug/feature of cmd.exe If you call a label in the same file and then start a second batch file without CALL, then the label will be jumped to also in the second batch file! batc...
by jeb
07 Apr 2020 23:09
Forum: DOS Batch Forum
Topic: can you do this batch ocrrectly for me please
Replies: 7
Views: 1940

Re: can you do this batch ocrrectly for me please

Hi, you should check, that there is no ping.bat in your working directory, else it will be infinitely repeated, because "ping 66.151.33.4 -t" will call the batch file "ping.bat" not the ping.exe command. Your other problem is the character encoding of "Conexión de red inalámbrica". You got the error...
by jeb
07 Apr 2020 05:25
Forum: DOS Batch Forum
Topic: can you do this batch ocrrectly for me please
Replies: 7
Views: 1940

Re: can you do this batch ocrrectly for me please

Hi abuchaibe3, first your problem with "ping 66.151.33.4 -t" if i dont save it as .bat with notepad, but if i do that the command doesn't stop repeating I guess, you save it as "ping.bat" ? If yes, think about it a minute and you will find the problem. Your first problem occurs probably from your ut...
by jeb
07 Apr 2020 00:00
Forum: DOS Batch Forum
Topic: Special Characters contained in Variable used in String:Replace command...
Replies: 1
Views: 820

Re: Special Characters contained in Variable used in String:Replace command...

Hi Arianax, simple: You can't :!: It's not possible to escape an equal sign in the search string. There exist some pure batch solutions (also on Dostips), but I would recommend the easy to use and powerful solution from Dave JREPL . This is a JScript/Batch hybrid from one of our honored, expert memb...
by jeb
02 Apr 2020 02:41
Forum: DOS Batch Forum
Topic: Echoing variables with colouring problem for filenames or directories
Replies: 2
Views: 859

Re: Echoing variables with colouring problem for filenames or directories

Hi stevehero, most of my code is more or less only a proof of concept :!: The color sample, too. Long time ago, I developed it to show that it's even possible to colorize characters. But to use it as a function, you better switch to the code of Dave SO: How to have multiple colors in a Windows batch...
by jeb
29 Mar 2020 22:52
Forum: DOS Batch Forum
Topic: % in file list causing issues with call :command
Replies: 4
Views: 1081

Re: % in file list causing issues with call :command

Hi stevehero, the problem is the call command, it starts a second round of parsing, therefore the percent is interpreted and eventually removed. It's better to assign "%%~fG" to a variable, and later, use that variable. @For /F "UseBackDelims=" %%G In ("%Temp%\music-checker-list-2020-03-29_2034-21.t...