TIB: The LIB4 TI-BASIC Program Structure Standard


[Prev][Next][Index][Thread]

TIB: The LIB4 TI-BASIC Program Structure Standard



Title: The LIB4 TI-BASIC Program Structure Standard
I have published standards for a new means of code and routine re-use and collaboration that i designed a few years ago.  I call it the LIB4 standard.  It is AMAISINGLY useful for TI-BASIC programmers.  The document, lib4.txt, can be found in ticalc.org's technical document directory, but it's not that long so I will include it here.  Contact me for any comments of questions.

--
M   M IIIII TTTTT  CCC  H   H  OOO
MM MM   I     T   C   C H   H O   O
M M M   I     T   C     HHHHH O   O
M   M   I     T   C   C H   H O   O
M   M IIIII   T    CCC  H   H  OOO
ticalc.org handle:  mitchodog



lib4.txt
The LIB4 TI-BASIC Program Structure Standard
10/24/1999
by Michael 'Mitcho the Dog' Erlewine
erlewine@lynxus.com
ticalc.org handle name: mitchodog
-------------------------------------------

--- Section 1:  About the LIB4 standard ---
The LIB4 is the newest revision to the LIB standard, formerly known as dlib3 or the Skylights-style Library Standardization.  The LIB4 standard comes from a never released GUI / OS for the TI-86 called Skylights.  By programming with, or converting to LIB4 in your programs, other programs will be able to tap into the specialized power of your program and be able to give the right credit to you for using your algorithms, and without actually copying any of your algorithm code.

--- Section 2:  Why use the LIB4 standard? ---

LIB4's Pros:
- You can incorporate anyone else's public algorithms into your programs, saving you coding time and adding strength to your program
- If others don't like your program's interface, they can easily make a compatible program sporting their interface, without making any changes to your program
- Proper credit is always given to the original programmer
- Makes updating to newer versions a breeze
- Allows for multiple similar programs to save space by accessing the same library, where the actual calculations take place

LIB4's Cons:
- You may not use all of the functions that are part of a library, wasting space, though this should not be a problem if the libraries are designed well
- The proper library files are required for the use of the programs

--- Section 3:  LIB4 system schematics ---
A LIB4 program accesses library(s), either made for the program, or someone else's.  Most all of the actual calculations and algorithms are in the library, and can be accessed individually.  The main program does not need to go along with much of a standard, but the library MUST follow the LIB4 standard.  This sample program shows a splash screen, asks for a STRNG var, asks for a character, and counts the number of characters in the string.

PRGM: Sample                       PRGM: SmplLib
:1->CODE                           :If CODE==1
:SmplLib                           :Then
:Pause                             : RcPic SmplPic
:Input "Enter varname: ", strng    : Return
:InpSt "Enter char: ", char        :End
:2->CODE                           :
:SmplLib                           :If CODE==2
:Disp "There are"                  :Then
:Disp x                            : 0->x
:Disp char+"s in your string"      : For(A,1,lngth strng)
:Pause                             :  If sub(strng,A,1)==char
:ClLCD                             :   x+1->x
:0->CODE                           : End
:Outpt(1,1," ")                    : Return
:Stop                              :End
                                   :
                                   :Outpt(1,1,"SmplLib")
                                   :Outpt(2,1,"Sample LIB4 library")
                                   :Outpt(3,1,"Michael Erlewine")
                                   :Outpt(4,1,"'Mitcho the Dog'")
                                   :Outpt(5,1,"erlewine@lynxus.com")
                                   :Return

Now any other program can access SmplLib to count the number of 'char's in 'strng', in the same manner that Sample did.  By combining different related functions into one library, multiple programs can use functions in the library, saving the individual programs space.

Notice that the Sample returns the variable CODE to 0 at the end, and that if CODE is not a number of a valid routine in SmplLib, it displays a credit screen.  In this way, anyone can check how to contact the original author of the routine, and not bother the program's writer.

--- Section 4:  Your program's routines ---
For example there is a routine in Smpl2Lib, routine number 4, which sets the windows to a specific standard.  You want to do the exact same thing in your program.  Instead of rewriting the code, you can just put in the following:

:4->CODE
:Smpl2Lib

This will set the calling routine number to 4, and call Smpl2Lib.  Smpl2Lib will skip all other routines, just run routine number 4, and return right back to the next line after the ':Smpl2Lib'.  Your program will now continue.

--- Section 5:  The library's structure ---
The library must follow a more strict standard.  For example, if you want to make routine number 3, this would be the structure:

:If CODE==3
:Then
: <your routine here>
: Return
:End
:

This is the basic structure.  It's not that hard.  Now here are the some more specifications for the libraries:
- Routine numbers must start from 1, and be positive integers i.e. 1,2,3,4...
- All routines must Return back to the originating program at the end
- There must be a simple credit screen that is at the very bottom of the program.  This will run automatically when none of the other routines were run, and it is reached.  It is a few Outpt(s, with a Return at the end.  This must include your name (legal or nickname, or both) an email address or other medium of communication.  This is limited to 8 lines.  A version number is recommended, since some libraries may act differently depending on it's revision.
- Library files must be locked, just so people dont ***** it up, or change the credits.  Your program should be unlocked, so that people can see what routines are being called when and make their own interfaces and programs based on yours, using your library.
- Library files must have names that end in 'Lib', just to make things clear.

Routines in libraries do NOT need to be in order of routine number.  It is to your advantage to see which routines are used most often and bring them to the beginning, since that will speed up the program.

--- Section 6:  Distributing LIB4 libraries ---
When distributing LIB4 libraries, you MUST include a document to describe your library's routines.  This must include the routine number, what the routine does, and what variables are used for what.  Remember, without this documentation, no one will be able to use your libraries, and as more programs use your libraries, the more your name will known, and your programs will be distributed.

--- Section 7:  Assembly LIB4 libraries ---
It is quite possible, and quite helpful, to make LIB4-compatible libraries in assembly.  The program must find CODE in RAM, check its value, then run the proper routine, or display a standard credit screen.  This should not be terribly hard for any assembly programmer.

--- Section 8:  For more information ---
For more information, contact Michael "Mitcho the Dog" Erlewine at erlewine@lyxnsu.com, or go to his TI page at erlewine.homepage.com/ti/

--- About the author ---
Name:          Michael Erlewine
Other names:   Mitcho the Dog, The Great Mitcho, Mitcho
Birthday:      06/08/1999
eMail:         erlewine@lynxus.com
Website:       erlewine.homepage.com/mitcho/
               erlewine.homepage.com/ti/
AIM/AOL:       mitchodogg
Platform:      MacOS / LinuxPPC / BeOS PPC
ticalc.org:    mitchodog
History:       MacAddict since his first Mac in 1993
               got his TI-86 in summer 1997
               master Mac hacker
               master TI-BASIC programmer, specializes in algorithm design and optimization
               co-decoder of the Sqrxz level description language
               MathCounts 1st Place State Team 1999
               Math Team 1st Place State Team 1997-1999
               Currently in college Calculus I at the University of Minnesota
Comments:      "And yes, I'm single!"

More information on Mitcho is in the document caphill.txt in the miscellaneous information directory of ticalc.org