Libraries. Texas Instruments TI-Nspire CX
Reklaam
Reklaam
Libraries
A library is a TI-Nspire™ document that contains a collection of variables, functions, and/or programs that have been defined as library objects.
Unlike ordinary variables, functions, and programs, which can be used only within a single problem (the problem in which they are defined), library objects are accessible from any document. You can even create public library objects that appear in the TI-Nspire™ Catalog.
For example, suppose you have created library document matrix containing public library function diagwithtrace() and a private library function errmsg() .
Function diagwithtrace() displays the diagonal of a square matrix and calculates the trace of the matrix. If its input is not a square matrix, the function calls errmsg() , which should then return an appropriate error string.
You could then use the following syntax to display the diagonal and calculate the trace of matrix
m
defined in the current problem:
matrix\diagwithtrace(m)
Libraries 557
Creating Libraries and Library Objects
A document is regarded as a library when it is saved or copied to the designated library folder. The default location is:
• Windows®: My Documents\TI-Nspire\MyLib.
• Mac®: Documents/TI-Nspire/MyLib.
• Handheld: MyLib
If the folder has been inadvertently deleted, you must create it before attempting to use libraries.
You can define library objects using either the Program Editor or the Calculator application. Library objects must be defined with a
Define command and must reside in the first problem of a library document.
Note:
If you use the Program Editor to define a library function or program, you must store the object and also save the document. Saving the document does not automatically store the object. For more information, see Programming.
Naming restrictions apply to library documents and library objects.
• A library document name must be a valid variable name between 1 and 16 characters long, and it must not contain a period or begin with an underscore.
• A library object name must be a valid variable name between 1 and 15 characters long. It must not contain a period and must not begin with an underscore.
Private and Public Library Objects
When you define a library object, you designate it as private (LibPriv) or public
(LibPub).
Define a=5
a
is not a library object.
Define LibPriv b={1,2,3}
b
is a private library object.
Define LibPub func1(x)=x^2 - 1
func1
is a public library object.
A
Private library object does not appear in the Catalog, but you can access it by typing its name. Private objects serve well as building blocks that perform
558 Libraries
basic, low-level tasks. Typically, private library objects are called upon by the public functions and programs.
A Public library object appears in the Catalog’s library tab after you refresh the libraries. You can access a public library object through the Catalog or by typing its name.
Mac® only: In version 1.4 of the software, a library document name cannot contain extended characters, such as Ö, á, or ñ.
Note:
In library programs and functions defined as public, a comment line (©) immediately following the Prgm or Func line is automatically displayed as help in the Catalog. You could, for example, show a syntax reminder there.
Using Short and Long Names
Anytime you are in the same problem where an object is defined, you can access it by entering its short name (the name given in the object’s
Define command). This is the case for all defined objects, including private, public, and non-library objects.
You can access a library object from any document by typing the object’s long name. A long name consists of the name of the object’s library document followed by a backslash “\” followed by the name of the object. For example, the long name of the object defined as func1 in the library document lib1 is lib1\func1 . To type the “\” character on the handheld, press g p
.
Note:
If you cannot remember the exact name or the order of arguments required for a private library object, you can open the library document or use the Program Editor to view the object. You also can use getVarInfo to view a list of objects in a library.
Using Library Objects
Before using a library variable, function, or program, make sure that these steps have been followed:
• The object has been defined with the Define command, and the command specifies either the LibPriv or LibPub attribute.
• The object resides in the first problem of a library document. The document must reside in the designated library folder and must meet the naming requirements.
Libraries 559
• If you defined the object using the Program Editor, it has been stored using
Check Syntax & Store from the Program Editor menu.
• The libraries have been refreshed.
Refreshing the Libraries
▶
Refresh libraries to make the library objects available to your documents.
From the Tools menu, click Refresh Libraries .
Handheld: Press
/ b and click
Refresh Libraries
.
Using a Public Library Object
1.
Refresh the libraries.
2.
Open the TI-Nspire™ application in which you want to use the variable, function or program.
Note:
All applications can evaluate functions, but only the Calculator and
Notes applications can run programs.
3.
Open the Catalog and use the library tab to find and insert the object.
4.
If arguments are required, type them inside the parentheses.
Using a Private Library Object
1.
Refresh the libraries.
2.
Open the TI-Nspire™ application in which you want to use the variable, function, or program.
Note:
All applications can evaluate functions, but only the Calculator and
Notes applications can run programs.
3.
Type the name of the object, such as lib1\func1().
In case of a function or program, always follow the name with parentheses.
To type the “\” character on the handheld, press g p
.
4.
If arguments are required, type them inside the parentheses.
Creating Shortcuts to Library Objects
You can make the objects in a library more easily accessible by using libShortcut() to create shortcuts to them. This creates a variable group in the current problem that contains references to all the objects in the specified library document. You can choose to include or exclude the private library objects.
560 Libraries
For example, suppose the library document linalg contains functions named clearmat, cofactor, gausstep, help, inversestep, kernelbasis, rank, and simultstep. Executing libShortcut(
“linalg”,“la”
) would create a variable group containing the following members: la.clearmat
la.cofactor
la.gausstep
la.help
la.inversestep
la.kernelbasis
la.rank
la.simultstep
You can refer to those library objects from within the current problem by typing their variable names or by selecting them from the Variables menu.
For more details about using libShortcut() , see the
Reference Guide.
Included Libraries
To help you get started with libraries, the TI-Nspire™ Software installation includes a library document with useful Linear Algebra functions. The library is named linalg or linalgCAS and is installed in the designated library folder.
Note:
Updating the handheld’s operating system or reinstalling the computer software places all included libraries in the default folder. If you have edited an object in an included library or replaced an included library with your own document of the same name, updating or reinstalling will overwrite your changes. This could also happen after batteries are replaced or the handheld system is reset.
Restoring an Included Library
If you inadvertently delete or overwrite an included library, you can restore it from the installation DVD.
1.
Open the DVD, and navigate to the libs folder.
2.
Identify the library file to restore, such as linalg.tns
or linalgCAS.tns
for the linear algebra library.
3.
Copy the file.
Libraries 561
Windows®: Copy the file to your designated library folder. The default location is My Documents\TI-Nspire\MyLib .
Mac®: Copy the file to your designated library folder. The default location is
Documents/TI-Nspire/MyLib
.
Handheld: Connect the handheld to your computer, open the
TI-Nspire™ software, and copy the library file to the handheld’s MyLib folder.
4.
Activate the new library objects.
From the TI-Nspire™ Software
Tools menu, click
Refresh Libraries
.
Handheld: Press
/ b
, and click Refresh Libraries .
562 Libraries
Laadi alla
Reklaam