Announcement

Collapse
No announcement yet.

Units ?

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

  • Units ?

    My once simple code is starting to acquire a life of its own.
    At around 5k lines there is no more room to run the PB3.5 Editor
    and the code; I get an "out of memory" error. Can I complie what
    I have done so far, as a Unit or Chain file, to reduce the overall
    size? I do not have any documentation on why/how this could be
    done. My attempts so far have produced numerous compile-time
    errors. Any ideas on how I can make this work without doing a
    .EXE compile after every code revision? My programmming experience
    is between "drools while coding" and "OOP God" (middle of the road).

    Thank You in advance.
    Steve Andrues

  • #2
    Units are blocks of precompiled code, and they get linked in during the compile process. Essentially, this means that using UNIT files does not reduce the amount of memory needed to run your application.

    However, if you can reduce the amount of memory thet your app needs to run, say for arrays, etc, then you may be able to continue coding in the IDE for a while more.

    For example, in some of my apps, I am using several arrays of 10000 subscripts, but in order to debug the code I can get away with using much smaller arrays, say 500 subscripts. I use compiler-directives to determine how big the arrays should be, for example:
    Code:
    %DEBUG = -1
    ...
    $IF %DEBUG
      DIM STATIC Arr1&(500), Arr2&(500)
    $ELSE
      DIM STATIC Arr1&(10000), Arr2&(10000)
    $ENDIF
    Also, you could make your numeric arrays to VIRTUAL arrays to free conventional memory... using the above technique, you could do this just for the "debug" version of your code.

    Also, I use this technique to exclude code that I do not need to test. FOr example, I may have a large block of code that handles report creation and printing, so I exclude that code the same way:
    Code:
    $IF NOT %DEBUG
      ... large block of debugged/working code
    $ENDIF
    Now, when I want to compile an EXE, I simply edit %DEBUG = 0 and compile to EXE.

    Finally, if you can maximize conventional memory, you may be able to squeeze a few more bytes for the IDE. Which O/S and version are you using?

    Failing that, you will be faced with the choice of either using PBD.EXE to debug the full code (and/or run it as a standalone EXE), or break the code into separate files (ie, one EXE and one or more PBC {chain} files).



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

    Comment


    • #3
      I have had this problem for years in QBX. What I do is break the
      code into modules which are roughly self-contained, eg. a Main
      module, an Edit module, and a Report module.
      Then create dummy modules for Edit & Report. You then create
      blank subs in the dummy modules.
      This unfortunately means that you cannot work on all of it at
      once, but allows much larger .EXE's to be produced.
      Also, you cannot compile & link inside the environment, so
      require batch & linker response files.
      That's assuming you can do this in PBDOS

      DJW


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

      Comment


      • #4
        My operating system is DOS 6.22. I have already made my arrays VIRTUAL user-defined type.
        The arrays are dynamicaly created depending on the size of the file being opened.
        The nature of the program already has it naturally divided into about six sections. Could these be compiled and CALL'ed (another feature I have never tried)?
        What are Chains and how do they differ from Units?

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

        Comment


        • #5
          A CHAIN (PBC) file is a stand-alone compiled module, like an EXE, but without a run-time library included.

          When you CHAIN to a PBU file (ie, from an EXE or another PBC), the runtime library remains in memory (along with any COMMON variables), and the nnew executable code is loaded and executed.

          A more complete description aand explanation can be found in the documentation...


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

          Comment


          • #6
            This may be a use for my Batch-file-calling-Executable-Which-writes-batch file-that-runs-original-batch-file technique that I mentioned in an earlier posting.

            If you want further enlightenment on this curious technique, email [email protected]

            DJW

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

            Comment


            • #7
              [QUOTE]Originally posted by Steve Andrues:
              [B]My once simple code is starting to acquire a life of its own.
              At around 5k lines there is no more room to run the PB3.5 Editor
              and the code; I get an "out of memory" error. Can I complie what
              I have done so far, as a Unit or Chain file, to reduce the overall
              size? I do not have any documentation on why/how this could be
              done. My attempts so far have produced numerous compile-time
              errors. Any ideas on how I can make this work without doing a
              .EXE compile after every code revision? My programmming experience
              is between "drools while coding" and "OOP God" (middle of the road).

              what I have done to get larger code to compile in the ide is make all
              all arrays virtual to test the code then when im ready I return them
              to real mode and command line compile them.
              That might work for you, it might not.

              Andrew



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

              Comment

              Working...
              X