That was a joke benI do NOT recommend that comment because it contains a colon. It will not work properly
Take out the : and it works fine.

Moderator: DosItHelp
That was a joke benI do NOT recommend that comment because it contains a colon. It will not work properly
Take out the : and it works fine.
Code: Select all
set ^"@Debug.on=( %$n1c%
set "@Ddef=if defined $Debug.Sub" %$n1c%
)"
Code: Select all
set ^"@TraceOut=( %$n1c%
if defined $Debug.Sub do something %$n1c%
)"
Code: Select all
set ^"@TraceOut=( %$n1c%
^^^!@Ddef^^^! do something %$n1c%
)"
Code: Select all
^^^!@Ddef^^^!
%%@Ddef%%
for.... in
for /f "usebackq" %%^^^! in ( `echo."^!@Ddef^!"` ) do %%~^^^! %$n1c%
etc...
Code: Select all
set ^"@WriteAdvancedReturn=do ( %$n1c%
set "$NotDelayedFlag=!" %$n1c%
setlocal EnableDelayedExpansion %$n1c%
set "$token=%%~!" %$n1c%
set "$RetVar=!$token!" %$n1c%
set "$RetVal=!%%~!!" %$n1c%
echo.$RetVal=!$RetVal! %$n1c%
)"
echo.
( for %%! in ( @WriteAdvancedReturn ) %@WriteAdvancedReturn% ) >tst.txt
type tst.txt
%@endoftest%
Yes, that would be a carriage return.Ed Dyreen wrote:but euh, what is \r, is that a carriage return ?
No, I don't think that is necessary. However, you might want to use a different text editor. Wordpad maybe? I use ConText - a free programmers editor. There are other free text editors out there.Ed Dyreen wrote:Does this mean I have to replace <LF> with <CR><LF> before writing to file ?
I don't think this is an issue if you don't change anything.Ed Dyreen wrote:And will a macro still work if I then try to load it with for "usebackq" ?
Code: Select all
:function
@macro
@macro
@macro
@macro
:endfunc
Code: Select all
@combinedmacro=(
call helperfunc: @macro
call helperfunc: @macro
call helperfunc: @macro
call helperfunc: @macro
)
I was completely ignoring this fact until nowNow that wasn't dos syntax, all these languages are so confusing![]()
The extreme slowness of CALL is well documented:CALL me, or better avoid callEd Dyreen wrote:I thought keeping helperfunc: in a separate file would be enough but CALL hits hard.
It feels like wasting hundreds of msecs !
The moment you call your helper function - it's no longer pure macro. Achieving pure macro code is impossible the moment the task becomes moderately complex. (in other words, more complex than what can be achieved in 8k). So, yes, I suppose trying to achieve the impossible is bad.Ed Dyreen wrote:To strive for "pure" macro code is bad
Actually I think macros are a perfect replacement for most utility type functions, given that most functions have a very specific function that does fit within 8k. They most definitely are NOT replacements for entire batch processes.Ed Dyreen wrote:Conclusion:
Macros are not a replacement for functions, rather function enhancers.
There is a fragile balance to be chased for "optimal" performance.
I am starting to believe this has everything to do with DOS memory.Also, function libraries tend to slow down as the file size increases. Not generally true with macros. Though I saw where you reported that your large macro project seemed to slow down. I haven't seen that with macros yet.
Code: Select all
start "WMIC.EXE" /wait /high /min "%comspec%" /c 2^> "%%~?" 1^> "%%~!" WMIC.EXE !Alias!
And the fool continiuesdbenham wrote:OK - I have finally caught up with the macro "calling" macro discussion. Thanks Jeb and Ed, it's been a good exchange.![]()
I had been hoping that the expansion of the inner macro could be delayed until run-time because, as Ed pointed out, I was concerned about the size limit of any single macro definition. But I now realize that there is no avoiding the fact that at run time the entire fully expanded macro must exist in memory as one parsed "statement", so it was a fools dream.
Code: Select all
echo.@endoftest>nul
echo.
set "@macro=echo.this is a macro &echo.that uses memory &echo.to hold this text &echo.memory use grows as the macro gets longer &echo.but i'm sure that 1 + 1 equals &set /a "val=1+1" &echo.'!val!'"
setlocal enableExtensions enableDelayedExpansion
:: (
%@macro%
for /f "usebackq tokens=*" %%? in ( `echo. ^&!@macro!` ) do echo.%%?
:: )
endlocal
%@endoftest%
Code: Select all
this is a macro
that uses memory
to hold this text
memory use grows as the macro gets longer
but i'm sure that 1 + 1 equals
'2'
this is a macro
that uses memory
to hold this text
memory use grows as the macro gets longer
but i'm sure that 1 + 1 equals
2'2'
endoftest Druk op een toets om door te gaan. . .
Code: Select all
@echo off
setlocal
set "@macro=echo.this is a macro &echo.that uses memory &echo.to hold this text &echo.memory use grows as the macro gets longer &echo.but i'm sure that 1 + 1 equals &set /a "val=1+1" &rem '!val!'"
setlocal enableExtensions enableDelayedExpansion
set val
for /f "usebackq tokens=*" %%? in ( `echo. ^&!@macro!` ) do echo.%%?
echo(
set val
Code: Select all
Environment variable val not defined
this is a macro
that uses memory
to hold this text
memory use grows as the macro gets longer
but i'm sure that 1 + 1 equals
2
Environment variable val not defined