Search found 1609 matches

by Aacini
29 Dec 2011 12:08
Forum: DOS Batch Forum
Topic: infinite loop with break condition
Replies: 32
Views: 22612

Re: infinite loop with break condition

Thanks a lot Dave, it works now! set while=for %%n in (1 2) do if %%n==2 (%\n% call :StrLen argv argvLen=%\n% set "body=!argv:*do=!"%\n% call :StrLen body bodyLen=%\n% set /A condLen=argvLen-bodyLen-2%\n% for %%a in (!condLen!) do set "cond=!argv:~0,%%a!"%\n% echo for /L %%%%w in...
by Aacini
28 Dec 2011 22:02
Forum: DOS Batch Forum
Topic: infinite loop with break condition
Replies: 32
Views: 22612

Re: infinite loop with break condition

I need the help of a Batch macro expert I tried to write a macro, called WHILE, to make good use of this trick in an easier way. I first wrote a subroutine that works ok. When I convert it to a macro I got an error in the line with the REM below: @echo off setlocal DisableDelayedExpansion set LF=^ :...
by Aacini
28 Dec 2011 16:31
Forum: DOS Batch Forum
Topic: infinite loop with break condition
Replies: 32
Views: 22612

Re: infinite loop with break condition

You CAN get back a value. But only a single integer via errorlevel. Yes, it works! echo %\n% @echo off%\n% set num=0%\n% set result=0%\n% for /L %%%%i in (1,0,1) do (%\n% set /A num+=1%\n% if not %%1 %%2 %%3 call break !result!%\n% echo !num!%\n% set /A result+=num%\n% ) > while.bat echo exit %%1 >...
by Aacini
28 Dec 2011 13:39
Forum: DOS Batch Forum
Topic: infinite loop with break condition
Replies: 32
Views: 22612

Re: infinite loop with break condition

There is no way to break a FOR loop in the same CMD context , so I used a trick to export the cycle to a new CMD that can be broken via an EXIT command, and the execution return to the caller code: @echo off setlocal DisableDelayedExpansion set LF=^ ::Above 2 blank lines are required - do not remove...
by Aacini
27 Dec 2011 00:28
Forum: DOS Batch Forum
Topic: Macros with parameters appended
Replies: 29
Views: 18395

Re: Macros with parameters appended

Ed Dyreen wrote:And while you're at it, how about:

Code: Select all

set /a $var=%StrLen% ( "I wish this worked" ) + %random%
Now that would be really impressive. :lol:


Yes, it can be done now this way:

Code: Select all

set "string=I wish this worked"
%set/a% $var=StrLen(string)+%random%

See my SET/A macro at this topic
by Aacini
27 Dec 2011 00:09
Forum: DOS Batch Forum
Topic: SET/A: Macro to expand function results in SET /A expression
Replies: 4
Views: 5867

SET/A: Macro to expand function results in SET /A expression

2- Library of functions to be used in SET/A macro. Let's define some stuff designed to be used with SET/A macro. Note that these functions does not check for any errors in order to keep them simple and fast. For example: :NEG N R=-N set /A "%2=-(%~1)" exit /B :ABS N R=ABS(N) set /A "%...
by Aacini
26 Dec 2011 23:51
Forum: DOS Batch Forum
Topic: SET/A: Macro to expand function results in SET /A expression
Replies: 4
Views: 5867

SET/A: Macro to expand function results in SET /A expression

Batch macros with parameters make possible to redefine the syntax of Batch language and give access to complex procedures in a simple way. Let's start with a smaller example before we immerse in SET/A macro description. %SET/S% variable:~start,size=substring to insert Previous "SET-Substring&qu...
by Aacini
15 Dec 2011 22:46
Forum: DOS Batch Forum
Topic: Macros with parameters appended
Replies: 29
Views: 18395

Re: Macros with parameters appended

jeb: I modified my original answer as I said. Perhaps you would like to review it looking for a new declaration to disprove :| :?
by Aacini
14 Dec 2011 07:48
Forum: DOS Batch Forum
Topic: Why does SET performance degrade as environment size grows?
Replies: 31
Views: 17542

Re: Why does SET performance degrade as environment size gro

Here it is a third test that use AllocateEnvironmentSpace/FreeEnvironmentSpace instead of ReserveEnvironmentSpace as described above; result times behaved as expected: Environ Grow SetLocal- Size Environ EndLocal Set Unset Expand -------------------------------------------------------------- 4678 0....
by Aacini
14 Dec 2011 01:31
Forum: DOS Batch Forum
Topic: Why does SET performance degrade as environment size grows?
Replies: 31
Views: 17542

Re: Why does SET performance degrade as environment size gro

Dave: I could get some time at least to achieve the missing timing test. I slightly modified your program to show results in a more compact form, and I added the calculation of the time the environment takes to grow up to the testing size. These are the results of original program: Environ Grow SetL...
by Aacini
12 Dec 2011 21:55
Forum: DOS Batch Forum
Topic: Macros with parameters appended
Replies: 29
Views: 18395

Re: Macros with parameters appended

Welcome Aacini to the expert discussions Thanks, jeb. Because this trick use textual substitution of whichever text placed after the macro, if another & COMMAND is placed after macro params, that command will also be carried into the for body and hence also executed 2 times: [...] The only way ...
by Aacini
12 Dec 2011 05:19
Forum: DOS Batch Forum
Topic: Macros with parameters appended
Replies: 29
Views: 18395

Re: Macros with parameters appended

jeb: First of all, I want to offer you a VERY BIG CONGRATULATION for all of your ideas, specially this one. That said, this is a small observation: WHY YOU DIDN'T EXPLAIN YOUR METHODS? I worked for over 25 years explaining computer themes to other people. I used to write larger and clearer explanati...
by Aacini
11 Dec 2011 14:25
Forum: DOS Batch Forum
Topic: Why does SET performance degrade as environment size grows?
Replies: 31
Views: 17542

Re: Why does SET performance degrade as environment size gro

Dave: Let's go back a little. The goal was/is to speed up a program that use a large environment and that run very slowly, right? For example, the loading of a large file in memory variables (that was the origin of this topic, indeed): @echo off setlocal EnableDelayedExpansion findstr /N ^^ %1 | fin...
by Aacini
10 Dec 2011 21:33
Forum: DOS Batch Forum
Topic: Batch "macros" with arguments
Replies: 73
Views: 50380

Re: Batch "macros" with arguments

All this macro stuff in wonderful! I understand this is an advanced topic that challenge and amuse experts (like all of you, people!). However, my main concern is to made possible that average people may have access to advanced techniques like this one, so I have a somewhat different point of view t...
by Aacini
10 Dec 2011 01:27
Forum: DOS Batch Forum
Topic: Batch "macros" with arguments
Replies: 73
Views: 50380

Re: Batch "macros" with arguments

Hey, dave! I just carefully read all the five pages of this topic and have not discovered what is the method you used to place macro parameters after the macro expansion, like in these lines: %macro.diffTimeRaw% t1 t2 base %macro.diffTimeRaw% t2 t3 base_setlocal_endlocal that you posted in this topi...