I am converting a qbasic application to powerbasic and have a problem with the data in random access files. Quite a few fields are stored as packed 4 byte single with MKS. When read by powerbasic with CVS it dosen't return the correct value. I've tried every combination to unpack ie CVL, CVS, CVQ, even CVE but don't get the right value. The 2 byte convert fine. Does anyone know if there is something else I need to do?
Announcement
Collapse
No announcement yet.
Qbasic cvs problem
Collapse
X
-
Actually, QBasic uses the IEEE format, same as PowerBASIC. There's no need to try to convert to/from the old MBF.
QuickBasic DID use MBF, athough there was (is?) a command-line compiler override to use IEEE instead. Or maybe it was IEEE by default, with override to MBF... I know it's one of those because I had to use it.
MCMMichael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
-
-
>what am I doing here!
Mining for Old Farts and hitting a rich vein?Michael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
-
-
QuickBasic
Sorry for the misunderstanding, this app was written in MS Quick Basic. The compiler batch file is:
BC %1,,, /MBF/W/Fs/D/E/Es/AH
LINK /E %1
We are using the FIELD statement as is and all the data except the "4P (4 Byte packed)" fields are read fine. Here is an example, the variable is "S14" With the QuickBasic code "S14 = CVS(S14$)" returns 112
With PowerBasic I read the file and printed the contents of S14 raw, then with each CV* function. The last one (ABC) is with the assembler code that was posted yesterday.
S14: `ç
S14-Integer: 0
S14-Long: 2271215616
S14-Single: -1.685189E-34
S14-Extend: 0
S14-Double: 1.12212961016376E-314
S14-Double Word: 2271215616
S14-LONG: -2023751680
ABC: 0
Comment
-
-
Given what current program is doing and how it's compiled, the MBF functions in that ZIP file attached to post #6 should handle your problem promptly.
Instead of "CVS(field variable)" you'll have to use "CVMS (field variable)" in your code, making sure the DECLARE..
Code:DECLARE FUNCTION CVMS LIB "MSBF.DLL" (x AS STRING) AS SINGLE
Michael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
-
-
> Instead of "CVS(field variable)" you'll have to use "CVMS (field variable)" in your code, making sure the DECLARE..
Must be a "string variable" here ... or a compilation error occurs using CC5!"The trouble with quotes on the Internet is that you can never know if they are genuine." - Abraham Lincoln.
Comment
-
-
>Must be a "string variable" here
Forgot... there now is a type FIELD variable.
I got my printed manual about a week ago. I took it out of the mailing envelope, but it's still in the shrink wrap. I got that because just surfing through a manual, you can find all the new and improved stuff a lot easier than trying to divine it from the help file.
Rumor has it there is lots of new stuff since my last printed manual... PB/DLL version 2.0
(The "new" I can usually remember, but the "Improved!" go right past me).
Guess I'll have to break that open and put it somewhere I often sit with not a heck of lot else to do except read.
MCMMichael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
-
-
Of course if you still have QuickBasic they have the conversion functions as standard ie CVSMBF and CVDMBF so you should be able to write a converter. They were still there in my copies of QB4.5 and BC7.1, can't quickly find my Windows for DOS 1 but think they were in that as well. Default mode for all the was IEEE.
Comment
-
-
Code:#COMPILE EXE #DIM ALL ' PowerBASIC declarations for MSBF.DLL functions DECLARE FUNCTION CVMS LIB "MSBF.DLL" (x AS STRING) AS SINGLE DECLARE FUNCTION MKMS LIB "MSBF.DLL" (BYVAL s AS SINGLE) AS STRING DECLARE FUNCTION CVMD LIB "MSBF.DLL" (x AS STRING) AS DOUBLE DECLARE FUNCTION MKMD LIB "MSBF.DLL" (BYVAL d AS DOUBLE) AS STRING FUNCTION PBMAIN () AS LONG LOCAL s,d AS FIELD 'local a as single 'local b as double OPEN "gwbf.bin" FOR RANDOM AS #1 LEN=12 FIELD #1, 4 AS s, 8 AS d GET #1,1 'FIELD STRING s,d 'CLOSE #1 PRINT CVMS(s); CVMD(d) WAITKEY$ CLOSE #1 END FUNCTION PowerBASIC Console Compiler PB/CC Version 5.01 Copyright (c) 1998-2009 PowerBasic Inc. Venice, Florida USA All Rights Reserved Error 480 in F:\PBCC50\Cvrtgwbf.bas(21:017): Parameter mismatches definition Line 21: PRINT CVMS(s); CVMD(d)
"The trouble with quotes on the Internet is that you can never know if they are genuine." - Abraham Lincoln.
Comment
-
-
The CVMS and CVMD functions hould be declared with param "AS STRING."
I only used the word FIELD because you had FIELDed a buffer in you code... I FORGOT there is now a "FIELD" data type in PB and I should never have used that (now magic) word in this post.
As far as the GPF... if you don't have data that might be the problem. ie., file 'gwbf.bin' not found, and was created empty, meaning you would be passing garbage to the CVMS function.Michael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
-
Comment