Search found 907 matches

by jeb
22 Aug 2019 13:36
Forum: DOS Batch Forum
Topic: How to use command output in echo? assign cmd output to var?
Replies: 2
Views: 39

Re: How to use command output in echo? assign cmd output to var?

Hi pstein, it's not as easy like in bash with myVar=$(myCmd) But with the help of a macro you can simplify it to %$set% volumeName="vol D:" Or even multi line output of a command %$set% ipOutput="ipconfig" Here is the full sample, with the used macro (you don't need to undestand the macro itself) @e...
by jeb
22 Aug 2019 13:25
Forum: DOS Batch Forum
Topic: .Bat File calling with other .bat file with paramater isue
Replies: 2
Views: 62

Re: .Bat File calling with other .bat file with paramater isue

Hi , your strlen batch is wrong, you doubled S="S= SET S="S=!%~2!#" The next problem is, that your parameters are wrong when calling the batch. CALL ...\islength.bat result1 !string1! The !string1! results into the expansion to the content, but the batch file expects only a variable name, not the co...
by jeb
21 Aug 2019 07:26
Forum: DOS Batch Forum
Topic: How <cr> behaves in a variable?
Replies: 2
Views: 51

Re: How <cr> behaves in a variable?

Hi Szecska,

the cr character should be used only with delayded expansion.

So your code should be changed to

Code: Select all

 if "!key!" == "!cr!" Echo.
by jeb
02 Aug 2019 01:01
Forum: DOS Batch Forum
Topic: B A T C H R E C U R S I O N exceeds STACK limits
Replies: 3
Views: 548

Re: B A T C H R E C U R S I O N exceeds STACK limits

Hi,

the error is not related to setlocal, but to the call stack.
Probably you have a recursion in your code, like

Code: Select all

:recursion
call :recursion
by jeb
13 Jul 2019 05:17
Forum: DOS Batch Forum
Topic: Passing arguments with spaces in it to a subroutine
Replies: 2
Views: 923

Re: Passing arguments with spaces in it to a subroutine

Your problem is, that the spaces are outside of quotes, because of doble quoting call :info "!json!" -> call :info " {^ " a^": ^"a b c^"^, ^"b^": ^"x y z^"} " Only the red text is inside qotes, the rest is outside and the spaces are used as delimiters. You could solve that with carets in front of so...
by jeb
14 Jun 2019 01:29
Forum: DOS Batch Forum
Topic: Strange double syntax error
Replies: 2
Views: 1180

Strange double syntax error

Hi, I found a strange behaviour in the syntax error handling. I forced a syntax error with a simple %VAR:=WRONG SYNTAX% Normally you see something like "=WRONG SYNTAX% " kann syntaktisch an dieser Stelle nicht verarbeitet werden. But if the preceding line contains one of the internal-internal comman...
by jeb
14 Jun 2019 00:53
Forum: DOS Batch Forum
Topic: Examination of Linefeeds with CALL
Replies: 18
Views: 5272

Re: Examination of Linefeeds with CALL

Hi Dave,

it's hard to remember all the problems parsing CALL/LF variables.

I retested some of the behaviour and I suppose your rules are correct now.

jeb
by jeb
29 May 2019 04:40
Forum: DOS Batch Forum
Topic: why does this code output such result
Replies: 11
Views: 1853

Re: why does this code output such result

The question is: What do you expect?

- Simplify your test to only show the unexpected part.
- Use "set str" to show the unmodified content after the set str=... command, to be sure that the correct content is there
by jeb
06 May 2019 10:49
Forum: DOS Batch Forum
Topic: Successfully escape a token delimiter in a fully qualified command path!
Replies: 7
Views: 1177

Re: Successfully escape a token delimiter in a fully qualified command path!

I tested the behaviour described by Dave. c:\temp\with^ space.bat - WORKS \temp\with^ space.bat - FAILS with^ space.bat - FAILS But only when you try it from the command line :!: Tested in a batch file the results are different c:\temp\with^ space.bat - WORKS \temp\with^ space.bat - WORKS with^ spac...
by jeb
06 May 2019 00:19
Forum: DOS Batch Forum
Topic: Successfully escape a token delimiter in a fully qualified command path!
Replies: 7
Views: 1177

Re: Successfully escape a token delimiter in a fully qualified command path!

Hi Dave, yes, in phase 2 the command token and the parameters are determined, therefore the escaping plays a role. but not for the splitting of the parameters (perhaps in pahse7 ?) It's also important for the delayed expansion phase, as this phase is executed indipendent for the command and the para...
by jeb
15 Apr 2019 01:18
Forum: DOS Batch Forum
Topic: how to preserve leading spaces in parameter during function call
Replies: 4
Views: 615

Re: how to preserve leading spaces in parameter during function call

There are two fundamental differnt ways to handle function parameters 1) Use a parameter ByValue, like you do in CALL :myFunc %str% This technic is simple but has also some limitations with special characters like quotes, spaces and carets. You should at least quote the content to presever spaces an...
by jeb
06 Apr 2019 05:40
Forum: DOS Batch Forum
Topic: string as statement
Replies: 4
Views: 658

Re: string as statement

This lines executes like set str1=set s1=hi cat & echo %s1% set str1=set s1=hi cat echo %s1% --- s1 doesn't contain anythig here, therefore "ECHO IS OFF" will be printed It's always a good idea to use some debugging technics (not only within batch files). View the variables, with `SET` or delayed ex...
by jeb
05 Apr 2019 06:49
Forum: DOS Batch Forum
Topic: how to make an array by function and by local variable of the function
Replies: 5
Views: 825

Re: how to make an array by function and by local variable of the function

You need to preserve the values in the ENDLOCAL-Block. @echo off set /a n=99 set ret= call :test3 ret echo show array: echo %ret.Array[0]% echo %ret.Array[1]% echo %ret.Array[2]% echo %ret.Array[3]% goto :eof :test3 setlocal EnableDelayedExpansion set /a n=0 for /L %%n in (0 1 3) DO ( set "%~1.Array...
by jeb
14 Mar 2019 05:22
Forum: DOS Batch Forum
Topic: Lag methodology
Replies: 9
Views: 1382

Re: Lag methodology

Hi SIMMS7400, I would convert the date to julian date (number of days). Then use some math to add/subtract days and convert it back from the julian format to gregorian date. Look here :date2jdate - converts a gregorian calender date to julian day format :jdate2date - converts julian days to gregoria...
by jeb
11 Feb 2019 05:19
Forum: DOS Batch Forum
Topic: Call and goto may fail when the batch file has Unix line endings
Replies: 16
Views: 2280

Re: Call and goto may fail when the batch file has Unix line endings

One more observation. As you already said, the scan for labels is reset at the file beginning or after a CR/LF. The label scanner reads chunks of ~512 bytes, therefore we see the described effect. BUT the scanner is able to set the new file position to the wrong position after a label is found :!: @...