tags:

views:

332

answers:

4

Is it possible to format a string to a hex value using DOS command? I'm trying to pass a hex value to my program from command line but it takes that complete value a a string and not as hex value?

A: 

Isn't more logic to the program that receive the parameter to do the conversion?? Also testing that the parameter is ok??? And no, I don't think there is such function on DOS.

gbianchi
A: 

No it only passes strings. You need to do the conversion to hex from inside your program.

Goz
A: 

I'm not sure about a DOS command, but you can use Windows Calculator to do this... Just put it into Scientific Mode (the View menu), then put it into Decimal mode (also the View Menu), then type the number, then put it into Hex Mode (again, in the View menu). It will show you the corresponding Hex value for the decimal number you entered.

Michael Bray
+2  A: 

Forget about Peak Oil, what about Peak DOS? It's time to look to the future. And the future is PowerShell.

PS >  "{0:x4}" -f ([int]"999")
03e7

Jay Bazuzi
seems like a lot of typing just to convert a number... ??
Michael Bray
Is it less typing than all the typing that goes in to a highly specialized, custom .EXE who's sole purpose is to convert decimal to hex?Is it less typing than a CMD script that is able to convert decimal numbers to hex, with all the parsing, etc? See `set /?` for the `/A` switch that would make it possible. I could do it in less than 100 lines, but then I'd have a headache the rest of the day.
Jay Bazuzi