<< Click to Display Table of Contents >> Home mIoTa BASIC > mIoTa BASIC Language Reference > Program Organization |
A mIoTa BASIC program comprises a set of user defined variables and a collection of Event Code blocks. All variables are available to all Event Code blocks and each Event Code block is triggered when a specific event occurs.
mIoTa BASIC creates a single source file for each project. This contains all Event Code blocks and User Variable assignments.
Important Notes To Remember When Creating a Program
•Each of the Event Code blocks of code are executed when that relevant event is triggered.
oSome Events require some setup before they will occur!
•The 'Power On Initialization' event is unique in that it is only triggered once, at power on, and must be completed before any other events can start.
oAvoid infinite loops in this code that may stop the Power On event completing it execution (unless this is the desired effect).
•Event Code block execution is 'time-sliced' which means any or all events could be running their code simultaneously.
oNo event can rely-on any other event being at a specific run-state.
•Subroutines can be written in any Event Code block and can be called by all other Event Code blocks, so could be called by more than one event at the same time.
oEvents using the same Subroutines at the same time could interact in unpredictable ways!
•One or more Event Code blocks can access the same variable at the same time.
oEvents using the same variables at the same time could interact in unpredictable ways!
•Once triggered, any Event Code block must complete before it can be triggered again.
oAvoid infinite loops in code blocks that will stop any other triggers of the same event. Event triggers are buffered so no event triggers will NOT be lost unless the code in a event block takes too long and the buffer overflows. So avoid slow 'long-winded' code that may cause a backlog of events.