This text contains a detailed description of all the functions of Flib and Flib2, read Readme for a more general presentation.
How to use Flib:
You only have to type, usually in a BASIC program:
flib("command1" [,"command2",...])
example : flib("clrscr","msg:Hello, World !","slrcl")
If you use functions from flib2, then:
example: flib2("version","mkhs:10,500,fl,sc","hide:sc")
Numerical arguments can be of any type, just like BASIC: numbers, but also variable names, mathematical expressions, brief anything that returns a number. Attention, a numerical argument has to begin by a number or a space:
example, beware at the spaces before 'list', 'int' and 'sin': flib2("drawline:0,1/2-1/5, list[5], int(a+7*b), sin(atan(x^2))")
A number or a variable name will work perfectly and fast (I did it by hand), whereas expressions will be much slower and won't recognize local variables. If an argument has a syntax error, Flib will stop by throwing an error, just like a BASIC instruction would do.
Flib returns always a list, empty if need be, containing the results of all the functions, in the order they are called. This list is stored in variable 'fl', which can be declared as a local variable.
If you don't understand a function, LOOK AT THE EXAMPLES given with Flib; 99% of the problems can be solved this way, thanks! I won't reply to the questions which can be answered by reading the examples, I really don't have time left for this... Moreover, Flib is just a library to fill up the lacks of the TI-BASIC, but you must already know this langage before using this library!
Info:
Functions of the second library (flib2) are preceded by a star.
All the function names are in small letters and the shorter possible so they are easier and shorter to remember and write.
I've now included all kinds of protections, so I think Flib can't throw an error any more, even if the arguments are wrong.
General functions:
"off"
Turns the calculator off.
"breakoff"
Disables the break (ON key, see example 'flpass'). Attention, using getkey(), calling a program or function string() will enable the break again, that's why I haven't included another function to enable it. Finally, since this function disables all interrupts, it will speed up your programs.
C |
C#
|
D
|
D#
|
E
|
F
|
F# | G | G# | A | A# | B |
A
|
B
|
C
|
D
|
E
|
F
|
G | H | I | J | K | L |
To change the octave, type 'O' followed by the number of the octave, which has to be between 0 and 4 (2 by default).
To change the notes' type, type:
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
Semibreve |
Minim
|
Dot crochet
|
Crochet
|
Dot quaver
|
Quaver
|
Double quaver | Treble quaver | Triolet |
4 beats
|
2 beats
|
1+1/2 beats
|
1 beat
|
1/2+1/4 beats
|
1/2 beat
|
1/4 beat | 1/8 beat | 1/3 beat |
Finally, for a rest, type 'P', the rest will be the same length as the note who would have been played instead.
"wait:value"
Waits without doing anything, value is a time in tenth of a second. This function is parameterized to fit exactly on HW2 calculators.
*"apd:value"
Sets the value of the automatic power-down (APD) rate; value is a time in seconds. Returns the previous value.
*"error:num"
Throws the error num; see the TI manual to find the meaning of the different error codes. The advantage of throwing an error manually is that you can inform the user of the error without exiting the program.
*"reset"
Resets the calculator. This function isn't the most useful, but it's the funniest for sure!
(*)"version"
Returns a string containing Flib's version.
"getcont"
Gets the current contrast, which is a integer between 0 (very low contrast) and 15 (very high contrast).
"setcont:value"
Set the current contrast. value has to be a number between 0 and 15.
"+"
Increases the contrast.
"-"
Decreases the contrast.
Graphical functions:
The argument 'mode' is always optional, it will be replaced by 1 if it is omitted.
The coordinates begin at the upper left corner (0,0) to the lower right corner (159,99) [or (239,127) on a 92+].
"gray"
Activates the grayscale mode, clears the screen on the two planes, and activates plane 1. At the end of Flib's call, the library waits for the user to press a key, then returns the value of the pushed key, turns the grayscale mode off and restores the original screen (look at the examples 'grayex' and 'anni').
"gray2"
Same thing as 'gray', but the calculator does not wait for a key-press at the end. If you call this function a second time, it will turn the grayscale mode off.
"plane:x"
Sets the active plane to x : all the graphical function calls that you'll make after will draw on this plane. x can take the values 0 and 1.
A * pixel corresponds to planes * on/off :
"clrscr"
Clears the screen.
"sprite:[x,][y,][mode,]pic"
Puts the bitmap pic to the screen at position (x, y).
mode can take the values:
x and y are worth 0 by default.
"savpic:x1,y1,x2,y2,pic"
Saves in variable pic the part of the screen between the points (x1, y1) and (x2, y2).
"savscr:pic"
Saves the LCD screen and puts it in pic.
"rclscr:pic"
Restores the LCD screen saved in pic with 'savpic'.
"picsize:pic"
Returns, in a list, the horizontal and vertical dimensions of pic.
"rect:x1,y1,x2,y2[,mode]"
Draws a empty rectangle with (x1, y1) and (x2, y2) as corners.
mode can take the values:
In fact, if you're looking for a particular effect, just try other arguments, you can have rounded and inverted rectangles, double rectangles with the corners cut...
Moreover, the values indicated above will draw white rectangles, you'll have to add one of the three first values to draw a black or inverted rectangle.
Ex: 97 ( = 64 + 32 + 1 ) for a black double rounded rectangle.
"fillrect:x1,y1,x2,y2[,mode]"
Draws a filled rectangle with (x1, y1) and (x2, y2) as corners.
mode can take the values:
"filltri:x1,y1,x2,y2,x3,y3[,mode]"
Draws a filled triangle between the points (x1, y1), (x2, y2) and (x3, y3).
mode can take the same values as 'line'.
"fillpoly:x1,y1,x2,y2,x3,y3,x4,y4[,mode]"
Draws a filled quadrilateral between the lines (x1, y1)-(x2, y2) and (x3, y3)-(x4, y4).
The first line has to be closer to the bottom of the screen than the second one, or nothing will be drawn.
mode can take the same values as 'line'.
"ellipse:x,y,r1,r2[,mode]"
Draws an ellipse with center at (x, y), and with semi axes r1 and r2.
mode can take the same values as 'fillrect'.
"line:x1,y1,x2,y2[,mode]"
Draws a line between (x1, y1) and (x2, y2).
mode can take the values:
Shadings will work only with lines more than 45°.
"pix:x,y[,mode]"
Draws a pixel at (x, y).
mode can take the same values as 'fillrect'.
"pixtest:x,y"
Returns 0 if the pixel (x, y) is off and 1 if it's on.
"mkpic:width,height,var,data"
Creates ,in variable var, a picture of width width and height height, where the picture itself is directly given as a string.
The data structure is defined as following: each line is given by a whole number of characters; each character contains 8 pixels (if the width of the picture is not a multiple of 8, the last bits of the last character of each line won't be used).
The lines are written one after the other.
To avoid the problem of characters that aren't accessible to BASIC, replace character n°0 by '00', n°2 by '02' and n°13 by '13'.
To understand, look at the small BASIC programs 'mkpic' and 'mkpic2' which automatically convert pictures in strings for 'mkpic'; you should also look at my BASIC Othello so you can have an example of how to use it.
If I did such a function, it's because I always see BASIC programmers who distribute their program with thousands of little pictures in several folders. With this function, it's possible to create pictures easily and with little memory.
"map:[width,][x,][y,][horiz,][vert,][mode,][time,],prefix,data"
Displays a succession of sprites in one pass, one after the other in ordered lines (look at the example 'map').
width is the number of sprites per horizontal line; when this number is reached, sprites will be drawn on the next line.
Sprites will be drawn from the point (x, y); this point is (0, 0) by default.
mode can take the same values as 'sprite'.
horiz and vert indicate what size is left to each sprite: if some sprites are bigger than this size, they'll overlap. When horiz and vert are omitted, 'map' takes the size of the current sprite as arguments, but in this case, sprites should all have the same size, otherwise strange shifts could appear.
All sprites must have their name made of prefix + 'one character': data is the succession of the characters standing for all the sprites you want to display.
Last but not least, time is a subtle argument: 'map' becomes an evolved CyclePic if you use it. Indeed, the function is then going to loop till a key is pressed by the user, time is the time given in hundredth of a second it is going to wait between two picture drawings. If horiz and vert are worth 0, all the pictures will be drawn at the same place.
Ex : flib("map:,x,y,0,,4,time,pic,123456")
where pic1, pic2,... make a little video, and x, y and time have to be replaced by numbers.
By setting time to 0, you can even make grayscale (see example 'grayex'), it is practical to display a gray image in a black & white interface; you can't do that with 'gray' (but quality is not as good).
Text functions:
"font:num"
Sets the current font.
num can take the values:
"drawstr:x,y,[mode,]str"
Prints the string str at (x, y).
If x is worth 999, the string will be centered horizontally on the screen; don't use this too often because then the programs for 89 don't work properly on 92+.
mode can take the values:
Attention, if you omit the argument mode, str shouldn't begin with a number or a space, or Flib will think it is mode. Another solution I recommend is to write a coma without any argument behind.
"drawstrv:x,y,[mode,]str"
Prints the string str vertically at (x, y).
mode can take the same values as in 'drawstr'.
"pretty:x,y,[mode,]expr"
Prints in Pretty Print mode the expression expr at (x, y).
mode can take the same values as 'drawstr'.
"pinfo:expr"
Returns the width that will have the expression when printed whith pretty, followed by the ordinate of its top and bottom.
In brief, if you print it at (x,y), it will be contained between (x, y+top) et (x+width, y+bottom).
"width:num,str"
Returns the width, in pixels, of the string str using the font num.
"msg:string"
Prints string inverted in a black box and waits for the user to press a key, then restores the screen and returns the value of the pressed key (see 'keywait').
You can print the message on more than one line by separating each line with '|', each line will be truncated after 25 chars (38 on a 92+) and centered on the screen. The screen is limited to 8 lines (12 on a 92+).
Do not use this function when grayscale mode is on, because both functions use the same memory place so save the screen, so Flib will no restore correctly the screen at the end. But you can do it manually if really you want to...
*"menu:[height,][x,][y,]title,options..."
Displays a rectangular menu with as many options and suboptions as you wish, with it's left upper corner at (x, y). The three first arguments are optional, the menu will have just the right height and will be centered if they are omitted. If height is insufficient to show all the elements, you can scroll the menu.
Each option is preceded by a coma, and each suboption by a '|'.
The value returned in 'fl' is the number of the element where the user has pressed ENTER, or 0 if he has pressed ESC.
For example, on your calculator, try
flib2("menu:20,title,option1,option2|suboption1|suboption2")
To understand, or look at the program 'menu' given as an example.
*"numline:var"
Returns the number of lines in the text variable var.
If there is a problem - var doesn't exist or isn't a text - the function doesn't return anything.
*"getline:n,var"
Returns the n-th line of the text variable var.
In a text, the first line is line n°0 (same thing for the two following functions).
If there is a problem, the function doesn't return anything.
*"delline:n,var"
Deletes the n-th line of text var.
Returns 1 if successful, 0 otherwise.
*"insertline:n,var,str"
Inserts line str between the (n-1)-th line and the n-th line of text var.
Returns 1 if successful, 0 otherwise.
High-scores functions:
A high-score table is a symbol containing several high-scores, each of them formed with a number between 0 and 65535 and a string, 10 characters maximum.
The symbol is a string, but you don't have access to the data, you will only see 'highscores by flib;' you can find an example in program 'memory.'
*"mkhs,n,score,name,var"
Creates, in var, a high-score table containing n high-scores, initialized to the value score and to the name name.
If name is more than 10 characters long, it will be truncated.
*"puths:score,name,var"
Automatically inserts in the high-score table var the record given by its value score and a name name.
Returns the place of the new record or 0 if score wasn't good enough to be in the high-scores.
If name is more than 10 characters long, it will be truncated.
*"geths:n,var"
Returns, in 'fl', the n-th high-score of var, a number followed by a string for the name.
Status Line functions:
"slclr"
Erases the status line's content.
"slrcl"
Redraws the line above the status line.
"slmsg:string"
Displays string in the status line.
"busy:mode"
Sets the BUSY indicator in the status line.
mode can take the values:
Key functions:
"keywait"
Waits for the user to press a key and returns the value of the pressed key.
Attention: the following codes are different from the ones returned by getkey() in BASIC, the other ones are the same:
Attention: on a 92+, keys Up and Left are inverted.
"keylow"
keylow is used for low-level key reading: it detects only when the arrows or the keys 2nd, Shift, Diamond or Alpha are being held down.
Moreover, it doesn't flush the keyboard queue: it is independent with all the getkey() and other key functions that you can call, it just returns the actual keyboard state.
Finally, it detects when more than a key are pressed at the same time.
It returns a string where the successive characters represent the keys 2nd, Shift, Diamond, Alpha (Lock on the 92+), Left, Right, Up and Down.
For example, "10001010" means that 2nd, Left and Up are being held down and that the other keys are not.
"initdelay:time"
Sets the time (395th of a second) a key has to be held down before it starts to repeat.
The default value is 336, but it is reseted each time you turn your calc off/on. Returns the previous value.
"delay:rate"
Sets the rate (395th of a second) at which a key auto repeats.
The default value is 48, but it is reseted each time you turn your calc off/on. Returns the previous value.
TIOS functions:
*"hide:var"
Hides the symbol or folder var (the symbol will be hidden from the TIOS).
If it is a folder, it will first fold it to hide all its variables.
*"unhide:var"
Unhides the symbol or folder var (look at 'hide').
*"size:var"
Returns the size of var.
*"state:var"
Returns a number composed of 3 bits representing the state of var: The first bit tells if var is archived, the second if it's locked and the last one if it's hidden.
More clearly, you must do this if you want to get the different characteristics independently:
flib("state:var")
fl[1] and 1->archived
fl[1] and 2->locked
fl[1] and 4->hidden
*"folder:var"
Returns the list of all the folders containing the symbol var.
*"getfolder"
Returns a list containing all the folders in the calc.
*"getfile:[type,]folder"
Returns in a list all the files of the folder folder.
Moreover, you can add another argument: a number that represents a variable type. If you do, then getfile will return only the symbols of the type type.
type can take the following values:
Expressions don't have an assigned value, that's why they don't appear here.
*"getbyte:num[,n],var"
Returns the byte number num of var.
If the argument n is present, Flib will return, in a string, n bytes of the variable var, beginning with the byte num.
The argument n is much more powerful and practical to program an editor than getting the bytes one by one, but it often throws an error (no crash, don't worry), so use it with moderation!
num has to be a number between 0 and 'size(var)-3'.
*"setbyte:num,value,var"
Sets the byte number num of var to value.
num has to be between 0 and 'size(var)-3', value between 0 and 255.
*"memcpy:ndest,nsrc,num,dest,src"
Copies num bytes of variable src, beginning with it's nsrc-th byte, to variable dest, beginning with it's ndest-th byte.
Ex : "Flib by François Leiber"->a : "Flib2 & "->b : flib2("memcpy:9,1,23,b,a")
*"komp:var"
If var is not compressed, the function compresses it: it replaces it by a variable of type KOMP, but smaller in size. If var is already compressed, then it decompresses it.
The function returns a number which can take the following values:
*"kinfo:var"
Returns the original type (see function 'getfile') and size of a KOMP variable.
*"group:[var1,var2,...]var"
When there is more than one argument, the function groups variables var1, var2, ... in var, whose type will be GRP. The sum of all the variables' sizes must not exceed 65 KB, limited by the TIOS. Variable names can include a folder name.
Returns the number of variables successfully grouped in var.
When there is only one variable name, this function understands that it must extract the variables grouped in var (its type must be GRP). If there is a numerical argument, it will only extract the nth variable from var.
Returns the number of variables successfully ungrouped from var.
With this function, you don't need to make programs with thousands of little files. Moreover, compression with 'komp' is much more efficient when you group many variables of the same type before compressing them, instead of compressing them independently and grouping them afterwards.
*"ginfo:var"
Returns the list of the files stocked in GRP variable var.
*"mkvar:size,[type,][extension,]name"
Creates a variable named var of size bytes, filled with 0.
type is a number so you can give the type of the variable (see 'getfile' to know the different possibilities). By default, 'mkvar' creates a text (type is then worth 224).
extension is a string of 4 letters maximum to create a variable whose type in Var-Link will appear as extension.
If you put arguments type and extension, this last one will be preponderant.
Ex : flib2("mkvar:7,aaa","setbyte:2,32,aaa")
to create an empty text called 'aaa'. The second byte set to 32 indicates to the TIOS the beginning of the first line.
Ex : flib2("mkvar:50,pers,aaa")
to create a 50-byte long variable whose type in Var-Link will be 'pers'.
*"type:var"
Returns the extension of var, if var has a personalized extension (made whith 'mkvar' for example).