Search found 2429 matches

by dbenham
01 Apr 2011 12:44
Forum: DOS Batch Forum
Topic: :lTrim bug and improved function template
Replies: 2
Views: 4633

:lTrim bug and improved function template

There is a bug in the current :lTrim function that prevents it from supporting strings containing ! test0.bat - Test with existing code: @echo off setlocal disableDelayedExpansion set kind=cruel set test= Hello !kind! world! Goodbye! and Hello again! and so on... set test call :lTrim test set test e...
by dbenham
31 Mar 2011 18:47
Forum: DOS Batch Forum
Topic: new functions: :chr, :asc, :asciiMap
Replies: 35
Views: 156318

Re: new functions: :chr, :asc, :asciiMap

...and I'm back to thinking many of the "problematic" characters are still a problem. The problematic characters can be handeld with delayed expansion. I can't use delayed expansion in my endlocal block that returns the results. This was what I meant in my original post when I said "I...
by dbenham
31 Mar 2011 17:37
Forum: DOS Batch Forum
Topic: new functions: :chr, :asc, :asciiMap
Replies: 35
Views: 156318

Re: new functions: :chr, :asc, :asciiMap

...and for the TAB character, I can get that character in my source, but my programming editor is typically set to convert tabs into spaces. Eventually I'm sure I would make a mistake and forget to disable this feature when editing the source, and my map would become corrupted. Any way to programmat...
by dbenham
31 Mar 2011 17:30
Forum: DOS Batch Forum
Topic: new functions: :chr, :asc, :asciiMap
Replies: 35
Views: 156318

Re: new functions: :chr, :asc, :asciiMap

Thanks again Jeb. What about the other non NULL "problematic" characters? I'm still stumped on how to introduce them. I have some concern with 0x0A (Ctrl-Z). Is this no longer treated as an end of file marker? I haven't done any testing, I'm just remembering issues I ran into back in the 8...
by dbenham
31 Mar 2011 17:04
Forum: DOS Batch Forum
Topic: BatchLibrary or how to include batch files
Replies: 14
Views: 34834

Re: BatchLibrary or how to include batch files

Thanks Jeb Just 1 comment for a change You are right, it seems to be impossible to get the line number of block-calls, therefore I simply ignore this! I only try to catch line numbers outside of blocks. That's the parsing that boggles my mind! ⋅ You have to recognize when it's possible to ...
by dbenham
31 Mar 2011 05:12
Forum: DOS Batch Forum
Topic: new functions: :chr, :asc, :asciiMap
Replies: 35
Views: 156318

new functions: :chr, :asc, :asciiMap

Here is code I developed for 3 new functions to support bi-directional conversion between numeric ASCII codes and characters. I think I saw routines with similar functionality some where that relied on DEBUG and temp files. These routines do not need either. There are 10 characters that are problema...
by dbenham
30 Mar 2011 22:19
Forum: DOS Batch Forum
Topic: Enhanced toHex function
Replies: 3
Views: 6696

Re: Enhanced toHex function

Oooh! :D I like the bit manipulation in the final version!

Very clean and efficient.

I think in my own version I will add a leading /S option to the parameter list. If passed then I'll shift the arguments and activate the code to strip leading zeros.

Dave
by dbenham
27 Mar 2011 22:57
Forum: DOS Batch Forum
Topic: Enhanced toHex function
Replies: 3
Views: 6696

Enhanced toHex function

This proposed replacement for toHex has the following improvements: 1) Added support for negative numbers (the wonders of two's complement math) 2) Eliminated leading zeros from output (personal preference) 3) The new Hex map lookup strategy is simpler and slightly faster :toHex dec hex -- convert a...
by dbenham
20 Feb 2011 03:20
Forum: DOS Batch Forum
Topic: BatchLibrary or how to include batch files
Replies: 14
Views: 34834

Re: BatchLibrary or how to include batch files

Thanks for your excellent response Jeb. Both your code and explanations are very instructive. But the library start could be at the end of a batch file, triggered with an goto :startLib Ouch! I never considered anyone would put the include anywhere other than the top. Can you think of a reason why t...
by dbenham
18 Feb 2011 00:57
Forum: DOS Batch Forum
Topic: BatchLibrary or how to include batch files
Replies: 14
Views: 34834

Re: BatchLibrary or how to include batch files

Hi Jeb Thanks for your response Wow! so many things to talk about. I wanted to respond earlier, but for some reason my account was temporarily deactivated yesterday. ------- <:%BL.Start% - Very interesting, with good explanation. I'll file that trick away in my head - maybe it will come in useful so...
by dbenham
15 Feb 2011 23:13
Forum: DOS Batch Forum
Topic: BatchLibrary or how to include batch files
Replies: 14
Views: 34834

Re: BatchLibrary or how to include batch files

Arrg! I hit submit when I meant to hit preview. To continue - I'm sure I've seen the technique in my previous post described elsewhere, but when I look throughout this site now I realize I don't see any mention of it here. It seems this is much simpler and cleaner than trying to implement an include...
by dbenham
15 Feb 2011 22:53
Forum: DOS Batch Forum
Topic: BatchLibrary or how to include batch files
Replies: 14
Views: 34834

Re: BatchLibrary or how to include batch files

Cool (and scary) looking stuff, though I'm wondering if I have a simpler solution. this site shows many functions and they all can build a useful library, but it's always annoying that I have to copy & paste them into my code. I was surprised by the statement above in bold. When I first discover...
by dbenham
12 Feb 2011 22:40
Forum: DOS Batch Forum
Topic: String Comparison
Replies: 7
Views: 9112

Re: String Comparison

Oops! In my 2nd option I forgot to remove the echo from the code I used for testing. Here it is corrected setlocal set parm="|%~1|" set parm=%parm:\=\\% echo "|-help|/?|-?|\?|/h|\h|-h|"|findstr /i %parm% >nul && (endlocal & goto :Help) endlocal Needless to say, this o...
by dbenham
12 Feb 2011 22:29
Forum: DOS Batch Forum
Topic: String Comparison
Replies: 7
Views: 9112

Re: String Comparison

The problem is simplified if you prepare a delimited list of options, making sure to include the delimiter at both the beginning and end of the string. If it's OK for the search to be case sensitive then the following works (expand delimited list as needed): setlocal enableDelayedExpansion set helpO...