Search found 2241 matches

by dbenham
07 Apr 2011 15:04
Forum: DOS Batch Forum
Topic: new functions: :chr, :asc, :asciiMap
Replies: 31
Views: 35092

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

The character searching in :asc or in :str2hex could be enhanced by a map (similar to :strLen) set "ch=a" set "ascMap=000#101#202#A41#B42" set "split=!ascMap:*%ch%=!" set /a "hexVal=0x!split:~0,2!" Great idea Jeb. I had hoped to use one map that would convert...
by dbenham
06 Apr 2011 23:53
Forum: DOS Batch Forum
Topic: new functions: :chr, :asc, :asciiMap
Replies: 31
Views: 35092

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

Correction - the code block is converting the TAB into 3 spaces. The TAB in the map outside the code block is correct. But the 161st character after the = is supposed to be ASCII decimal 160, but it has been corrupted into a space in both places.

Dave
by dbenham
06 Apr 2011 23:38
Forum: DOS Batch Forum
Topic: new functions: :chr, :asc, :asciiMap
Replies: 31
Views: 35092

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

Well I finally did what should have been obvious, and downloaded a free Hex editor. (thanks Jeb) It's much easier to investigate and work things out now. I added two additional related functions: :hex2str converts a string of hex digits into a string (for example 414243 -> ABC) :str2hex converts a s...
by dbenham
01 Apr 2011 17:36
Forum: DOS Batch Forum
Topic: new functions: :chr, :asc, :asciiMap
Replies: 31
Views: 35092

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

Thanks Jeb

I'll try out your suggestions in a few days. I'm heading out of town in a few minutes and won't have access to a computer.

Dave
by dbenham
01 Apr 2011 17:30
Forum: DOS Batch Forum
Topic: :lTrim bug and improved function template
Replies: 2
Views: 2083

Re: :lTrim bug and improved function template

Thanks Jeb for pointing out the flaw. I humbly withdraw my suggestion for the modified function template. I don't see a practical way to create a function that supports calls while delayed expansion is enabled. I think the :lTrim function should still be fixed though (switch from enabled to disabled...
by dbenham
01 Apr 2011 14:43
Forum: DOS Batch Forum
Topic: RENAME using redirection operators......
Replies: 2
Views: 2287

Re: RENAME using redirection operators......

Because command (program) command line arguments are not the same thing as command (program) input (also known as stdin, or standard input). From an English language perspective, yes they are both forms of input to the program. But from a programming standpoint they are very different. The < operato...
by dbenham
01 Apr 2011 13:10
Forum: DOS Batch Forum
Topic: new functions: :chr, :asc, :asciiMap
Replies: 31
Views: 35092

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

Simple solution, and powerfull. Thanks Jeb! What about the other issues in my prior back-to-back posts? I still can't get the other chars in my source code (editor limitation). But even if I do I'm worried what will happen when the command line interprets the text at execution time. For example, wil...
by dbenham
01 Apr 2011 12:44
Forum: DOS Batch Forum
Topic: :lTrim bug and improved function template
Replies: 2
Views: 2083

: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: 31
Views: 35092

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: 31
Views: 35092

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: 31
Views: 35092

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: 14306

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: 31
Views: 35092

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: 2049

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: 2049

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...