Search found 2212 matches

by dbenham
14 Jun 2019 07:11
Forum: DOS Batch Forum
Topic: Examination of Linefeeds with CALL
Replies: 17
Views: 3566

Re: Examination of Linefeeds with CALL

Below is evidence that Phase 0 preserves the end of line newline, and that phase 1 truly truncates the line at the first appearing newline not within expanding percents. Also, percent expansion error is not fatal after CALL. It is important that the last line of the script does not end with a newlin...
by dbenham
14 Jun 2019 06:45
Forum: DOS Batch Forum
Topic: Strange double syntax error
Replies: 2
Views: 67

Re: Strange double syntax error

:shock: Very interesting But I do not get the same results on my Windows 10 64 bit machine. :? What version are you using? The only situation that gives different behavior for me is if the fatal syntax error follows immediately after a CALLed :label (GOTO does not work) And even in this case, only t...
by dbenham
13 Jun 2019 18:43
Forum: DOS Batch Forum
Topic: Examination of Linefeeds with CALL
Replies: 17
Views: 3566

Re: Examination of Linefeeds with CALL

No, because the newlines don't exist until after phase 1 is complete. Within Phase 1, only the outer loop looks for <LF> to truncate. After the %\n% gets replaced, the outer loop scanner continues with the next character after the replacement, so the <LF> is never seen by the scanner, and it is safe...
by dbenham
13 Jun 2019 12:24
Forum: DOS Batch Forum
Topic: Examination of Linefeeds with CALL
Replies: 17
Views: 3566

Re: Examination of Linefeeds with CALL

I updated the Phase 1 parsing rules on StackOverflow here and here to account for the newline behavior after CALL.

Dave Benham
by dbenham
13 Jun 2019 12:23
Forum: DOS Batch Forum
Topic: Delayed expansion fails in some cases
Replies: 18
Views: 4055

Re: Delayed expansion fails in some cases

I updated the Phase 5 parsing rules on StackOverflow here and here to account for the disabled delayed expansion behavior associated with "naked" batch script commands.

Dave Benham
by dbenham
12 Jun 2019 15:09
Forum: DOS Batch Forum
Topic: Batch file with config file
Replies: 2
Views: 115

Re: Batch file with config file

It sounds like you are trying to dynamically write a batch script. That should not be necessary. Except in very rare circumstances, you should be able to write a static batch script that reads and processes a data (.txt) file with FOR /F. You can dynamically create the .txt file with MS Access. The ...
by dbenham
12 Jun 2019 14:31
Forum: DOS Batch Forum
Topic: Examination of Linefeeds with CALL
Replies: 17
Views: 3566

Re: Examination of Linefeeds with CALL

I re-examined the behaviors and proposed theories and I think I have a simple set of rule changes that account for the behaviors. It is very similar to what jeb proposed, but just fleshed out a bit more. Currently phase 1 is defined as : Phase 1) Percent Expansion Starting from left, scan each chara...
by dbenham
11 Jun 2019 21:33
Forum: DOS Batch Forum
Topic: JREPL.BAT v8.2 - regex text processor with support for text highlighting and alternate character sets
Replies: 413
Views: 169281

Re: JREPL.BAT v8.2 - regex text processor with support for text highlighting and alternate character sets

Your regex is definitely not correct. I'm not going to try to figure out exactly what is going on. The regex I would use is: ^([^\r\n]+)\r?\n(?=[\s\S]*^\1$) But when you use CALL with quoted strings, the ^ is doubled to ^^. That doesn't matter for beginning of line anchor, but it gives the wrong res...
by dbenham
10 Jun 2019 11:44
Forum: DOS Batch Forum
Topic: Safely parse nearly any CSV with pure batch
Replies: 1
Views: 341

Re: Safely parse nearly any CSV with pure batch

I decided to make a BatchParseCSV.bat utility script containing all pure batch code necessary to easily parse nearly any CSV. BatchParcseCSV.bat @echo off if "%~1" equ "" goto :Help shift /1 & goto %1 2>nul || >&2 echo ERROR: Invalid %~nx0 function '%1' :GetToken ForVar EnvVar :: :: Gets field in %%...
by dbenham
05 Jun 2019 16:01
Forum: DOS Batch Forum
Topic: JREPL.BAT v8.2 - regex text processor with support for text highlighting and alternate character sets
Replies: 413
Views: 169281

Re: JREPL.BAT v8.2 - regex text processor with support for text highlighting and alternate character sets

Here is version 8.2 JREPL8.2.zip Summary of changes c:\>jrepl /?history 2019-06-05 v8.2: /RTN bug fix - preserve Unicode by using CHCP 65001/utf-8 to transfer value to variable unless /XFILE used. ... Hopefully this is the last remaining encoding issue with JREPL. The /RTN option makes use of a tem...
by dbenham
03 Jun 2019 07:33
Forum: DOS Batch Forum
Topic: How to get parameters of script in subroutine
Replies: 1
Views: 220

Re: How to get parameters of script in subroutine

Batch does not have any built in functionality for named arguments. You will need batch code to parse named arguments and store the values in environment variables. Once you have that, you can do anything you want with the values, including pass them to called functions. Things to consider: - How to...
by dbenham
02 Jun 2019 15:56
Forum: DOS Batch Forum
Topic: Batch file runs differently when executed line by line
Replies: 6
Views: 393

Re: Batch file runs differently when executed line by line

Major differences, off the top of my head: SETLOCAL / ENDLOCAL has no effect on the command line GOTO has no effect on the command line CALL :label always fails on the command line If VAR is undefined, then %VAR% and !VAR! expands to empty string in batch, but no change (%VAR% !VAR! remain) on the c...
by dbenham
01 Jun 2019 06:08
Forum: DOS Batch Forum
Topic: why does this code output such result
Replies: 11
Views: 486

Re: why does this code output such result

Of course adding the quote makes a profound difference - it inverts what is quoted within the value of %str%. Quoted carets don't escape anything in phase 2 - they are simply string literals. Dropping the variable and working just with strings. echo "^A"^B"^A"^B yields "^A"B"^A"B because the A strin...
by dbenham
31 May 2019 06:51
Forum: DOS Batch Forum
Topic: why does this code output such result
Replies: 11
Views: 486

Re: why does this code output such result

:? I never said that, so I'm not sure why you are reaching that conclusion. Of course both forms pass through phase 2. My original explanation attempts to show a command, and then illustrate the intermediate result of each phase. And here is an example of what I intended in my last post: @echo off s...