Magialisk wrote:Ed I don't understand the problem you're trying to solve. When it sees the data as a stream you have to escape it:
Of course you knew this, which is why I'm not sure where the question is
Ah yes ofcourse your solution does work, but it also alters how the data is set.
Magialisk wrote:You said you don't want to include any text other than intended in the set, so the other way you could do this is to quote only what you want to set:
Code: Select all
set "var=set /a ?=1"
set var
::or
set "var=set /a ?=1"<nul
set var
The latter example is simply impossible for many macros. As it alters how the data is eventually stored.
Sorry, maybe I haven't been very clear.
The goal was to set the data using the multi-line comment style jeb suggested over the well known comment style that only allows one single empty comment line. For example:
Code: Select all
@echo off
set var=^%= this is a single line comment, next has to be data =%
echo.^&^%= this is a data line =%
echo.^&^%= this is a data line =%
set /a ?=1%= this is a data line =%
set var
set var=^%= this is a single line comment, next has to be data =%
^%= this is fails or alters original data line =%
^%= this is fails or alters original data line =%
set /a ?=1%= this is a data line =%
set var
set var=<nul ^%=this is a multi line comment, next can be data or a multi line comment=%
^^%= this is a multi line comment, next can be data or a multi line comment=%
^^%= this is a multi line comment, next can be data or a multi line comment=%
set /a ?=1%= this is a data line =%
set var
set var=<nul ^%= this is a multi line comment, next can be data or a multi line comment=%
set /a ?=1<nul ^%=this is the only known case where a multi line comment, corrupts original data=%
set /a ?=1%= this is a data line =%
set var
pause
exit
Code: Select all
var=echo.&echo.&set /a ?=1
var=^
var=set /a ?=1
var=set /a ?=set /a ?=1
Druk op een toets om door te gaan. . .
var=set /a ?=set /a ?=1 var=set /a ?=1set /a ?=1 expected
So I was hoping to figure a multi-line comment equivalent to the more common style which doesn't alter the data assignments
Magialisk wrote:I run into a similar problem all the time writing files with echo, ie: 'echo 1>test.txt' ends up writing "Echo is OFF" into the file instead of the number 1. I've just gotten in the habit of escaping any single digit number next to an angle bracket thanks to too many such experiences. Double digit numbers don't have the problem of being interpreted as streams of course...
Aha yes, that sucks
Magialisk wrote:Somehow I'm positive I've completely overlooked the question though.
The macro \n doesn't has this problem, but inserting unnecessary newlines is not ideal.
This is why I originally refused to use jeb's suggestion of ' <nul^' as it inserted a space in the data. It was then suggested using '<nul ^' to counter this and it seemed to work until this popped up.
I hope it's more clear now.