ticalc.org
Basics Archives Community Services Programming
Hardware Help About Search Your Account
   Home :: Community :: Articles :: BASIC Library Functions
BASIC Library Functions

Posted on 19 November 1998

The following text was written by Dennis Lambe Jr.:

The power of the TI-89/92/92+ calculators still amazes me.  Their advanced symbolic math capabilities have revolutionized the way I thought of calculators.  But what is even more amazing to me than what they do is what they can do.  When TI introduced the incarnation of TI-BASIC used by these calculators, including the ability to create functions and pass parameters, a doorway was opened for the functionality of these calculators to be expanded limitlessly.  This makes me wonder why a common library of utility functions and programs haven't been developed to make it easier to write more complicated calculator aplications without duplicating code and wasting time.

I have developed a number of these utilities, but I never released them for one, rather embarassing reason: my overuse of ASM games has caused my calculator to crash before I could back up my most favorite creations.  However, I continue my work, and I invite the rest of the TI community to join me.  With that in mind, I have developed a few standards that will make an organized effort easier.

First of all, I suggest that every "library" utility be placed in a folder named "libs", thus keeping the main folder from getting cluttered and providing a place for permanent data to be stored.

A variable named "calctype" should be kept in this folder, and it should contain either "92", "92+", or "89", depending on the calculator it exists on.  This will allow graphics routines to be written that can be run on any of the three calculators without the need for editing.

Most importantly, the routines should be coded in such a way as to work no matter what folder they are executed from, since many complicated programs often exist in their own folders.

As for what these routines should do, I leave that up to your imaginations.  I myself am working on a Long File Name system to hold saved games, Organizer information, or whatever.  I've actually already written one, and am simply adapting it for use by multiple programs.

Oh, and I've cut back on my game playing, so maybe you'll actually get to see it before it gets erased :-)

  Reply to this item

Re: Article: "BASIC Library Functions"
EmuCalc

I do NOT agree with you. You are trying to make "TI-basic" into "TI-basic for geeks". Real geeks use Assembly, and you are going to have to learn assembly eventually if you want to program any worthwhile programs.

Maybe when the CPU of the calc runs at 450 mhz, then will higher language programming libraries become effective. But by that time, you will not have to worry about storage and not duplicating code. IBM just came out with a 340 megabyte hard drive the size of a quarter, which is used in cameras.

Reply to this comment    20 November 1998, 02:08 GMT

Re: BASIC Library Functions
Monkeyforx

What about Francois Leiber's FLIB libraries? They are an incredible source of Assembly functions that can be called quickly and painlessly from ANY BASIC program. What's more, since they can accept a virtually infinite number of arguments, you could (in theory) write an entire Assembly program using very few lines of BASIC code (you'd need more than one if you wanted to interpret and negotiate user input). In fact, it is possible to build a three-minute long animated movie - in grayscale - using FLIB. I have done so - it's about the adventures of a kid named Todd. I applaud Francois for his bold step into the unknown realms of BASIC/Assembly libraries and the wonders they hold.

Reply to this comment    1 February 2001, 22:11 GMT

Re: Article: "BASIC Library Functions"
Psilon
(Web Page)

Just a few modifications to the idea:
1. Don't put it in "libs\"! Stick it in something that comes AFTER main\ so that people using VAR-LINK don't have to scroll through 5+ pages of programs just to find their own stuff. TI should learn this, because the adv\ and elem\ packages drive me up the wall.
2. Add TI-Basic wrappers to some useful ASM routines (maybe using the incomprehensible Exec command) so non-assembly guys can use them too and do cool tricks.
3. calctype as a string would be irrelevant. Programs could do something along the lines of the following to check models:

Try
Local pid
left(getConfg()[6],2)->pid
If pid="01" Then
Return "TI92+"
ElseIf pid="03" Then
Return "TI89"
EndIf
Else
Return "TI92"
EndTry

Don't yell at me if the product ID is wrong, as I use a 92+ instead of an 89. I added the left() because Flash updates change the later digits of the product ID returned by getConfg().

And finally,
4. Try to combine utilities into one big program, maybe passing the actual one like this:
tilibs\lib1("Function1",a,x^2,42)
After all, one bigger program is usually preferable to three little ones, and since calling subprograms is already slow there can't be that much of a performance hit.

Otherwise it sounds like a good idea, although once someone makes an on-calc compiler like Jazz on the HP it'll dry up like the Sahara in summer.

Reply to this comment    20 November 1998, 23:57 GMT


Re: Re: Article: "BASIC Library Functions"
Patrick Dwyer

I agree with not putting libraries in a folder named "lib". How about the ascii character 255 (on the TI-92 it is a y with two dots on top, I use this method a fair bit) and then "lib", if you do this it will appear at the end of the var-link screen.

Reply to this comment    14 March 1999, 13:35 GMT

Re: Article: "BASIC Library Functions"
Mr. Stupid

Am I wrong in thinking that someone really smart could write a compiler that would convert TI-Basic into ASM. I have a compiler that can turn my Q-Basic programs into executables. Or do I just need to lay off the crack?

Reply to this comment    22 November 1998, 04:04 GMT

Re: Re: Article: "BASIC Library Functions"
Jeff Tyrrill

A TI-Basic to ASM compiler would be difficult and not that helpful because Basic programs sometimes generate code during runtime that would need to be interpreted then (such as simplifying a mathematical expression, or executing a TI-Basic statement stored as a string with the expr() function), so the ASM program would still need to call the TI-Basic interpreter frequently. Also, because the ASM program would just be doing the same thing that the TI-Basic routines are doing, it would be hardly any faster.

Reply to this comment    22 November 1998, 22:12 GMT


Re: Re: Article: "BASIC Library Functions"
QK

I think it well be better to make a compiler on calculator or computer for the algorithmic programming languages (e.g. C/C++, Pascal, Java, etc.) to ASM. I do know that a lot of people knows those languages.

I personally program only in C++ and Java, and don't know ASM nor how hard is it. I will take this comment back if ASM is very hard.

Reply to this comment    26 November 1998, 03:04 GMT

Re: Article: "BASIC Library Functions"
Lord Unigamer

BASIC libraries would kick butt! I can't do ASM. I don't understand it. But I am very handy with BASIC, and some routines do get tedious.

Reply to this comment    25 November 1998, 21:13 GMT

Re: Article: "Getkeys"
Zach

I am confusedabout getkeys. i know that there are certin # that will let you use certin buttons but i dont know what numbers they are if you have any list or just a few or any comments please E-mail me.

Reply to this comment    28 November 1998, 06:58 GMT

Re: Article: "BASIC Library Functions"
Jeff W

On my TI-89, BASIC games take a really long time to load, and when in game play, very slow in animation and gameplay. Also bad graphics at times. Compare to assembly games, now how would BASIC game compare to the fast-paced action (usually) of Assembly games?

Reply to this comment    28 November 1998, 08:35 GMT


Re: Re: Article: "BASIC Library Functions"
Person

If you lock the game it won't take so long.

Reply to this comment    12 July 1999, 23:37 GMT

Re: Article: "BASIC Library Functions"
Cliff

There -was- a C compiler for TI-92s, called TIC. Of course, it disappeared, but it was really very nice. :-)
As for libraries, I say go for the TI-BASIC libs. This basically comes down to the Visual Basic vs. C debate--less power but faster development in BASIC. (And on that note, I agree with everyone--let's get some ASM libs that are callable from BASIC! I'm working on this for sound, anyone else interested?)

