[7.5] Considerations For Referencing External Programs - Texas Instruments TI-89 Tip List

Graphing calculator
Hide thumbs Also See for TI-89:
Table of Contents

Advertisement

This method fails if the function is designed to return a string instead of a number. In that case you may
be able to use special coded strings for the error message. For example, suppose we have a routine
that is supposed to build a string from two arguments:
stringit(a,b)
func
if dim(a)=0 or dim(b)=0 then
return "©bad arg in stringit"
else
return a&b
endif
endfunc
stringit() is supposed to return a concatenated with b, but only if both arguments have one or more
characters. If this is not true, then stringit() returns an error message, the first character of which is the
89/92+ comment symbol, character 169. In this case, the calling routine checks the first character of
the result to see if it is character 169. If so, the error is handled.
This method assumes that the strings will not start with character 169.

[7.5] Considerations for referencing external programs

This is not so much as tip as it is some things to consider when you write a program that call routines
which are external to that program. For example, suppose we have a program A() which calls program
or function B(). If both A() and B() are in the same folder, and that folder is the current folder, there is
no problem. We have this:
A()
prgm
...
B()
...
endprgm
It is not so simple, however, when you consider some other likely cases. For example, B() might be a
general-purpose utility program, located, for example, in the /utils folder. The most straightforward way
to deal with this problem is to include the folder specification in the function call, like this:
A()
prgm
...
utils/B()
...
endprgm
This method has these disadvantages, because the folder name is hardcoded in program A():
! The B() utility must be in the /utils folder, and it cannot be moved.
! The /utils folder cannot be renamed.
! An RAM or archive overhead is incurred each time B() is referenced in A().
! If you distribute your program to others, the /utils folder must be created, and B() must be stored in
it. Suppose that the user already uses that folder name, or already has a program of her own called
B()? Then there is a conflict.
Method 1
Method 2
7 - 5

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ti-92+

Table of Contents