QB64 Phoenix Edition
CVSMBF, MKSMBF$, ETC. - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10)
+---- Thread: CVSMBF, MKSMBF$, ETC. (/showthread.php?tid=640)



CVSMBF, MKSMBF$, ETC. - arnoldhf - 07-18-2022

Some questions:

1. As I mentioned in another thread, I wrote extensive QB programs Back in the 80s & 90s when RAM and HD space was at a premium. I used MKI$, MKS$ and MKD$ extensively in my databases.

Converting the programs using QB64 I noticed they, MKS$ etc., were not converting back properly with CVI, CVS, and CVD.

I found and tested CVSMBF and that seemed to work. Does that mean to continue accessing/using my existing databases with QB64 EXEs I must modify the syntax by adding MBF to all of the above, e.g. MDS$ becomes MDSMBF$, etc.?

2. Is there a way to position the window of the running program so it always opens to the same spot on the desktop?

3. When the program exits, I sometimes get the message "press any key to continue" when all I want is the window to close.

Thanks,
 
Arnold


RE: CVSMBF, MKSMBF$, ETC. - bplus - 07-18-2022

"2. Is there a way to position the window of the running program so it always opens to the same spot on the desktop?"

_ScreenMove leftX, topY ' after screen statement, there is also
_ScreenMove _Middle ' <<< but this takes some time so a _Delay or _Screenexists check is needed, bah too slow IMHO

"3. When the program exits, I sometimes get the message "press any key to continue" when all I want is the window to close."

Don't use End, use System


RE: CVSMBF, MKSMBF$, ETC. - SMcNeill - 07-18-2022

Is this a problem with the return type that you're moving your variable back in to?  As far as I can tell, MKD$ works as it should, and we haven't had any error reports with it before.

Code: (Select All)
Dim x As Double, y As Double
x = 3.141592654
t$ = MKD$(x)
y = CVD(t$)
z = CVD(t$)

Print x
Print t$
Print y
Print z

As you can see from the above, if we take a value from a double, convert it to a string, then convert it back to a different double, the value remains the same.  
There is a loss of precision, however, when we try and put that same double value into a SINGLE, as we see with z.


If you can share some code that isn't working as expected, we'll be more than happy to look into it.


RE: CVSMBF, MKSMBF$, ETC. - arnoldhf - 07-18-2022

Here is a snippet from QB that I executed in QB:

  a = 91234.56
  b$ = MKD$(a)
1 c = CVD(b$)
2 PRINT c
   PRINT b$
OPEN "O", 1, "testmkd"    'sent it a file
WRITE #1, b$
CLOSE 1

The result of lines 1-2 correctly yields the proper value of "a".
--------------------------------------------------------------------------------------
Here is the QB64 code I used to test b$ that I wrote to the file:

   Open "I", 1, "testmkd"
   Input #1, b$
1 Print CVD(b$)
2 Print CVDMBF(b$)
   close 1

OUTPUT:
-7.6795... D-226    (line 1)
91234.5625          (line 2)

As you can see only line 2 correctly interpreted the string b$ back to the original value of a in QB.

Arnold


RE: CVSMBF, MKSMBF$, ETC. - arnoldhf - 07-18-2022

(07-18-2022, 01:31 PM)bplus Wrote: "2. Is there a way to position the window of the running program so it always opens to the same spot on the desktop?"

_ScreenMove leftX, topY ' after screen statement, there is also
_ScreenMove _Middle ' <<< but this takes some time so a _Delay or _Screenexists check is needed, bah too slow IMHO

"3. When the program exits, I sometimes get the message "press any key to continue" when all I want is the window to close."

Don't use End, use System

Thank you bplus. Woked just as youe said.

Arnold

I need to adjust my spell checker...

Thank you bplus. Worked just as you said.


RE: CVSMBF, MKSMBF$, ETC. - SMcNeill - 07-18-2022

(07-18-2022, 05:06 PM)arnoldhf Wrote: Here is a snippet from QB that I executed in QB:

  a = 91234.56
  b$ = MKD$(a)
1 c = CVD(b$)
2 PRINT c
   PRINT b$
OPEN "O", 1, "testmkd"    'sent it a file
WRITE #1, b$
CLOSE 1

The result of lines 1-2 correctly yields the proper value of "a".
--------------------------------------------------------------------------------------
Here is the QB64 code I used to test b$ that I wrote to the file:

   Open "I", 1, "testmkd"
   Input #1, b$
1 Print CVD(b$)
2 Print CVDMBF(b$)
   close 1

OUTPUT:
-7.6795... D-226    (line 1)
91234.5625          (line 2)

As you can see only line 2 correctly interpreted the string b$ back to the original value of a in QB.

Arnold

The problem is that your default variable type is SINGLE, instead of a DOUBLE.  Try this:

Code: (Select All)
Dim As Double a, c
Dim As Single lookieHere
Print "************************** WRITING"
a = 91234.56
b$ = MKD$(a)
c = CVD(b$)
Print c
Print b$
Open "O", 1, "testmkd" 'sent it a file
Write #1, b$
Close 1
Print "************************** READING"


Open "I", 1, "testmkd"
Input #1, c$
Print CVD(c$)
Print c$
'Print CVDMBF(c$)
Close 1

Print "************************** DEBUGGING"
a = 91234.56
lookieHere = 91234.56
b$ = MKD$(a): d$ = MKD$(lookieHere)
c = CVD(b$): d = CVD(d$)
Print c, d
Color 4
Print b$, d$
Color 7

Print
Print
Print "As you can see, CVD gives much different results when used with a SINGLE        variable type, as with a DOUBLE variable type."
Print
Print "Make certain you use it with DOUBLE variable types, and your issue will go away."


MKD$ produces vastly different strings when passed a SINGLE value and when passed a DOUBLE value.  If you're going to make doubles into a string, be certain it pass it double type variables to begin with.  (Or else use MKS$ to make SINGLE types into a string.)


RE: CVSMBF, MKSMBF$, ETC. - arnoldhf - 07-18-2022

QB64 has two different encodings: MKD$, CVD and MKDMBF$, CVDMBF,

I tried them out on the same number and MKD$ is not the same as MKDMBF$.

When I wrote my programs, I think I had the default in QB set to MBF but the default in QB64 is IEEE so the MKDMBF$ etc. appears to be for backward compatibility with the QB /MBF option

Found this in WIKI:

"By the time QuickBASIC 4.00 was released,[when?] the IEEE 754 standard had become widely adopted—for example, it was incorporated into Intel's 387 coprocessor and every x86 processor from the 486 on. QuickBASIC versions 4.0 and 4.5 use IEEE 754 floating-point variables by default, but (at least in version 4.5) there is a command-line option /MBF for the IDE and the compiler that switches from IEEE to MBF floating-point numbers, to support earlier-written programs that rely on details of the MBF data formats. Visual Basic also uses the IEEE 754 format instead of MBF."

As always, Thanks for your time on this.

Arnold