Search found 2085 matches

by dbenham
18 Aug 2018 21:14
Forum: DOS Batch Forum
Topic: Small Macros - timeSince, nullDir, prt, poz
Replies: 5
Views: 91

Re: Small Macros - timeSince, nullDir, prt, poz

I've read about the phases of the command interpreter before, but where's your best resource that explains this? The best resource is the StackOverflow answer begun by jeb , coupled with my answer that gives more detail about phases 1 (percent expansion) and 5 (delayed expansion). The information i...
by dbenham
18 Aug 2018 16:48
Forum: DOS Batch Forum
Topic: %MM% v0.2a - a full-featured WinNT math macro
Replies: 21
Views: 370

Re: %MM% v0.2a - a full-featured WinNT math macro

Regarding v0.2 - Great job, especially with the extensive documentation and in-line comments :!: :D The addition of the major section header comments at the beginning of the lines really helps get your bearings. And the variable documentation is also great. All in all - very impressive. Dave Benham
by dbenham
18 Aug 2018 08:56
Forum: DOS Batch Forum
Topic: Small Macros - timeSince, nullDir, prt, poz
Replies: 5
Views: 91

Re: Small Macros - timeSince, nullDir, prt, poz

While %prt% is super neat (and I still don't quite get it) I really never use it, and it's the one I didn't write. It's clever, but actually quite simple. It works by preceding the message with a disappearing quote. The message is quoted during phase 2 parsing. But phase 4 removes the quote so it d...
by dbenham
10 Aug 2018 18:46
Forum: DOS Batch Forum
Topic: %MM% v0.2a - a full-featured WinNT math macro
Replies: 21
Views: 370

Re: %MM% - a full-featured WinNT math macro

So n0 must be initialized to 0 before entering the IF, yes? It's a bit smaller than my version... but won't it fail if o1=0 because it won't execute the remainder of the line? Doh - Of course. And I probably need to clear dc as well. My formula needs parens around each of the IF statements )ELSE IF ...
by dbenham
10 Aug 2018 16:04
Forum: DOS Batch Forum
Topic: %MM% v0.2a - a full-featured WinNT math macro
Replies: 21
Views: 370

Re: %MM% - a full-featured WinNT math macro

Very similar to SET /A, but not exactly the same. For example, @ is used for MOD instead of % (or %% in batch). Also %MM% has some features that SET /A doesn't, such as comparison operations that can be used with the ternary if construct: someCondition ? doThisIfTrue : elseDoThisIfFalse. And SET /A ...
by dbenham
10 Aug 2018 13:12
Forum: DOS Batch Forum
Topic: %MM% v0.2a - a full-featured WinNT math macro
Replies: 21
Views: 370

Re: %MM% - a full-featured WinNT math macro

@IcarusLives The macro would be useful any time you are trying to do arithmetic with numbers that do not fit within the constraints of a 32 bit signed integer. This includes decimal (fractional) numbers, as well as numbers that are larger than 2,147,483,647 or less than -2,147,483,648. One obvious e...
by dbenham
10 Aug 2018 05:31
Forum: DOS Batch Forum
Topic: %MM% v0.2a - a full-featured WinNT math macro
Replies: 21
Views: 370

Re: %MM% - a full-featured WinNT math macro

One other idea I had for XOR - use || for XOR and | for OR
by dbenham
09 Aug 2018 21:39
Forum: DOS Batch Forum
Topic: %MM% v0.2a - a full-featured WinNT math macro
Replies: 21
Views: 370

Re: %MM% - a full-featured WinNT math macro

I think bit operators are not worth it, which simplifies things. I think ^ is good for XOR, it normally works fine as long as it is quoted. Things that can cause issues: Quoted ^ is doubled if CALL is used. Since we are using macros, CALL is not normally an issue. But it could be an issue if %MM% is...
by dbenham
09 Aug 2018 16:32
Forum: DOS Batch Forum
Topic: %MM% v0.2a - a full-featured WinNT math macro
Replies: 21
Views: 370

Re: %MM% - a full-featured WinNT math macro

One thing you need to do is document all of the internal variables that are at risk of conflicting with user defined variables. The macro uses nested SETLOCALs. The first captures the user's environment and only variables beginning with dollar sign are used, because the dollar sign is a special sym...
by dbenham
09 Aug 2018 06:38
Forum: DOS Batch Forum
Topic: %MM% v0.2a - a full-featured WinNT math macro
Replies: 21
Views: 370

Re: %MM% - a full-featured WinNT math macro

I just now noticed your update (edit) to the first post :roll: I like the comments - they help a lot. But it is possible (even though extremely unlikely) that %# comment #% could be a valid variable. It is impossible for batch to define a variable like %= comment =%, and there are no pseudo variable...
by dbenham
09 Aug 2018 02:19
Forum: DOS Batch Forum
Topic: %MM% v0.2a - a full-featured WinNT math macro
Replies: 21
Views: 370

Re: %MM% - a full-featured WinNT math macro

One thing you need to do is document all of the internal variables that are at risk of conflicting with user defined variables. Ideally, all internal variables would be prefixed with a unique character, and then you could instruct users to simply avoid using variables with that prefix. You have alre...
by dbenham
08 Aug 2018 20:45
Forum: DOS Batch Forum
Topic: %MM% v0.2a - a full-featured WinNT math macro
Replies: 21
Views: 370

Re: %MM% - a full-featured WinNT math macro

Impressive :!: :D I've reformatted your MM definition to have consistent indents (2 spaces per level) that properly reflect the code structure, and there is now more than 100 bytes to spare when defining with delayed expansion. The trick to saving space is to expand an impossible variable name with ...
by dbenham
06 Aug 2018 15:25
Forum: DOS Batch Forum
Topic: Macros with parameters appended
Replies: 28
Views: 12906

Re: Macros with parameters appended

No, that was a side effect rather than a goal. We mistakenly thought the \n definition required ^<LF><LF>, meaning the (<CR>)<LF> at the end of the line would normally terminate the definition. The trailing ^ was just to force the next line to be appended to the definition. The escaped first charact...
by dbenham
06 Aug 2018 12:19
Forum: DOS Batch Forum
Topic: Macros with parameters appended
Replies: 28
Views: 12906

Re: Macros with parameters appended

Sure. The old \n was defined as ^^^<LF><LF>^<LF><LF>^^ After parsing the definition, the actual stored value is ^<LF><LF>^ When included at the end of a macro definition line, the ^<LF><LF> inserts a single <LF> into the macro definition, and the trailing ^ escapes the (<CR>)<LF> at the end of the s...
by dbenham
05 Aug 2018 19:49
Forum: DOS Batch Forum
Topic: Macros with parameters appended
Replies: 28
Views: 12906

Re: Macros with parameters appended

The \n value used to create multi-line macros can be greatly simplified as ^<LF> instead of ^<LF><LF>^.

Code: Select all

(set \n=^^^
%= This creates an escaped Line Feed - DO NOT ALTER =%
)

Dave Benham