Announcement

Collapse
No announcement yet.

Turbo to Power

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

  • Turbo to Power

    I've been using Turbo BASIC since it came out (in 1986 I think) but am now experimenting with its successor, Power BASIC for DOS 3.5.
    Most of my programs have transferred fine, except for a few which use newly reserved words, but there seems to be a major difference in the handling of *PBC files (*.TBC in Turbo BASIC) in that they cannot be called from within another *.PBC program. Is this true? Or have I misunderstood something? Certainly my programs fail with the error message: "error 53 at pgm 1060"

    Any other old Turbo users out there who have faced this problem - if that is what it is!

    Cheers

    Mike



    ------------------

  • #2
    Your description is kind of sparce. You can call .PBC files from
    anywhere from within the program. Maybe you could post a small
    example.

    One thought: Have you PUBLIC'ed all you SUB's and FUNCTION's
    in the .PBC file? You need to make them public if you want one
    program segment to see the other.

    Example:

    Function DoSomething(x,y,z) public
    ..process
    ..process
    end function

    Sub DoSomethingElse(a,b,c) public
    ..process
    ..process
    end sub

    Hope this helps
    Cheers


    ------------------
    There are no atheists in a fox hole or the morning of a math test.
    If my flag offends you, I'll help you pack.

    Comment


    • #3
      Mel, that would be more likely to affect UNIT (.PBU) files rather than CHAIN (.PBC) files, I would suspect.

      Mike, .PBC files can certainly CHAIN to other .PBC files. Of course, you cannot CHAIN to a TBC file though... the runtime library requirements are incompatible.

      An error 53 suggests the CHAIN is not able to locate the target PBU file - one possible cause could be if the current directory (CURDIR$) is the same as where the target .PBU file is located on disk.

      Beyond this, we'd really need to know more about the situation when the CHAIN statement fails...

      ------------------
      Lance
      PowerBASIC Support
      mailto:[email protected][email protected]</A>
      Lance
      mailto:[email protected]

      Comment


      • #4
        Thanks for the speedy reply. I have an *.EXE file that calls a *.PBC file like this:

        RUN "nextbit.pbc"

        This works fine; but "nextbit.pbc" has a SELECT CASE statement that goes to several lines like:

        CASE 2
        RUN "line.pbc"

        and so on.

        This works fine in Turbo BASIC but fails in Power BASIC. If you are correct in saying that this is legal (contrary to my reading of the manual) then the ERROR 53 must mean that the program cannot find "line.pbc"; in which case I might have to put a specific path into the line. In Turbo BASIC it defaults to the directory from which the program is running. I've just had a thought - perhaps I have not correctly set up the "where the files are kept" bit in the user interface. But this should not affect a compiled program, surely?
        Thanks for your thoughts,

        Cheers

        Mike




        ------------------

        Comment


        • #5
          Lance, that was just a thought. Now that I'm on the right track,
          I can see two possibilities:

          CASE 2: If you have your variable declarations in the main .EXE
          file, you need to COMMON them in all the .PBC files that you
          plan to use them in.

          RUN "line.pbc":
          Pretty sure this needs to be changed to CHAIN "LINE.PBC"



          ------------------
          There are no atheists in a fox hole or the morning of a math test.
          If my flag offends you, I'll help you pack.

          Comment


          • #6
            Mike --

            From the PB/DOS docs:


            Run

            filespec is a string expression representing a PowerBASIC chain (.PBC) or .EXE file (created by PowerBASIC). The RUN filespec operation can only be performed from an .EXE file.


            You should use CHAIN, not RUN.

            -- Eric


            ------------------
            Perfect Sync Development Tools
            Perfect Sync Web Site
            Contact Us: mailto:[email protected][email protected]</A>

            [This message has been edited by Eric Pearson (edited March 29, 2002).]
            "Not my circus, not my monkeys."

            Comment


            • #7
              I think you need to use CHAIN instead of RUN. My recollection
              is that RUN and EXECUTE are expecting .EXE and CHAIN
              is expecting .PBC extension. As far as the directory is
              concerned, you shouldn't need to put the whole path in
              if your .PBC's sit in the same directory.

              Craig

              ------------------
              Craig J. Slane
              Nostalga Sim Baseball

              Comment


              • #8
                Thanks to all of you - you all agreed that I should use CHAIN instead of RUN. I tried it, but it came up with the same error.

                The set of programs is a simple stats package with an introductory program and a menu program that runs your choice. Almost certainly I should re-write the whole thing as one program with several modules, but that's not the way it's happened - you all know the scenario!

                The intro program is an *.EXE file which tells the user about the suite of programs; it ends with:

                RUN "menu.pbc"

                This works in Turbo and Power BASIC

                The program MENU.PBC has a choice section which is followed by:

                SELECT CASE
                CASE 1
                RUN "first.pbc"
                CASE 2
                RUN "second.pbc"
                and so on, until
                CASE 13
                EXIT SELECT
                END SELECT

                and ends with

                SYSTEM

                This works.

                The program FIRST.PBC runs the stats test and ends with:

                INPUT"Do you want another go (Y/N)";b$
                IF b$="Y" OR b$="y" THEN RUN ELSE RUN "menu.pbc"

                All of this works fine in Turbo BASIC, but in Power BASIC that last line fails with an error 53. I might add that each program is self contained and that none of the variables are common.

                As I said, I've tried replacing the RUNs with CHAINs but get the same error. In most other respects PowerBasic is a direct development of TurboBasic in that it just adds new capabilities, but this does seem to be a genuine difference in the way they work.

                Perhaps this is the spur to get me to re-write the whole thing as a single program! But up to now I've taken the attitude that if it ain't bust why mend it.

                Thanks again for your help.

                Cheers

                Mike



                ------------------

                Comment


                • #9

                  Mike,

                  Don't you need a string after RUN?


                  IF b$="Y" OR b$="y" THEN RUN "what?" ELSE RUN "menu.pbc"


                  ------------------

                  Comment


                  • #10
                    I vaguely remember similar problems when I changed from TurboBasic to
                    PowerBasic.

                    I eventually adopted the method of creating multiple EXEs which can
                    be EXECUTED into (new in PB-DOS), are easier to program and debug,
                    smaller memory footprints and if need be, can be run stand-alone.

                    In your case, I would compile the PBCs as EXEs and use the SELECT CASE
                    in each. SELECT to EXECUTE another EXE of your choice or simple END to
                    get back to the System, after clearing the screen

                    ------------------

                    Comment


                    • #11
                      Mike --

                      I promise you, the PB/DOS CHAIN system works properly. But as the docs clearly state, you must use CHAIN not RUN. This is a documented difference between TurboBASIC and PowerBASIC, and you must make this change when converting a TB program to PB. You may have other problems that are causing the CHAIN to fail, but sticking with RUN is not the answer.

                      I have a large PB/DOS program that has been used for well over a decade at hundreds of sites, and it is designed the way you describe. An EXE chains to a PBC, which then chains to another PBC, and so on. The program often runs for weeks at a time, with literally thousands of CHAINs, and zero reported problems.

                      -- Eric


                      ------------------
                      Perfect Sync Development Tools
                      Perfect Sync Web Site
                      Contact Us: mailto:[email protected][email protected]</A>

                      [This message has been edited by Eric Pearson (edited March 30, 2002).]
                      "Not my circus, not my monkeys."

                      Comment


                      • #12
                        This might sound simple, but have you tried specifying the
                        absolute path to the file you are running? I wrote a few test
                        programs using the method you described, but was unable to
                        reproduce the problem unless I deleted the chain file and moved
                        it to a different location.

                        After specifying the relative or absolute path of where I moved
                        it, the problm was fixed.

                        ----------------------------------------------------------

                        If you still have a yearning to create your program in one big file,
                        try replacing RUN "foo.pbc" with $include "foo.bas"

                        That will usually compile with just a few minor modifications...
                        Or better yet, turn all of your chain files into SUBs, include
                        them at the top, and call them at will....

                        ------------------
                        Amos
                        mailto:[email protected][email protected]</A>

                        Comment


                        • #13
                          Some of you really want to make programming difficult for yourselves

                          I created 2 versions of doing things. The second is my way !

                          The first is CHAINING to 5 PBCs from the CHAIN.EXE, containing the CHAIN
                          to the next PBC command only. The last PBC has a SHELL only to test the effect
                          in Memory.

                          The second does the same, but this time EXECUTEs.

                          The results shown below should be self-explanatory. No messing making sure that
                          there are matching COMMON in all modules, freedom to modify individual modules
                          at leisure without having to worry about the effects in others, etc.

                          Code:
                          <U>CHAINING</U>
                          CHAIN    BAS            20  30/03/02  23:56
                          CHAIN    EXE        76,800  30/03/02  23:56
                          CHAINA   BAS            18  30/03/02  23:57
                          CHAINA   PBC           496  30/03/02  23:59
                          CHAINB   BAS            18  30/03/02  23:58
                          CHAINB   PBC           496  31/03/02   0:00
                          CHAINC   BAS            18  30/03/02  23:58
                          CHAINC   PBC           496  31/03/02   0:00
                          CHAIND   BAS            18  31/03/02   0:00
                          CHAIND   PBC           496  31/03/02   0:01
                          CHAINE   BAS            12  31/03/02   0:01
                          CHAINE   PBC           496  31/03/02   0:01
                          
                          
                          Modules using memory below 1 MB:
                          Name           Total           Conventional       Upper Memory
                            --------  ----------------   ----------------   ----------------
                            SYSTEM      41,312   (40K)     15,008   (15K)     26,304   (26K)
                            HIMEM        1,168    (1K)      1,168    (1K)          0    (0K)
                            EMM386       4,320    (4K)      4,320    (4K)          0    (0K)
                            CHAIN      130,016  (127K)    130,016  (127K)          0    (0K)
                            SBEINIT      4,480    (4K)      4,480    (4K)          0    (0K)
                            COMMAND     10,768   (11K)         80    (0K)     10,688   (10K)
                            ANSI         4,320    (4K)          0    (0K)      4,320    (4K)
                            IFSHLP       2,864    (3K)          0    (0K)      2,864    (3K)
                            COMMAND     10,880   (11K)          0    (0K)     10,880   (11K)
                            KEYB         6,944    (7K)          0    (0K)      6,944    (7K)
                            Free       596,304  (582K)    500,000  (488K)     96,304   (94K)
                          
                          
                          <U>EXECUTING</U>
                          CHAIN    BAS            22  31/03/02   0:13
                          CHAIN    EXE        12,816  31/03/02   0:13
                          CHAINA   BAS            20  31/03/02   0:13
                          CHAINA   EXE        12,816  31/03/02   0:13
                          CHAINB   BAS            20  31/03/02   0:14
                          CHAINB   EXE        12,816  31/03/02   0:14
                          CHAINC   BAS            20  31/03/02   0:14
                          CHAINC   EXE        12,816  31/03/02   0:14
                          CHAIND   BAS            20  31/03/02   0:15
                          CHAIND   EXE        12,816  31/03/02   0:15
                          CHAINE   BAS            12  31/03/02   0:01
                          CHAINE   EXE        22,432  31/03/02   0:15
                          
                          
                          Modules using memory below 1 MB:
                            Name           Total           Conventional       Upper Memory
                            --------  ----------------   ----------------   ----------------
                            SYSTEM      41,312   (40K)     15,008   (15K)     26,304   (26K)
                            HIMEM        1,168    (1K)      1,168    (1K)          0    (0K)
                            EMM386       4,320    (4K)      4,320    (4K)          0    (0K)
                            CHAIN        1,088    (1K)      1,088    (1K)          0    (0K)
                            SBEINIT      4,480    (4K)      4,480    (4K)          0    (0K)
                            CHAINE      75,664   (74K)     75,664   (74K)          0    (0K)
                            COMMAND     10,768   (11K)         80    (0K)     10,688   (10K)
                            ANSI         4,320    (4K)          0    (0K)      4,320    (4K)
                            IFSHLP       2,864    (3K)          0    (0K)      2,864    (3K)
                            COMMAND     10,880   (11K)          0    (0K)     10,880   (11K)
                            KEYB         6,944    (7K)          0    (0K)      6,944    (7K)
                            COMMAND     10,688   (10K)          0    (0K)     10,688   (10K)
                            Free       638,880  (624K)    553,264  (540K)     85,616   (84K)

                          ------------------




                          [This message has been edited by OTTO WIPFEL (edited March 30, 2002).]

                          Comment


                          • #14
                            Otto --

                            > No messing making sure that there are matching COMMON
                            > in all modules, freedom to modify individual modules
                            > at leisure without having to worry about the effects
                            > in others, etc.

                            ...and no ability to share variables between modules, which is what CHAIN is intended to provide.

                            EXECUTE and SHELL have their uses, as does CHAIN.

                            -- Eric


                            ------------------
                            Perfect Sync Development Tools
                            Perfect Sync Web Site
                            Contact Us: mailto:[email protected][email protected]</A>
                            "Not my circus, not my monkeys."

                            Comment


                            • #15
                              Eric......

                              Yes, "Horses for Courses". I just can't help doing things as easy as possible,
                              Old Age you know

                              All my program modules are independent beings in their own right, getting Run Time
                              Data they need by means of external Parameter Files. Anything else they need you
                              would COMMON, they can get themselves from their own source code, so there

                              But getting back to the original question and remembering all sorts of limitations
                              in TurboBasic, PB-DOS up to 3.5 did away with, would Mike not be better of Compiling
                              the whole lot within one EXE, using $INCLUDE, $SEGMENT, etc wherever necessary ?

                              I can't see the code of his programm being that Huge to not fit into a PB-DOS 3.5 EXE ?
                              Anyting up to 350 Kb is acceptable for an EXE in all OSs ?



                              ------------------

                              Comment


                              • #16
                                Once again, thanks to all of you for the interesting and knowledgeable discussion of RUN and CHAIN. Jerry - RUN without parameters simply runs the current program.

                                It all seems to have been a bit of a storm in a teacup, as I've found the answer - and it's so stupidly simple that I feel a bit of an idiot. It was, as I mused in a previous contribution, simply that I had not set the "where to find the files" bit on the Options. The error 53 was genuine in that the program just couldn't find the *.PBC files. It all works perfectly now that I've put this right!

                                But I think we have all learned a bit about RUN and CHAIN and I guess most of you are suprised that RUN works in this context. I think that the key is that I'm not passing any values from one program to another, so chaining is not neccessary. What do you think?

                                Anyway, all is well now and I look forward to exploring more of Power BASIC. Thanks to you all.

                                Cheers

                                Mike



                                ------------------

                                Comment


                                • #17
                                  Oops, your right, I read right over that. First words on the line.
                                  I need to wash this foot more often.

                                  ------------------

                                  Comment

                                  Working...
                                  X