Announcement

Collapse
No announcement yet.

Qbasic cvs problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Qbasic cvs problem

    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?

    #2
    Dan:

    May be the file uses the MS format for single precision values. Power Basic for DOS have a function (CVMS) to deal with that non-standard format, but PBCC doesn't. May be you can make an applet to process the files prior to use them with your new programm.

    Comment


      #3
      Have you tried reversing the input string? ie. Cvs(StrReverse$(InVal$))
      Scott Slater
      Summit Computer Networks, Inc.
      www.summitcn.com

      Comment


        #4
        Dan,
        I do not understand your problem as the CVS function will convert correctly all my QBASIC SINGLE random files ?
        All the other types also work perfectly.
        Can you show us some failing code ?
        Old QB45 Programmer

        Comment


          #5
          This will work. Try creating a small QB program that creates a file with some data and a PB program that reads this file. If it does not work, then please post the code here and we will see what is wrong.
          Sincerely,

          Steve Rossell
          PowerBASIC Staff

          Comment


            #6
            Maybe this help!
            Attached Files
            "The trouble with quotes on the Internet is that you can never know if they are genuine." - Abraham Lincoln.

            Comment


              #7
              Actually, QBasic uses the IEEE format, same as PowerBASIC. There's no need to try to convert to/from the old MBF.

              Bob Zale

              Comment


                #8
                Actually, QBasic uses the IEEE format, same as PowerBASIC. There's no need to try to convert to/from the old MBF.
                Unless..... the term "qbasic" here has been (mis-)used and it should have have been "QuickBasic."

                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.

                MCM
                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment


                  #9
                  Steve Rossell, Bob Zale, Michael Mattias......... God, what am I doing here!

                  I think we should wait for a word from Dan.

                  May be. Just may be, he is dealing with "legacy" files produced by a very old QuickBasic program, using MBF.

                  Comment


                    #10
                    QuickBasic was IEEE by default.
                    You had to use the /MBF option when starting the compiler in order to convert to MBF mode
                    Old QB45 Programmer

                    Comment


                      #11
                      >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


                        #12
                        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


                          #13
                          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
                          .. is in your code and the DLL is available to the EXE.
                          Michael Mattias
                          Tal Systems (retired)
                          Port Washington WI USA
                          [email protected]
                          http://www.talsystems.com

                          Comment


                            #14
                            > 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


                              #15
                              >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.

                              MCM
                              Michael Mattias
                              Tal Systems (retired)
                              Port Washington WI USA
                              [email protected]
                              http://www.talsystems.com

                              Comment


                                #16
                                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


                                  #17
                                  I often sit with not a heck of a lot to do
                                  Now we know the real reason for those 22k post from MCM
                                  Old QB45 Programmer

                                  Comment


                                    #18
                                    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)
                                    If I change the "x as string" to "x as field" in declares it compiles but I receive a gpf.
                                    "The trouble with quotes on the Internet is that you can never know if they are genuine." - Abraham Lincoln.

                                    Comment


                                      #19
                                      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


                                        #20
                                        Solved

                                        Thanks for all the responses, we have a solution. The only additional change is that a FIELD is not exactly the string the function was expecting. We had to change the field to a string then use the CVMS function on the string. It works great!

                                        Comment

                                        Working...
                                        X
                                        😀
                                        🥰
                                        🤢
                                        😎
                                        😡
                                        👍
                                        👎