HOME  - -  Lazarus/ Delphi tutorials

Converting a string with a decimal number to

a string with the equivalent hex... or other number

And why you might want to do that.

(Page's URL: ldn137-138-dec-to-hex-etc.htm)

If I have a dozen eggs, I have 12... at least that's what most people think. Computer people don't always think like other people, had you noticed? There are times when we would call it "$0A" eggs... the times when we are using hexadecimal notation. A notation that is very handy in some circumstances.

My Arduserver system is concerned with transmitting values from sensors. And the readings may end up in a data file.

Today, transmission speeds are so high and the cost of store so low that my preference for shortening things is probably just silly. I had fun with the following, anyway, and maybe you will either have fun or at least find something useful to you.

Unfortunately...

Unfortunately, I had so much fun that I lost track of the time, and over-ran what was available.

So this is half finished. Are you a "glass half full" person? If so, you could enjoy some of what I present here.

I have little by way of webpage for you... but there are a LOT of comments in the source-code. They not only cover the usual needs for documentation, but also cover the sorts of things I usually do in a web page.

There are two separate applications here.

The first is LDN138, and the second is LDN137. (Sorry about the illogical numbering.

The first may be useful to intermediate Lazarus users as an example of the ways some things can be done. It is a fairly tidy, "nice" little program. But the HEART of these programs is meant to be converting between number representations, and LDN138 (the first, more basic code) entirely funks THAT bit of programming and just uses Lazarus's "HexStr"!

But fear not... LDN137 builds on the foundation the earlier program constitutes, and does...

...the conversion of...

   a string representing a quantity with a decimal number

.......... to .............

        a string using a hexadecimal number.

Put "12" in, and you get "$0A" out! Both programs! (The user sees little difference.

Gee. Wow.

Not!

The second program... not quite finished, alas, but it works as far as it goes... WILL (you can do it!) ALSO convert that decimal-string input to an output in any base up to base 41!

And why you would want to do so is explained in comments in LDN137.

Enjoy. Sorry the webpage is weak... but it IS worth what you paid for it... at least!

The code!

Sourcecode and compiled .exe for simple version, 'Part one'. Zip file.

Sourcecode and compiled .exe for fancy version, 'Part two'. Zip file.

A few words from the sponsors...

Please get in touch if you discover flaws in this page. Please mention the page's URL. (wywtk.com/lut/ldn137-138-dec-to-hex-etc/ldn137-138-dec-to-hex-etc.htm).

If you found this of interest, please mention in forums, give it a Facebook "like", Google "Plus", or whatever. If you want more of this stuff, help!? There's not much point in me writing these things, if no one feels they are of any use.



index sitemap
What's New at the Site Advanced search
Search tool (free) provided by FreeFind... whom I've used since 2002. Happy with it, obviously!

Unlike the clever Google search engine, this one merely looks for the words you type, so....
*    Spell them properly.
*    Don't bother with "How do I get rich?" That will merely return pages with "how", "do", "I"....

Please also note that I have three other sites, and that this search will not include them. They have their own search buttons.

My SheepdogSoftware.co.uk site, where you'll find my main homepage. It has links for other areas, such as education, programming, investing.

My SheepdogGuides.com site.

My site at Arunet.




How to email or write this page's editor, Tom Boyd. Please cite page's URL, ldn137-138-dec-to-hex-etc.htm, if you write.


Test for valid HTML

Page has been tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org. It passes in some important ways, but still needs work to fully meet HTML 5 expectations. (If your browser hides your history, you may have to put the page's URL into the validator by hand. Check what page the validator looked at before becoming alarmed by a "not found" or "wrong doctype".)

AND passes... Test for valid CSS


Why does this page cause a script to run? Because of the Google panels, and the code for the search button. Also, I have my web-traffic monitored for me by eXTReMe tracker. They offer a free tracker. If you want to try one, check out their site. Why do I mention the script? Be sure you know all you need to about spyware.

....... P a g e . . . E n d s .....