Announcement

Collapse
No announcement yet.

conversion from QuickBasic to PBCC

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

  • conversion from QuickBasic to PBCC

    Hello. I have a legacy QBasic application that I want to convert to PBCC

    I Have three question for anyone out there that has experince in this:
    1. I am using BTRIEVE (7.9 Version PSQL 2000i). I have set up INCLUDEs to read specific files. Below is part of the INCLUDE that reads File 5.

    How would you handle a FIELD statement PBCC?

    How would you code the DECLARE for WBTRV32.DLL?

    The third question has to do with PRINT USING. I Use that a lot. Do I have convert all my numeric prints to strings to print in PBCC.

    Thanks for the Help.

    5001 ' SAVE"C:F5PROD.INC",
    5003 '* 5000-5099 ** 10/27/2008 ** Subroutine to open PRODUCTION ORDER FILE #5.*
    5005 ' DIM F5KLEN%(7),F5TYPE$(7),F5DUP$(7),F5KEYS$(7)
    F5NAME$ = "PRODORDR.DAT " '<====== NOTE file name here ==============
    B5LRECL% = 128 '<====== NOTE Logical Record Length here ==
    5009 'Keylen,Typ,Dup,Field Name
    5011 DATA 07,"D"," ","Production Order No."
    DATA 06,"U","D","Production Ordr Date"
    DATA 12,"U","D","Production Ordr Item"
    DATA 18,"U"," ","PO Date / Item No. "
    DATA 06,"U","D","PO Complete Date "
    DATA 18,"U"," ","PO Comp Date/Item No"
    DATA 00,"C"," ","KEY6"
    DATA 00,"C"," ","KEY7"
    5029 RESTORE 5011
    FOR I = 0 TO 7: READ F5KLEN%(I),F5TYPE$(I),F5DUP$(I),F5KEYS$(I): NEXT I
    OPEN "NUL" AS #5 LEN=B5LRECL% 'BASIC open; Set BTRIEVE Pos Block Area.
    FIELD #5, B5LRECL% AS F5REC1$ ' <======== Note FIELD statement.
    B5POS$ = SPACE$(128)
    B5KEYNUM% = 0: F5KEYL% = F5KLEN%(B5KEYNUM%) 'File 5 key length.
    B5KEY$ = F5NAME$: B5STATUS% = 0: B5LOCK$ = "N": B5LOCKF$ = "N": B5OPCODE%=BOPEN%: GOSUB 5100 'Go BTRIEVE open the file.
    IF B5STATUS% = 0 THEN 5065 'ERROR occurred if Status <> 0
    DBNAME$ = F5NAME$: BSTATUS% = B5STATUS%: BOPCODE% = B5OPCODE%: BKEY$ = B5KEY$: GOSUB 700
    5065 B5KEY$ = SPACE$(F5KEYL%) 'Init key field to blanks.
    5099 RETURN
    5100 '* 5100-5299 ** Subroutine to perform BTRIEVE I/O for file #5. **********
    IF B5LOCK$ = "Y" THEN B5OP% = B5OPCODE% + BLOCKWN%: B5LOCKF$ = "Y": B5LOCK$ = "N" ELSE B5OP% = B5OPCODE%
    IF B5OPCODE%=BINSERT% OR B5OPCODE%=BUPDATE% THEN GOSUB 5400
    B5FCBPTR% = VARPTR(#5)
    CALL BTRV(B5OP%,B5STATUS%,B5POS$,B5FCBPTR%,B5LRECL%,B5KEY$,B5KEYNUM%)
    IF DEBUG$ <> "D" THEN 5120
    LOCATE 23,1,0: PRINT USING "File 5 I/O - Op=## Lock=! Stat=## Keyl=## Key=\ \ Keynm=#";B5OPCODE%;B5LOCKF$;B5STATUS%;LEN(B5KEY$);B5KEY$;B5KEYNUM%;
    MSG$ = " Press ENTER to continue.": IBUFF$="Y": GOSUB 200: LOCATE 23,1,0: PRINT SPACE$(79);
    5120 DBNAME$ = F5NAME$: BSTATUS% = B5STATUS%: BOPCODE% = B5OPCODE%: BKEY$ = B5KEY$
    IF B5STATUS% <> 0 THEN 5170
    IF B5OPCODE%>4 AND B5OPCODE%<14 THEN GOSUB 5300 'Get data into local variables.
    5170 IF B5OPCODE% < 5 THEN B5LOCKF$ = "N"
    5199 RETURN

  • #2
    This forum thread may help you. Also, lookup FIELD, and USING$ in the online PBCC 5 Manual.

    Comment


    • #3
      Hi John. Thanks for the reply. I was looking at the language comparisons and did not see FIELD, but shown as a PBCC command. I see it now in the Manual. Also USING$, so that helps.

      Does PBCC have an alternative to the CHAIN comand? to link from one BASIC Program to another?

      Comment


      • #4
        Roy,
        there's no need to CHAIN as there's so much memory available in a modern PC that you can rewrite all the old programs as functions in a single big program.
        But if you really prefer then you could use SHELL instead of Chain (although variables won't be preserved).

        Paul.

        Comment


        • #5
          >How would you handle a FIELD statement PBCC?

          FIELD

          >How would you code the DECLARE for WBTRV32.DLL?

          Should be available with your doc for the function, or at some btrieve support site, or here somewhere, search on "WBTRV32.DLL." I know there are Btrieve'ers here .

          > The third question has to do with PRINT USING....

          The USING$ function is pretty close. But yes, you WILL have to convert them all.

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

          Comment


          • #6
            Field

            Roy,

            Instead of using RANDOM ACCESS why not use the BINARY mode from now on ?
            You will find it a lot less work and far more elegant way of reading and writing your old files.
            No more LSET command.
            You will never regret accessing your files that way.
            Last edited by Guy Dombrowski; 14 Nov 2008, 09:54 PM.
            Old QB45 Programmer

            Comment


            • #7
              or ACCESS RANDOM with UDTs instead of a FIELDed buffer?
              Michael Mattias
              Tal Systems Inc. (retired)
              Racine WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                Originally posted by Paul Dixon View Post
                Roy,
                there's no need to CHAIN as there's so much memory available in a modern PC that you can rewrite all the old programs as functions in a single big program.
                But if you really prefer then you could use SHELL instead of Chain (although variables won't be preserved).

                Paul.
                There are however limits for the compiler buffer so that your PBMAIN is limited in size. IIRC its now a 469 error if your PBMAIN overflows the compiler buffer.

                As I understand it subs outside of PBMAIN can be any size.

                When I found it it did not generate an error code just many varied strange problems.

                If you use shell just write a file of the variables you wish to transfer and read it in at the start of the shelled program.

                Loren

                Comment


                • #9
                  I'm afraid that's a very incorrect inference. The correct description is that a single SUB or FUNCTION is limited to approximately 12,000 lines of source code. That's an incredibly large function which would be impossible for a programmer to maintain effectively. Even if this limit is somehow reached, an appropriate warning error is generated. This limit has absolutely no effect on total program size.

                  Bob Zale
                  PowerBASIC Inc.

                  Comment


                  • #10
                    Code:
                    5001 ' SAVE"C:F5PROD.INC",
                    5003 '* 5000-5099 ** 10/27/2008 ** Subroutine to open PRODUCTION ORDER FILE #5.*
                    5005 ' DIM F5KLEN%(7),F5TYPE$(7),F5DUP$(7),F5KEYS$(7)
                    F5NAME$ = "PRODORDR.DAT " '<====== NOTE file name here ==============
                    B5LRECL% = 128 '<====== NOTE Logical Record Length here ==
                    5009 'Keylen,Typ,Dup,Field Name
                    ...
                    I thought it might be easier to follow were it formatted using Code Tags

                    I was wrong.

                    I do not envy Mr. Bauer his conversion task.
                    Michael Mattias
                    Tal Systems Inc. (retired)
                    Racine WI USA
                    [email protected]
                    http://www.talsystems.com

                    Comment


                    • #11
                      Coding limit

                      Bob,

                      I know that I will never go over the 12,000 lines limit but I have a question about the line composition.
                      I tend to put many instructions in each line because I work with twin 24" display and you get to see the big picture.

                      Code:
                      WHILE Z$="":  CODE: CODE: CODE: WEND
                      Would that count for one line of code ?

                      Thanks
                      Old QB45 Programmer

                      Comment


                      • #12
                        QB conversion

                        Roy,

                        As somebody who has many old programs written with QB45 and tried to save time by converting the old stuff here is my advice : DO NOT TRY IT !
                        Far better to start from scratch.
                        In the end, you will save time and end up with a far better program by using PBCC powerful Commands that do not exist in QBasic.

                        Good luck
                        Old QB45 Programmer

                        Comment


                        • #13
                          >Would that count for one line of code ?

                          Moot.

                          Given the documented 256-character limit per physical line, even if each statement contained therein counts against your 12,000 limit, you should rewrite this procedure.
                          Michael Mattias
                          Tal Systems Inc. (retired)
                          Racine WI USA
                          [email protected]
                          http://www.talsystems.com

                          Comment


                          • #14
                            Originally posted by Guy Dombrowski View Post
                            Far better to start from scratch.
                            Providing that you have the time to write the new system, are a master of controlling scope creep, have an excellent grasp of PBCC and can adapt your meticulously maintained condition lists and test plans to the new system, then go for it!

                            Heh. That was just my MCM impression - forgive me.

                            Comment


                            • #15
                              No forgiveness required.

                              I'd like a nickel for every time I've posted that software source code has a "shelf life"... after which modifying it to do something new -and running under Windows instead of MS-DOS would certainly seem to meet the definition of "something new" - is going to cost more than will just rewriting the software from scratch to support all the current requirements.
                              Michael Mattias
                              Tal Systems Inc. (retired)
                              Racine WI USA
                              [email protected]
                              http://www.talsystems.com

                              Comment


                              • #16
                                I have to disagree with Guy unless the program(s) to be converted contains graphics. If it's a text program (line/box drawing characters allowed), it's usually easy to globally change things that are different. Save the QB program
                                as text and use edit. Put in PBMAIN, change common to global. In my opinion it's quicker than rewriting the program.
                                Client Writeup for the CPA

                                buffs.proboards2.com

                                Links Page

                                Comment


                                • #17
                                  It depends to a certain degree upon the program style. However, I personally converted several million lines of QB source code to PBCC very successfully. In use by a major U.S. bank. Don't give up too easily.

                                  Bob Zale
                                  PowerBASIC Inc.

                                  Comment


                                  • #18
                                    I will hazard a guess that for "several millions" of lines of source code there are certain economies of scale not found in a 2500-line program.
                                    Michael Mattias
                                    Tal Systems Inc. (retired)
                                    Racine WI USA
                                    [email protected]
                                    http://www.talsystems.com

                                    Comment

                                    Working...
                                    X