Understand hexadecimal numbers
I was working with IM today. I found some toolbox constants that I need. There is only one problem: they are hex values. How do I set up FB (1.0.3) to recognize those as Hex numbers? (I need to add them, like you would add attributes for a window... so I don't think strings would work...)
Just assign the constants hex values.
Basically if you can do it in hex you can do it in decimal. If you assign the hex value to a variable it will be converted into decimal, but that doesn't change its value, just its representation. In other words, you could also convert the toolbox hex values into decimal and use them that way.
Yes. But, if IM lists constants in hex, isn't hex what the ToolBox expects if you use that constant? In other words, if you pass a decimal value (let's say 10) to a toolbox function that was expecting a hex value, couldn't bad stuff happen? (like your 10 (decimal) getting interpreted to 10 (hex)). Or, is the Toolbox smarter then that?
Are we talking about numbers or strings? If you are entering numbers, the computer knows them only in binary. FB converts all numeric entries into binary values, just as it does all FB commands. You tell FB what format you are giving it by using a "&" prefix to indicate hex, omit it to indicate decimal. As long as you remember to do that (and make sure you know which you are using) you don't have to worry about it beyond that.
The Toolbox itself is "language-independent," and doesn't care what the constant looked like (i.e., what "base" it was in) when you typed it into your language editor (such as FB's editor). The real question is whether the compiler/assembler that converts it from text into actual bits in memory is smart enough to do that conversion right. FB is smart enough, if you give it some help. If, in your source code, you precede the digits with "&" (or in some cases "$") then FB does a hex-to-binary conversion before feeding the number to the Toolbox. If you don't put any special symbol before the digits, then FB does a decimal-to-binary conversion before feeding the number to the Toolbox.