Reply to this comment    30 November 1998, 20:11 GMT

Re: Article: "BASIC Library Functions"
Ctrl-Alt-Del

I think that BASIC libraries have their good and bad points.

For the good: less 'tedious' stuff to program (ie: getkey() commands), universal between 89, 92 and 92+ calcs with little or no changes necessary.

For the bad: slower runtime (correct me if I am wrong, but it really slows down the calc everytime a prog has to call another one...), would need a special folder for them (ie: libs\BASIClib1() or libs\BASIClib2() )

However, I think we should give BASIC libraries a chance. I made my own (kinda..it's sort of more like a function) that displays the small font (like the one in the status bar or in the dialog boxes) anywhere on the graph screen. If anyone's interested, drop me an e-mail (senoramor@yahoo.com) and I'll be more than happy to e-mail a copy of it to you.

**Included characters:
A-Z, a-z, 0-9, !, #, ., (comma), ;, :, ', ", and more I think.

Reply to this comment    1 December 1998, 10:07 GMT

Re: Article: "BASIC Library Functions"
Anonymous

What an amazing idea! Just think of all the time I've wasted duplicating getKey statements...I could've put them all in one library and run 5 or 6 programs off of them. This is a WONDERFUL idea that deserves prompt action!

Reply to this comment    4 December 1998, 23:49 GMT

Re: Article: "BASIC Library Functions"
agent double "O-SH*T"

just out of curiosity what would the libs do, besides the obvious getkey commands?????????

Reply to this comment    8 December 1998, 21:56 GMT

TI-85 BASIC Library
David Strauss

I for one, long ago, created a set of BASIC libraries for the TI-85. It is called the "Davidsoft Programming Pack." It includes such functions as titles (centered at the top of the screen) and restoring defaults.

Reply to this comment    12 January 1999, 23:31 GMT

Re: Article: "BASIC Library Functions"
Kyle

Can sombody add functions to a calculator fo things like gray scall. Like hacking it when they made all those assembly shells.

Reply to this comment    25 February 1999, 21:30 GMT

Re: Article: "BASIC Library Functions"
Jordan P.

Basic library functions are a great idea!

My philosophy on the subject is: let’s keep Basic basic, but lets expand what we got! My goal is to maximize the amount of time saved by others and myself in using this powerful calculator. Personally, I could care less how the libraries are implemented (Basic or Assembly) if the job could be done well, but the fact is we need them.

Even though the libraries add to the calculator capabilities, I see many people wandering too far away from what the realization of Basic libraries means to TI calculator users. When I think of a “library”, I do not, for the most part, think of extended features, that is things that the Basic programming language couldn’t normally do on its own. But rather, I think of code saving, pre-written, pre-tested, and time saving functions. In many ways the criticism of the Basic library is very realistic. This is because there is ambiguity in exactly how far and how much the libraries will be able to extend the functionality of the calculator. Before any project is undertaken it is important to make these distinctions.

Let’s look at what Basic libraries can and cannot do:

Basic libraries cannot:
1) REPLACE assembly code as the programming platform for calculators. Assembly can do many things well, due to the low-level control of hardware, which Basic cannot do by itself.
2) Be relied on for speed, that is, the programs should not be intended for lightning-fast executions for things such as games and applications.

