Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi folks. I've once developed a batch script that would convert hexadecimal values to decimal values and vice-versa.
I've made a new version of it (2.0). The sintax is much simpler (it was kinda confusing at previous version), there is a much better error checking, which includes error checking for invalid numbers, and the
source is much more simpler. The converted number is saved into %num%. The speed didn't change too much. See timing below:PIII-700Mhz RAM-128MB Windows 98 second edition
convert.bat FFFF h = 0.21 seconds
convert.bat 65535 d = 0.28 secondsThe maximum number to convert is FFFF h and 99999 d.
The source code is in the following URL:http://www.batch.hpg.com.br/other/convert.txt
Comments are welcome. I hope anyone finds some use to this!
-- Secret_Doom - Leonardo Pignataro --
secret_doom@hotmail.com
www.batch.hpg.com.br

Now that's cool. I thought stuff like this was impossable.
Now is it be possable to add a input and a read from a file. Do conversion then write to a second file. ?
That would be really neat !
VP

VP, do you mean adding two more ways of using the script, one would be to ask user the number and type of conversion, and the other would be get the number from a file, convert and store on an another file, is that it?
Well, that is pretty possible!
Anyway, be aware... I didn't make a *pure* conversion. Who actually does the real conversion is DEBUG.exe.
On the hex-dec conversion, I run a script like this:
Nfilename.ext
rcx
[n]
w
q[n] is the number to be converted.
Then, I make a "dir filename.ext". The output from this has the file size, but in decimals. Then I just have to get the number out from the output.The dex-hex conversion creates a file which size is the number to be converted. Then I run this script:
w
qThe output has the file size, in hexadecimals! Again, all what's left to do is extract the number from the output.
-- Secret_Doom - Leonardo Pignataro --
secret_doom@hotmail.com
www.batch.hpg.com.br

Sorry, I did not make myself clear.
Input a file name
open file
Read a byte from file
Convert
Write converted to second file
Loop till EOF of first file.

Yes, of course it's possible. Let's number the procedure:
1. Get user input (filename)
2. Get first line from filename to a variable
3. Convert variable
4. Write to a second file (hardcoded name?)How to do all that:
1. http://www.batch.hpg.com.br/index.htm#07
2. http://www.batch.hpg.com.br/index.htm#15
3. convert.bat (run on a subroutine)
4. "echo %num%> output.ext"Just put it all togeter! Of course, there should be some error checking between those procedures (e.g.: check if inputed filename exists)
Do you really need it or you're jusk asking if it's possible? If you want it, I can make for you, it won't cost be more that a few minutes.
-- Secret_Doom - Leonardo Pignataro --
secret_doom@hotmail.com
www.batch.hpg.com.br

secret_doom,
That be a neat batch file to have.
But I can't think of anything to use
it in. So dont waste your time trying
to make it.Thanks for the help and time.
VP

![]() |
![]() |
![]() |

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