Search found 204 matches

by pieh-ejdsch
23 Apr 2018 11:53
Forum: DOS Batch Forum
Topic: 'for' statement in macro will not accept 'tokens' argument from another 'for' statement. Why?
Replies: 5
Views: 1059

Re: 'for' statement in macro will not accept 'tokens' argument from another 'for' statement. Why?

a little workaround to do this ... set "varCount=!varName!" set "varCount=!varCount:?=x" set "varCount="=x!" set "varCount="!varCount:,=" "!"" set "#=0" for %%L in (!varCount!) do ( set /a #+=1 if !#! equ !TOKEN#! for /f "delims=," %%S in ("!varName!") do set "newVar=%%S" set "varName=!varName:*,=!,...
by pieh-ejdsch
19 Apr 2018 14:00
Forum: DOS Batch Forum
Topic: Discussion about jeb's batch parsing rules on StackOverflow
Replies: 42
Views: 10391

Re: Discussion about jeb's batch parsing rules on StackOverflow

I had the function https://www.dostips.com/forum/viewtopic.php?f=3&t=6496&p=56356#p56356 return in the do. I first tried to replace an exclamation point with percent signs. which is NOT possible anyway: set "return.var=%return.var:!=%%5%" then with delayedexpansion I replaced the variable at the tim...
by pieh-ejdsch
19 Apr 2018 13:30
Forum: DOS Batch Forum
Topic: Strange for loop behaviour
Replies: 3
Views: 1216

Re: Strange for loop behaviour

the macro "loadColors" is created within delayedexpansion. As a result, the variable table and i - are non-existent (or even set to an undefined content) and will/can not be replaced in the macro. The line to represent the variable loadColors proves this fact. in the second attempt the variable i is...
by pieh-ejdsch
14 Apr 2018 18:03
Forum: DOS Batch Forum
Topic: exit function and preserve variable over endlocal barrier
Replies: 23
Views: 10970

Re: exit function and preserve variable over endlocal barrier

I once played around with the return. The exclamation point I have replaced in between - as well as the caret. Since I'm not quite sure why the exclamation mark in two lines is also available, I left the time as it is. Only one variable is used to create variables in delayed and disabled expansion. ...
by pieh-ejdsch
25 Mar 2018 06:22
Forum: DOS Batch Forum
Topic: How to end LOOP at this situation
Replies: 3
Views: 1165

Re: How to end LOOP at this situation

Your function should be divided into several sub-areas. Recognition of parameters: - 0 setting for a delimiter. (default = space) - 1 setting for creating N variables. (default = max) - 2 setting for creating variables according to string length (default = InputVar = max) - 3 setting for dividing th...
by pieh-ejdsch
19 Mar 2018 13:35
Forum: DOS Batch Forum
Topic: Invisible error, deleting a comment - makes everything work
Replies: 13
Views: 3277

Re: Invisible error, deleting a comment - makes everything work

Well - thanks for these tips - then I have allowed myself to change this variable something. It now also has both: simple one-line comments; bracketed comments and comments in parenthesis with pipe. The follow-up command within parentheses must of course be included. rem create a variable to insert ...
by pieh-ejdsch
18 Mar 2018 13:36
Forum: DOS Batch Forum
Topic: Invisible error, deleting a comment - makes everything work
Replies: 13
Views: 3277

Re: Invisible error, deleting a comment - makes everything work

You can use this

Code: Select all

:: define LF as a Line Feed (newline) character
set ^"LF=^

^" Above empty line is required - do not remove
:: define a newline with line continuation
set ^"\n=^^^%LF%%LF%^%LF%%LF%^^"
set \=::%\n%
 :_
 %\%comment 1
 (%\%comment2
 echo ...
 )
by pieh-ejdsch
27 Feb 2018 10:26
Forum: DOS Batch Forum
Topic: Counter with batch
Replies: 5
Views: 1419

Re: Counter with batch

Code: Select all

set a Counter=0
will create a varName like "a Counter" with Content is 0

Code: Select all

set Counter=0
will create a varname like "Counter" with Content is 0

Code: Select all

set /a Counter = 0
will use all Arithmetic operations to create or/and calculate with Content.
by pieh-ejdsch
26 Feb 2018 17:56
Forum: DOS Batch Forum
Topic: Why REM inside a block?
Replies: 14
Views: 3378

Re: Why REM inside a block?

Yes Jeb - you are right. I have practically evaluated the error level of the previous command of the script - well. ok - I did a few more tests, but I can not do anything with IF. On the other hand, FOR / F loops can produce Errorlevel 1 if an OR condition is appended. The AND condition does not wor...
by pieh-ejdsch
26 Feb 2018 08:13
Forum: DOS Batch Forum
Topic: Why REM inside a block?
Replies: 14
Views: 3378

Re: Why REM inside a block?

setting the errorlevel to 0 is still a lot faster with an if than with a call. @echo off call :loop Normal echo( call :loop "stdout already redirected to nul" "3>&1 >nul" exit /b :loop echo %~1 echo -------------------------------- for %%C in ( "cd ." "ver >nul" "date /t >nul" "time /t >nul" "verify...
by pieh-ejdsch
25 Feb 2018 04:36
Forum: DOS Batch Forum
Topic: having trouble with padding zeros in a for /f
Replies: 3
Views: 1196

Re: having trouble with padding zeros in a for /f

this should look like this in the command line.

Code: Select all

< JobIDs.txt cmd /v /c "set "x=" & (for /l %i in (1001 1 1999) do @ set /p "x=" && >nul set /a "padNr=%i,nr=padNr%1000" && echo ren "!Nr!.pdf" "!padNr:~1! - !x!") "
by pieh-ejdsch
24 Feb 2018 17:18
Forum: DOS Batch Forum
Topic: reverse string without goto
Replies: 4
Views: 2743

Re: reverse string without goto

Instead of just cutting the backward string into just 2 parts, the number of loops into for can be reduced to a certain mediocre level. With only two characters converted, there are a maximum of about 4000 times in the loop. With the maximum line length approx 700 characters can be shifted at once. ...
by pieh-ejdsch
12 Jan 2018 04:02
Forum: DOS Batch Forum
Topic: setlocal enabledelayedexpansion and its potential effect?
Replies: 6
Views: 1903

Re: setlocal enabledelayedexpansion and its potential effect?

I did not see that yesterday: call Batch That the batch kontex is started and Echo is switched on again within a bracket / command line I did not know either. That would mean, however, that the CMD line parser does not notice the echo condition and the individual re-reads command line / bracket and ...
by pieh-ejdsch
11 Jan 2018 16:22
Forum: DOS Batch Forum
Topic: setlocal enabledelayedexpansion and its potential effect?
Replies: 6
Views: 1903

Re: setlocal enabledelayedexpansion and its potential effect?

is an echo switched on in one of your scripts?
Just check it out with a script.
-----
checkcmd.cmd Yourbatch.cmd echo