Basic libraries on the other hand:
1) Provide additional functions that were not included on the calculator. Special mathematics functions are a good example. TI could not possibly have included every mathematics function pre-built in the calculator (it does appear that way though). This is reason why the programming abilities were built into the calculator, this applies especially to the new user defined functions.
2) Are generally better for things that provide high-level functionality, such as manipulating of expressions.
3) Are not intended to turn the “Joe Average” Basic programmer into a hard-core game programmer. This is definitely not my goal. In fact, I don’t even have a game on my calculator!

Functions have greatly increased the ability of the TI Calculator to be used for programming purposes. Any Basic library that is developed should consist of more functions than programs. The concept of the function fits in well with a library: ultimately the idea of reusable code. This is because the concept of a function on the TI calculator (only slightly different from that of functions in traditional programming languages) is that the function returns a value and does not (with the exception of a few instructions listed in the TI-89 Manual, “Differences Between Functions and Programs”, pg. 273, Oct. 1998) allow for any interface visible manipulation. Programs are usually not as reusable as are functions. Only the results of functions are used, which makes them ideal for reusable code. Functions can also be called from the home screen and used in “normal” expressions, which makes them especially useful when they are available in libraries.

Programs usually have interfaces, which are displayed on the screen and may get input from users. However these types of programs are rarely reusable because interfaces need to be changed and vary upon the preference and needs of the programmer. As a general rule, only the most basic of programs (with well-defined and common tasks) should be included in the library. For example a program which can do basic screen and text operations should be included in the library, but a lengthy chemistry program which does many inputs should not.

Indeed, EmuCalc, a critic to the idea of libraries, pointed out that some people are trying to make "TI-basic" into "TI-basic for geeks". I agree with EmuCalc that “...you are going to have to learn assembly eventually if you want to program any worthwhile programs.“ However these criticisms seem only to apply to the concept of Joe Average writing the next Mario Brothers. We need to see the libraries in their full potential, that is, improving the functionality of everyday operations and basic Basic programming. As Jeff Tyrill pointed out, “Assembly is usually only better than TI-Basic for games, not math, and still, any type of program can be written with TI-Basic much more easily than in assembly”

Critics of Basic programs say that the programs written in Basic just plain suck:

The control over the calculator with BASIC is
so limited. I personally, hate BASIC graphics
on my 92, because whenever it happens, I have to
see those graph menus, and it usually changed
my Graph settings, etc. --EC

However, it is obvious that Basic isn’t what makes these programs poor, its the programs themselves. Once again, Jeff Tyrill makes a point: “Only poorly written TI-Basic programs screw up calculator settings”.

In composing a library intended for widespread use, time would definitely have to be taken to ensure that Basic programs and functions were well debugged and useful.

Basic programs are also editable as well as reusable. Basic programs can be written on the calculator without the need for a computer. Indeed, much of the programs that I find myself writing are short and do not take much time. Machine code on the other hand takes a LITTLE more time to write and debug. Let us not forget that Basic is the programming language of choice by TI for use ON the TI calculator. This means that for the most part Basic code is much more easily adapted for use on the TI calculator.

The bridge between Basic and Assembly seems an interesting proposal which I await with an open mind, once again, however, the extent to which the interaction between the platforms will occur should be considered in depth.

It seems as if everybody has there own program or function that they wrote that helps operate their calculator best. Even Kelly, an opponent to the library functions, says

Personally, I have my own set of library functions that I use on my TI-89 to do such things as compute matrix exponentials, or do contour integration...I dont think anybody else might find them useful, especially in writing their own programs

There are two points to note from this statement. The first is that library functions are a very useful (and practical) idea. The second is that using the library functions will not be used strictly for programming. Once again, Basic functions and programs can be used from the home screen (with functions providing the most use in this context).

For example, a function that gets a column vector from a matrix could be included in the library. There are simple functions such as this which save large amounts of time when doing simple tasks.

I conclude by saying let’s develop a Basic library, let’s lead the direction of the Basic library towards functions, and let’s keep Basic basic, but lets expand what we got.

-Jordan P.

Reply to this comment    16 March 1999, 09:08 GMT


Re: Re: Article: "BASIC Library Functions"
Mastab

whew

Reply to this comment    15 April 1999, 00:21 GMT
1  2  

You can change the number of comments per page in Account Preferences.

  Copyright © 1996-2012, the ticalc.org project. All rights reserved. | Contact Us | Disclaimer