Search found 902 matches

by jeb
14 Jun 2019 01:29
Forum: DOS Batch Forum
Topic: Strange double syntax error
Replies: 2
Views: 94

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: 17
Views: 3585

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: 516

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: 261

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: 261

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: 267

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: 309

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: 392

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: 738

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: 1139

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 :!: @...
by jeb
11 Feb 2019 04:49
Forum: DOS Batch Forum
Topic: Call and goto may fail when the batch file has Unix line endings
Replies: 16
Views: 1139

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

Thanks Dave, your findings are impressive :D. I didn't see the idea of relative counting the characters :( I played with a file with unix style endings and a single CR/LF and thought the problem was gone as I didn't see the reset behaviour. But your analysis is really good. And your rule is really s...
by jeb
09 Feb 2019 12:47
Forum: DOS Batch Forum
Topic: Call and goto may fail when the batch file has Unix line endings
Replies: 16
Views: 1139

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

Hi jfl, like Dave I'm very interessted. And I simplified your code to a minimal, failing example: @echo off goto :zwei :####################################################################################################################################################################################...
by jeb
06 Feb 2019 09:29
Forum: DOS Batch Forum
Topic: Is there any standard equivalent of a .bashrc script for cmd?
Replies: 10
Views: 723

Re: Is there any standard equivalent of a .bashrc script for cmd?

Hi jfl, nice work! Eventually I found a heuristic that seems to give good results: - If the first token is == %COMSPEC% without quotes, then this is a for /f, and I should not run AutoRun scripts. - If the second token is /c, then this a manual execution of a single command, and it's not worth runni...
by jeb
05 Feb 2019 02:24
Forum: DOS Batch Forum
Topic: I need to escape pipe character in a string but still remove leading and trailing quotes
Replies: 6
Views: 407

Re: I need to escape pipe character in a string but still remove leading and trailing quotes

Hi bosekamineni, you should use delayed expansion, because it's always safe to expand with delayed expansion. @echo off setlocal EnableDelayedExpansion set "_string=Test String With | &&<> command" echo the string is !_string! The only drawback is that you be careful with literal exclamation marks, ...
by jeb
28 Jan 2019 03:01
Forum: DOS Batch Forum
Topic: Is there any standard equivalent of a .bashrc script for cmd?
Replies: 10
Views: 723

Re: Is there any standard equivalent of a .bashrc script for cmd?

Hi siberia-man, - It is reliable to detect an invocation from FOR/F. - Invokations from pipes doesn't trigger the autostart at all. - When a new instance of cmd.exe is launched directly it can fail, as it's possible to add any possible parameter, but then it only drops the additional commands. It sh...