Computing.Net > Forums > Programming > Batch (ASCII )

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch (ASCII )

Reply to Message Icon

Name: uli_glueck
Date: January 31, 2006 at 08:02:19 Pacific
OS: NT4
CPU/Ram: P3 / 256 MB
Comment:

Hello,

how can I use ASCII Code with a Batchfile?

thanks in advance for any help
uli



Sponsored Link
Ads by Google

Response Number 1
Name: dtech10
Date: January 31, 2006 at 12:55:33 Pacific
Reply:

Hi
depends what you mean by use ASCII code.
If you want to echo an ASCII key thats not on
the keyboard, you could use...
echo [followerd by holding the [ALT] down and entering it's ASCII number on the Numeric Keypad.


0

Response Number 2
Name: uli_glueck
Date: February 1, 2006 at 00:50:43 Pacific
Reply:

Thanks for help dtech.
I want to echo an ASCII key which is not on the keyboard. (CR) ASCII 13. It works when I type it at the command line, but not in a batchfile.
Tried to save it as unicode also.

I need it for string substitution.

uli



0

Response Number 3
Name: Mechanix2Go
Date: February 1, 2006 at 01:12:34 Pacific
Reply:

Hi uli,

I don't quite get the idea of the echo working at the prompt but not in a BAT.

Can you post exact results, like this:

::== uli.bat
@echo off

echo £
::== DONE

C:\temp\-\bigger>echo £
£

C:\temp\-\bigger>uli
£

And it would help to know what you are trying to do.

"I need it for string substitution."

Can you explain that?



If at first you don't succeed, you're about average.

M2


0

Response Number 4
Name: uli_glueck
Date: February 1, 2006 at 01:53:26 Pacific
Reply:

Sorry for giving less information.
I have a huge textfile like this:

uli::glueck[BR]ritchie::blackmore[BR]....
([BR] means the html tag)
I want to format it like:

uli::glueck
ritchie::blackmore
....

I found out now how to substitiute the [BR]
against a Carriage Return:

set end=%var:[BR]=&echo.%

Works, but not when html tags are in the textfile.

I get a CMD.exe error when I try to parse the textfile with a for loop.
'the instruction in "0x013799da" refers to memory in "0x00000000"
read couldn't complete at the memory"'

my code:

for /f %%A in ('type c:\test.txt') do call :SUB %%A

goto :EOF
:SUB %%A
set var=%1
set var=%var:[BR]=&echo.%

echo %var%

Just using type or find at the commandline works.
I don't have any idea what to do.
Uli



0

Response Number 5
Name: Mechanix2Go
Date: February 1, 2006 at 02:07:09 Pacific
Reply:

Hi uli,

I think it will take IVO or somebody smarter than me to do this with a BAT.

What I do is use a 3rd party 'find & replace' utility.

For files up to 30KB:

Change


Since you said the file is huge, you need:

Change9.11



If at first you don't succeed, you're about average.

M2


0

Related Posts

See More



Response Number 6
Name: Mechanix2Go
Date: February 1, 2006 at 02:22:22 Pacific
Reply:

Hi again,

Note that those utilities are DOS utils, so the file to be handled must conform to 8.3 naming.

Here's a BAT I wrote which temporarily renmes the file to change. I think you get the idea.

::==
:main

dir /b *.html > htmlLIST
for /f "tokens=*" %%H in (htmlLIST) do call :sub1 %%H
cls
goto :eof

:sub1

ren "%1" "workFILE"
change.com workFILE "www.microsoft.com" "www.apple.com"
ren "workFILE" "%1"
goto :eof
:: DONE



If at first you don't succeed, you're about average.

M2


0

Response Number 7
Name: uli_glueck
Date: February 1, 2006 at 05:15:57 Pacific
Reply:

Hi M2,

many thanks for your help.

I found the problem.
I tried a textfile with a few lines only and had the same effect.
1.
The lines are to long to get them in a variable.
(This crashes my cmd)

2.
Cause of the HTML-Tags I need double quotes for setting the variable.
Thats why I can't substitute the string in the variable with &echo. It isn`t recognized as a command.

I fear to solve this problem is over my head.
Do you have an idea how to fix this problem?

I try to avoid 3rd party tools. If there is no way I can try it with sed.

uli



0

Response Number 8
Name: Mechanix2Go
Date: February 1, 2006 at 05:36:56 Pacific
Reply:

Hi uli,

Wait for IVO to jump in.


If at first you don't succeed, you're about average.

M2


0

Response Number 9
Name: uli_glueck
Date: February 1, 2006 at 08:53:52 Pacific
Reply:


Problem 2 is solved: :-)

set var="uli[br]glueck"
set var=%var:[br]=#~#%
set var=%var:"=%
set var=%var:#~#=^&echo.%
echo %var%

uli


0

Response Number 10
Name: Mechanix2Go
Date: February 1, 2006 at 09:07:34 Pacific
Reply:

Hi uli,

That's heavy.


If at first you don't succeed, you're about average.

M2


0

Response Number 11
Name: dtech10
Date: February 2, 2006 at 14:15:51 Pacific
Reply:

Hi uli
If you don't need the quotes, this would be shorter.

@echo off
set var=uli[br]glueck
set var=%var:[br]=^&echo.%
echo %var%


0

Response Number 12
Name: uli_glueck
Date: February 3, 2006 at 00:37:16 Pacific
Reply:

Hi dtech,
thanks.
I need the double quotes cause of the html tag in the variable.
Otherwise I get the errormessage
"System can't find the file".

The code looks a bit circular. I know.

uli


0

Response Number 13
Name: dtech10
Date: February 3, 2006 at 06:34:13 Pacific
Reply:

Hi uli
A bit shorter but not much.

@echo off
set var="uli[br]glueck"
rem remove quotes
set var=%var:"=%
rem change [br] to CR
set var=%var:[br]=^&echo.%
echo %var%


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch (ASCII )

batch syntax question www.computing.net/answers/programming/batch-syntax-question/9088.html

HTML and DOS Batch questiona www.computing.net/answers/programming/html-and-dos-batch-questiona/9040.html

Batch File Problems www.computing.net/answers/programming/batch-file-problems/13301.html