DAY 002: CVSMBF
#3
(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.  Smile



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.  Smile
Reply


Messages In This Thread
DAY 002: CVSMBF - by SMcNeill - 11-07-2022, 05:10 AM
RE: DAY 002: CVSMBF - by Dimster - 11-07-2022, 12:49 PM
RE: DAY 002: CVSMBF - by SMcNeill - 11-07-2022, 01:15 PM
RE: DAY 002: CVSMBF - by Pete - 11-07-2022, 06:37 PM
RE: DAY 002: CVSMBF - by bplus - 11-07-2022, 07:22 PM
RE: DAY 002: CVSMBF - by Dimster - 11-07-2022, 07:57 PM
RE: DAY 002: CVSMBF - by Pete - 11-07-2022, 08:53 PM
RE: DAY 002: CVSMBF - by SMcNeill - 11-07-2022, 09:08 PM



Users browsing this thread: 5 Guest(s)