11-07-2022, 01:15 PM
(11-07-2022, 12:49 PM)Dimster Wrote: Hi Steve, so in your opening sentence "Let's start by.." you list the command as CVDMBF. Is that a typo or the command also works with Double?
It's a typo, but if you look at our wiki pages, you'll find that there's a half dozen different commands which look almost identical to this one.
CVD - QB64 Phoenix Edition Wiki
CVS - QB64 Phoenix Edition Wiki
CVI - QB64 Phoenix Edition Wiki
CVL - QB64 Phoenix Edition Wiki
CVDMBF - QB64 Phoenix Edition Wiki
CVSMBF - QB64 Phoenix Edition Wiki
Now, if you keep in mind that CV stands for "CONVERT to..", it's not hard to understand the rest of the command:
CVD -- convert string to Double.
CVS -- convert string to Single.
CVI -- convert string to Integer.
CVL -- convert string to Long.
MBF -- in Microsoft Binary Format.
The rest of the commands work *exactly* as I described above, but for their perspective variable type. Doubles are a constant 8-byte character string, Single and Long are 4-bytes, and Integers become constant 2-byte strings.
So even though I had a typo, the simple truth is you can still convert to Double/Long/Integer with just a single change of a letter in the command name. CVD converts to double, whereas CVS converts to single.
And, for those who want a slightly more modern version of these old commands (notice no underscore with these -- they were originally QBASIC conversion commands from waaay back in the day), there's always just _CV - QB64 Phoenix Edition Wiki and _MK$ - QB64 Phoenix Edition Wiki, which should work with any of the basic variable types you'd want, including Integer64, Byte, and Bit.