Is there a way I can echo a tab into a text file?
I've been trying to a find something with ^ to escape it, but I don't
know what character I can use next.
Thanks,
Just use the . with a tab character.
echo.TABCHARACTER
or to omit any trailing CR/LF pair use this
set /p "=TABCHARACTER"<nul
--
Regards,
Mic
That worked, thanks!
Does that really work on your system with "TABCHARACTER" replaced by "
"?
Frank
Replaced by a literal TAB? yep.
--
Regards,
Mic
This is confusing. On when my WV HOBOS, and I think on XP when I had it,
any whitespace immediately following the '=' is lost. So
Set /p "= TWO SPACEs"<nul
prints:
TWO SPACEs
And
Set /p "= TAB"<nul
prints:
TAB
Frank
On my OS when the double quote is on the right hand side of the equals sign
then it removes leading whitespace.
Set /p "= TWO SPACEs"<nul
versus
Set /p =" TWO SPACEs"<nul
--
Regards,
Mic
Mine also does that; both on the left and right.
I wonder if we have a difference here which should be explored. With the
following script:
SetLocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
Set /P "=["<NUL:
Set /P "= TAB"<NUL:
Set /P =" TAB"<NUL:
Set /P "= SPACE"<NUL:
Set /P =" SPACE"<NUL:
Echo=]
I get this:
[TABTABSPACESPACE]
The word TAB is preceded by a single tab and the word SPACE is preceded
by a single space.
Frank
>"foxidrive" news:l08on51h7bnedu60n...@4ax.com...
>> On my OS when the double quote is on the right hand side of the equals sign
>> then it removes leading whitespace.
>
>Mine also does that; both on the left and right.
>
>I wonder if we have a difference here which should be explored. With the
>following script:
>
> SetLocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
> Set /P "=["<NUL:
> Set /P "= TAB"<NUL:
> Set /P =" TAB"<NUL:
> Set /P "= SPACE"<NUL:
> Set /P =" SPACE"<NUL:
> Echo=]
>
>I get this:
>
>[TABTABSPACESPACE]
[ TABTAB SPACESPACE]
You're using vista? Have you rebooted?
--
Regards,
Mic
I have not rebooted in a long time; I use hibernation.
If you're thinking of a fix via Windows Update I have rebooted many
times since the last update I've received, but I stopped updating almost
a year ago. I was getting only 10-15 minutes per day on the Internet and
Microsoft wanted to use it all, or more. Now I'm afraid to update.
Do you think it's a recent fix?
Frank
>"foxidrive" news:cbaon59j8ppf1p6gi...@4ax.com...
>> You're using vista? Have you rebooted?
>
>I have not rebooted in a long time; I use hibernation.
>
>Do you think it's a recent fix?
I'm not thinking of a fix - but sometimes CMD misbehaves until a reboot. Do
so and then test your script...
--
Regards,
Mic
>times since the last update I've received, but I stopped updating almost
>a year ago. I was getting only 10-15 minutes per day on the Internet and
>Microsoft wanted to use it all, or more.
Do you get more time now? I wonder if a pal could download the service
packs and updates for you on a USB key - once you're updated and if you
have more online time you could catch up again.
Do you use dialup these days?
--
Regards,
Mic
Done. No change. I recall this behavior from at least as far back as
when I wrote the color routines using FINDSTR.
The system is Windows Vista Home Basic with service pack 1, US English.
"foxidrive" news:tobon5pvu589ko9jo...@4ax.com...
> Do you get more time now?
During Winter (north hemisphere) I have electricity and wireless nearby
and usually spend several hours on the computer while on the Internet.
In another month or two I'll be moving back to where it is a two-mile
walk to both, the electricity indoors and the wireless out in the rain.
I hadn't thought of it but now I'll plan to update the system before I
move back.
Frank
(snip)
One generic comment, which you two experienced regulars of course know
well, but for the less initiated. When evaluating the results of echoing
elusive characters like the tab it pays to use a hex editor (or the
like) to see what the outcome truly is.
All the best, Timo
--
Prof. Timo Salmi mailto:t...@uwasa.fi ftp & http://garbo.uwasa.fi/
Hpage: http://www.uwasa.fi/laskentatoimi/english/personnel/salmitimo/
Department of Accounting and Finance, University of Vaasa, Finland
Useful CMD script tricks http://www.netikka.net/tsneti/info/tscmd.php
>Done. No change. I recall this behavior from at least as far back as
>when I wrote the color routines using FINDSTR.
>
>The system is Windows Vista Home Basic with service pack 1, US English.
I guess that is another Microsoft 'gotcha'.
I started up Win7RC and also Vista in a VM and they both behave as yours
does.
>During Winter (north hemisphere) I have electricity and wireless nearby
>and usually spend several hours on the computer while on the Internet.
>In another month or two I'll be moving back to where it is a two-mile
>walk to both, the electricity indoors and the wireless out in the rain.
>I hadn't thought of it but now I'll plan to update the system before I
>move back.
I'm curious where your are moving to that has no electrickery. I'm so
accustomed to it that if we have an outage for just 3 hours I find myself
walk around switching lights on that don't work even when I have a torch,
think about making hot water for coffee in the electric kettle, nuking
stuff in microwave, watching TV etc etc etc.
--
Regards,
Mic
>One generic comment [...] for the less initiated. When evaluating the results of echoing
>elusive characters like the tab it pays to use a hex editor (or the
>like) to see what the outcome truly is.
That's a good point, Timo.
The file manager Total Commander which I use has a built in viewer that can
also display hex and I used it to display the hex 09 (Tab character) in the
file that the code created. I was going to copy and paste it in reply to
Frank but my hex screen doesn't support copying.
Here's a short teaser about viewing hexadecimal numbers (base 16) for those
that haven't used one: to begin with a hex viewer/editor displays a file in
both hexadecimal and plain text so you can identify which particular
character you are looking at.
A smattering of knowledge about the first 127 characters in the ASCII
character set is valuable. http://www.asciitable.com/ For example a
capital A is ASCII character 65 (hex 41) and a carriage return and line
feed pair of characters at the end of every line of plain text in Windows
is hex 0D 0A (ascii characters 13/10).
The first 31 (decimal) ASCII characters are control characters, and then
comes the space character (ascii character 32/hex 20), some punctuation,
and then the alphabet in order.
When dealing with control characters, spaces, tab, EOF markers and other
things in any kind of file a hex viewer can be very useful to identify
which is which.
If you've read this far and haven't yet used hexadecimal, the numbers in
hexadecimal count from 0 to 9 and then adds the letters A to F to make 16
characters, including zero.
So hex 0F is 15 decimal. Hex 0A is 10 decimal. B, C, D, E are 11, 12,
13, 14 respectively. So 0A 0B 0C 0D 0E 0F are 10 11 12 13 14 15
It gets interesting when the numbers after 0F hex are looked at and they
run like this.
10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23....
which are equal to (in decimal)
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35...
So you see that a space character, ASCII 32
(see http://www.asciitable.com/ ) is equal to 20 in the line above it and
every space character in a hex viewer will also be represented as hex 20.
The ascii table linked above has the characters and their numbers in hex,
decimal and octal, so you can compare them and look up the codes when you
need to.
Hex viewers allow you to do other nifty things - like identify the type of
file you have even when it has been renamed with a different extension.
For example a ZIP file starts with the characters PK and a JPG picture has
JFIF in the first 7 or so characters. A Gif picture has GIF at the start.
Here is a hew viewer showing an EXE file which you can see has the MZ as
the first two characters. http://www.fileviewer.com/HexView.gif
Download one and look at some of your files - there is lots of readable
text in program files... in the old days the cheat codes for games could be
picked out.
Don't forget to bookmark http://www.asciitable.com/
--
Regards,
Mic
Sounds good in theory, but without the update utility calling home to
analyze which updates have already been installed on the system, how should
his pal know which updates to download?
>
> Do you use dialup these days?
I don't miss those days.
--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)
--- news://freenews.netfront.net/ - complaints: ne...@netfront.net ---
Before moving away, one of my neighbors used to pack up and go camping all
summer long. He drove back to the city daily to work and then returned to
his fire ring every day. Sometimes he would even check his mail. Sure there
was electricity, water and phones out there, but without hi-speed internet,
why bother. :-O
>Before moving away, one of my neighbors used to pack up and go camping all
>summer long. He drove back to the city daily to work and then returned to
>his fire ring every day. Sometimes he would even check his mail. Sure there
>was electricity, water and phones out there, but without hi-speed internet,
>why bother. :-O
It's not my cup of tea. Bloody mosquitoes feast on me when I'm out at
night. I love camping, well that's past tense actually coz I need a well
supporting chair these days to keep the busted bones moving. Motor bikes
and pavement are an unforgiving combination.
--
Regards,
Mic
>> Do you get more time now? I wonder if a pal could download the service
>> packs and updates for you on a USB key - once you're updated and if you
>> have more online time you could catch up again.
>
>Sounds good in theory, but without the update utility calling home to
>analyze which updates have already been installed on the system, how should
>his pal know which updates to download?
Frank has Vista Service Pack 1 so Vista Service Pack 2 is a good start.
It's 350 MB.
>> Do you use dialup these days?
>I don't miss those days.
The BBS from those days were fun, but I kinda prefer the internet and
broadband too. :)
--
Regards,
Mic
As you will have seen, echoing a tab character is practically like
echoing any standard character. No escaping or extra tricks are needed.
The only thing that may require some finding out is writing the tab-char
as a literal with your text editor when writing the batch. How that is
done in the editor is editor specific.
>Is there a way I can echo a tab into a text file?
>I've been trying to a find something with ^ to escape it, but I don't
>know what character I can use next.
For systems that can run 16-bit programs (DOS, Windows, but not 64-bit
Windows). EKKO, via sig line 3, can "echo" any one-byte character, any
reasonable number of them, with short cuts for spaces and strings. And
it copies what is piped into it (Oh! not in XP?). ZIP, via sig line 3,
includes PAS code and EXE. There's another EKKO at chebucto.
>ekko 'c 9 'd
c d
>ekko 'cggg 9 'd
cggg d
Code, excluding comment and blank lines, is 21 lines or so.
--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk DOS 3.3, 6.20; WinXP.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm> - also batprogs.htm.
Do you think it might be that commander thing (sorry, I forgot the name)
you use to run CMD through? It seems unlikely to me but I think we
should identiy the cause of the difference.
Frank
No, I tested with a cmd window. It's probably just changes in cmd.exe, as
it's an internal command.
--
Regards,
Mic
You wrote that the leading whitespace failed to reproduce on Win7RC (I
don't know what an RC is) and on Vista so I assumed that the successful
leading whitespace behavior was on XP. My recollection might be in error
but I think I was getting the failures on XP when I had access to it, so
I don't see how a revision to CMD would be the cause.
What version OS succeeds in printing leading whitespace with SET/P?
So far we have:
XP ?
Vista fails
7 fails
Frank
Yep. XP pro SP3. You'll have to get verification from other users.
>Vista fails
>7 fails
Yes.
Win7 RC was the release candidate that MS allowed downloads of.
--
Regards,
Mic
My XP machine came with SP1 installed and I could not get SP2 to
install. Windows Update would not install it so I downloaded both the
full and partial service packs and received the same mysterious error
code that Windows Update returned. So if my recollection is correct that
SET/P prints leading whitespace on XP then it was XP prior to SP2.
Frank