aGerman wrote:I wonder if it could be useful ...
On a tangent, I wonder if the following would be considered fair game for a Quine attempt...
Code: Select all
@setlocal=enableExtensions,enableDelayedExpansion&set/pq=<"%~f0"&echo(!q!
Even shorter if "cmd /e:on /v:on" is assumed, of course.
aGerman wrote:That makes things easier for macros and it protects you from the critical empty lines for a line feed character.
Right, but also introduces ^Z control characters down the file.
I was hoping for an alternative to confine control characters to just the top line, so as to leave the rest of the file "plain printable ascii". Haven't found the right incantation to do it without a "critical empty line" though.
Code: Select all
:: @rem
::* * *
::70000000007000001111111111711111 1 0x
::F123456789FBCDEF0123456789FBCDEF A
@set /p "ctrlChrs=" <"%~f0"
@setlocal enabledelayedexpansion
@set ctrlChrs=!ctrlChrs:~2,10!^
!ctrlChrs:~13,15!^
!ctrlChrs:~35,1!^
!ctrlChrs:~29,5!
@echo !ctrlChrs!
Note that the first line won't copy/paste nicely, since browsers and editors differ in their handling of control characters within text. Lines 3 and 4 list the actual character codes supposed to go into the saved batch file (7F, 01, 02, etc).
Once saved and run, the screen output is useless (again, because of the control characters), but redirecting >somefile should look like this in a hex viewer...
Code: Select all
00000000 7F 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F ☺☻♥♦♣♠•◘○◙♂♀♪♫
00000010 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F ►◄↕‼¶§▬↨↑↓→←∟↔▲
00000020 0D 0A ♪◙
...and prove that the "ctrlChrs" variable does indeed hold the 1..31 range of ASCII control codes (code 0 is NUL which can't really be handled, and is replaced with 0x7F DEL here). So, !ctrlChrs:~n,1! is the respective character for n=1..31 and could be used as such for the remainder of the batch file.
Liviu