building own library with include-files?


Closed Thread
Results 1 to 26 of 26

Hybrid View

  1. #1
    Join Date
    Jan 2005
    Location
    Boston MA
    Posts
    19


    Did you find this post helpful? Yes | No

    Thumbs up

    Good to see this topic I thought I would add my 2cnts.

    Start with the hardware layer use my (your) standard names: LABX1_20
    Add chip layer ie DS1302, DS1620, one-wire: CLOCK1302
    Add util layer ie save_word_to_eeprom, get_last_temp_change: UTIL

    I also save these files in a include dir, so many projects can have access.
    Include "..\include\LABx1_20.inc"

    Since variables that need to be shared are shandard and internal variables are hidden like "__temp" then the actual project code is faster to code

    I am trying to make object programming without the objects.

    As you can see from my examples I break my own rules just to get the job done in time.

    Regards
    Tim
    Attached Files Attached Files
    Last edited by timc; - 19th September 2005 at 03:01.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Excellent! Somebody else is on the "Same Page".

    Are you interested in a few improvements?

    While it's nice to have all the routines available by simply Including a file, with 100% PBP statements in them, even the routines that you don't use, still take up code space. It limits the amount of routines you can have available, because it uses up all the space you want for the actual program.

    By using "Self-Optimizing" macro's, you could have hundreds of routines in place and ready to go. But, only the ones you use in your program will actually take up Code space.

    It would mean a lot of editing, but I think you'd find it worthwhile. And, it's much closer to those "Objects" you're looking for.
    <br>
    DT

  3. #3
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Darrell,

    Darrell>My mission now is to get everyone to use includes and macro's.
    I'm done with the "Blinky lights" and "why doesn't my program work" stuff. <<

    In C/C++ we call this "OOP's" Object Oriented Programming. It is extremely nice, because once your "Include" is running (rountine or whatever you want to call it)... you can almost COUNT on that rountine to work nomatter what. You can forget about it. Call it up as a "Subroutine" to a degree, and know the response you received from your "routine" will be accurate and working.

    One of the biggest disadvantages of Basic, (or PBP) is that the variables are "Global". Care must be taken to keep track of all variables within your program. C/C++ has what they call "Local" variables. These variables are ONLY recognized within their own subroutine or "object".

    I, myself, prefer subroutine and/or (what you call Include files) to my preferred method of programming. I have not "played" with the Include statements yet, and my own Psuedo Libraries of code. But someday I will have time to sit down and start putting together my own...

    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hiya Dwayne,

    Many years ago, I chose Pascal. I now wish I had chosen C instead. Would have been making much better money by now. But, pascal or Delphi, is also an OOP environment. All that Inheritance and Polymorphism stuff was so confusing, for so long. Didn't think I'd ever get a handle on it. But eventually it did make sense.

    Fortunately, OOP will never be a part of PBP. I can just image the posts on here if it was.

    As for the PBP variables, yes, they are all global. But, it's not mandatory that they are all assigned their locations by PBP. It's possible to create "Placeholders" for PBP variables. That way PBP can go ahead and compile the program, even though it doesn't know where the variables will be, and then the actual locations can be determined at the assembly level, by your code. Any variables that aren't used in the program, don't need to be assigned a location since there's no code that will be trying to use them.

    It's not quite "Local Variables", but it does help when making code that may, or may not be used in any given program. So, much like the "Self-Optimizing" macro's, the variables are optimized by the routine that might be using them.
    <br>
    DT

  5. #5
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Darrel,

    D>>Many years ago, I chose Pascal. I now wish I had chosen C instead. Would have been making much better money by now. But, pascal or Delphi, is also an OOP environment. All that Inheritance and Polymorphism stuff was so confusing, for so long. Didn't think I'd ever get a handle on it. But eventually it did make sense.<<

    Yes, Delphi and Pascal both have OOP environment...Borland compilers (The Builder Series) allow Delphi coding to be integrated. I do not like Delphi, because it is not as powerful as C/C++. But delphi has LOTS of PROTECTION from programming errors. This makes it so that messy and weaker programmers can make a mistake, and have their errors caught. In C/C++, you can overwrite your own program if you are not careful. You can overstep your variable bounds, overwrite memory, or any number of different things. This CAN be a advantage if used properly...<g>.

    Darrel>>As for the PBP variables, yes, they are all global. But, it's not mandatory that they are all assigned their locations by PBP. It's possible to create "Placeholders" for PBP variables.<<

    My knowledge on PBP is not this great. I use it to get a job done...and let the compiler take care of it for me. Off the top of my head, I can only think of something like "Orging" to a position of the program on startup. And those variables would be the first few locations of the program.

    could you give a example please Darrel? I think folks could benefit from this...Or should I say *I* (at least!) could benefit from this.


    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Dwayne,

    I'm sure I can come up with something for an example.

    But first, I'm preparing another program for the Code Examples forum that is somewhat similar. Except that it assigns variables to EEPROM instead of RAM.

    It uses some of the same concepts, yet is very different from doing it in RAM.

    I should have it posted in a day or two.
    <br>
    DT

  7. #7
    Join Date
    Jan 2005
    Posts
    72


    Did you find this post helpful? Yes | No

    Default start at the basics

    interesting all you write about this theme.

    for me as a beginner there are still some questions ...

    what is exactly the definition of a macro and an include? what are the advantages as well the disadvantages from each?

    what are the restrictions and syntax definitions to build up them? i. e. global /local variables, underscore, ...

    so when i can find this descriptions by myself anywhere, please tell me where.
    otherwise i'm happy for a short explanation. thanks a lot

Similar Threads

  1. Continuous Interrupts when using DT_INTS and an INCLUDE file
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 15th January 2010, 21:42
  2. Can't seem to add AllDigital to the include files
    By ozarkshermit in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 12th November 2009, 04:21
  3. Missing 16F882 family include files :-(
    By campmdabt in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 27th December 2007, 01:17
  4. include files 8k limit
    By skimask in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th January 2006, 06:35
  5. Replies: 2
    Last Post: - 13th December 2005, 00:11

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts