Shop OBEX P1 Docs P2 Docs Learn Events
Multi-File question — Parallax Forums

Multi-File question

ZeusZeus Posts: 79
edited 2012-11-07 23:48 in BASIC Stamp
Hello Everyone,

Does anyone out there know if it is possible to create a multi-file project, thereby taking advantage of larger capacity chips like a BS2sx, without having to create several separate/individual programs? I need the capacity of a larger stamp but for simplicities sake I am hesitant to break it out into several different programs.

Thanks,

Zeus

Comments

  • NWCCTVNWCCTV Posts: 3,629
    edited 2012-11-06 18:33
    The BS2SX is 2.5 times faster than a BS2 anything that has to do with math must be multiplied by 2.5. There is code that you can use at the begining of your program to do this for you. For the life of me I can not recall what it is called but I am sure someone else will chime in on this. You also must specify the BS2sx at the start of the program and it will be saved as a bsx file extension.
  • davejamesdavejames Posts: 4,047
    edited 2012-11-06 19:19
    Zeus wrote: »
    I need the capacity of a larger stamp but for simplicities sake I am hesitant to break it out into several different programs.

    Zeus - partitioning a multi-slot program is not much of a big deal. All one needs to keep in mind is that all slots require the same variable declarations, and at some point, operation must be passed off to another slot.

    Case in point...I'm currently working on a menu-driven project that is easily taking up 8K worth of memory. All I need to do is partition my individual sub-menu code into a separate BS2 memory slots. It's all one big program, but broken up into sub-sections (think function calls in C). As the user moves through the menus, different slots are run.

    Check this link for more info:

    http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol3/col/nv87.pdf


    Come on in, the water's fine! :cool:
  • ercoerco Posts: 20,256
    edited 2012-11-06 20:26
    And a BS2E is the same speed as a BS2, but with 8 slots for 16K total memory. BS2=$49, BS2E=$54: $5 well spent! 8X memory increase for 10% more price.
  • ZeusZeus Posts: 79
    edited 2012-11-07 14:38
    Dave,

    Thanks for the link, I came across this this other day but could not find it again.

    Maybe I am missing something but the following line indicates that the main program is referencing a second/separate program, no?

    {$STAMP BS2e, Thermo_LCD.BSE}

    Zeus
  • davejamesdavejames Posts: 4,047
    edited 2012-11-07 15:15
    ....errrrrrr....well, yes - sort of.

    Each slot's code does reside in a separate file. One of the first few lines in slot 0 (zero) describes/defines the other slot files so they auto-load into their respective memory slots when slot 0 (zero) is loaded.

    Does that present a problem?
  • ZeusZeus Posts: 79
    edited 2012-11-07 15:57
    Dave,

    Yes and no. Yes, in that I did not realize when I started this that it would grow so large that I would have to look at a larger stamp, given this I didn't exactly lay my program out such that it could easily be converted to a series of modular programs. No, in that it can be done with a multi-file structure. If it can't be written as one large file then so be it and I will have to re-write my code a bit, but if it can be done as one continuous file I would be able to resume my coding immediately.

    Zeus
  • davejamesdavejames Posts: 4,047
    edited 2012-11-07 16:08
    ...ok, understood.

    There is the need for one slot to "RUN" another slot when the code approaches the end of allocated memory. Which is why (for me), slicing up each menu's code into multiple slots works well.
  • ZeusZeus Posts: 79
    edited 2012-11-07 16:14
    Dave,

    So you are saying that I will have to load multiple programs due to the size, correct?

    Jake
  • davejamesdavejames Posts: 4,047
    edited 2012-11-07 17:07
    Hi Jake,

    I'm struggling with the terms we're using...but, yes, you'll need to load separate files that contain the complete program. Each file contains up to 2K worth of code that would be loaded into a given memory slot.

    Is there a chance you can relate a bit more details of your progam so that suggestions could be made on partitioning? If not, understood.

    Dave
  • NWCCTVNWCCTV Posts: 3,629
    edited 2012-11-07 18:44
    davejames wrote: »
    ...ok, understood.

    Which is why (for me), slicing up each menu's code into multiple slots works well.

    How is this done?
  • davejamesdavejames Posts: 4,047
    edited 2012-11-07 23:48
    NWCCTV wrote: »
    How is this done?

    Hi NWCCTV,

    In my particular case, I have a program that consists of a number of menus that display on a 4X20 LCD: "sign on", "run or program", "select this", "select that", "save selections" (the names are changed to protect the innocent).

    Navigation through the menus is done via a rotary encoder and choosing menu items is done with a single button switch.

    Each of the 5 menu's code is contained in a separate BS2pe source file (extension .bpe).

    The list of source files to load resides in a line at the top of the "sign on" file:
    ' {$STAMP BS2pe, RunProgram.bpe, SelectThis.bpe, SelectThat.bpe, SaveSelections.bpe}
    

    The "sign on" code is loaded into BS2pe memory slot 0. "run or program" into slot 1, "select this" into slot 2, "select that" into slot 3, and "save selections" gets loaded into memory slot 4.

    To "hand off" operation from one slot to another in this case, when "sign on" has completed its output to the LCD, it executes a RUN 1 statement. At that time, the code in memory slot 1 begins to execute ("run or program" and its menu). When "run or program" is finished, it executes a RUN 2 statement...and so on...and so on. Actually, I do a bit of error checking and if things don't go as planned, program execution gets routed back to the first memory slot with "sign on".

    Did that make any sense?
Sign In or Register to comment.