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.
beep:freq[,length]
Plays a note at frequency freq, for length hundredths of a second (4 by default).
The notes should be perfectly in tune both on HW1 and HW2.
beep2:[tempo,]song
Plays song song with tempo (beats per minute) tempo, which is worth 120 by default. Stops when the user presses a key. song must respect the following conventions (look at the example 'sound'):
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 (crochet by default), type:
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
Semibreve |
Minim |
Dot crochet |
Crochet |
Dot quaver |
Quaver |
Double quaver |
Triple 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.
+
Increases the contrast.
-
Decreases the contrast.
getcont
Gets the current contrast, which is a integer between 0 (very low contrast) and 15 (very high contrast).
setcont:valeur
Sets the current contrast. value has to be a number between 0 and 15.
|
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 :
- white : all off
- light gray : plane 0 on, and plane 1 off
- dark gray : plane 1 on, and plane 0 off
- black : plane 0 + plane 1 on
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:
- 0 replaces the destination with the inverse of pic
- 1 superposes pic to the destination
- 2 displays pic in 'xor' mode
- 3 erases the destination
- 4 replaces the destination with pic
- 6 displays pic in 'and' mode.
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 'savscr'.
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:
- 0 erases the rectangle
- 1 draws a black rectangle
- 2 draws an inverted rectangle
- 32 draws a rectangle with rounded corners
- 64 draws a double rectangle
- 128 draws a rectangle with the upper corners cut.
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:
- 0 erases the rectangle
- 1 draws a black rectangle
- 2 draws an inverted rectangle.
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:
- 0 erases the line
- 1 draws a black line
- 2 draws an inverted line
- 7 draws a double line
- 8 draws a line with a vertical shading
- 9 draws a line with a horizontal shading
- 10 draws a line using a negative slope diagonal shading pattern
- 11 draws a line using a positive slope diagonal shading pattern.
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.
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.
mode can take the same values as 'sprite'.
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, and then returns the number of the key. 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, just like CyclePic.
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).
|
font:size
Sets the current font.
size can take the values:
- 0 for the small font (nx5 pixels)
- 1 for the standard font (6x8 pixels)
- 2 for the big font (8x10 pixels).
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 always look nice on 92+.
mode can take the values:
- 0 prints white on black
- 1 prints black
- 2 prints inverted
- 3 prints gray on white.
- 4 prints black on white.
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 {width, top, bottom} that the expression will have when printed with pretty.
In brief, if you print it at (x,y), it will be contained between (x, y+top) and (x+width, y+bottom).
width:size,str
Returns the width, in pixels, of the string str using the font size.
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.
|
*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:
*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:
- 45 -> to return only strings
- 217 -> lists or matrices
- 220 -> programs or functions
- 221 -> data
- 222 -> GDB
- 223 -> pictures
- 224 -> texts
- 225 -> figures
- 226 -> macros
- 243 -> asm programs or libraries
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.
num has to be a number between 0 and 'size(var)-3'.
The argument n is much more powerful and practical to program an editor than getting the bytes one by one, but there will be errors if the string contains unauthorized characters. n has to be less than 4997.
*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.
This function gives you a total control over the variables, but also over the TIOS's stability...
*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:
- 0 : (de)compression successful
- 1 : variable var doesn't exist
- 2 : no compression has been done, the compressed variable would be bigger than the original
- 3 : not enough memory to (de)compress.
*kinfo:var
Returns the original type (see function 'getfile') and size of a KOMP variable. Returns 0 if var is not a KOMP variable.
*group:[n,][var1,var2,...]var
When there is more than one argument, the function groups variables var1, var2, ... in var, whose type will be GRP. If var is already a GRP variable and if there is only one other argument var1, the function adds var1 to the variable var. 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 in GRP variable var.
*mkvar:taille,[type,][extension,]name
Creates a variable named name 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 customized extension (made whith 'mkvar' for example).
Returns nothing if the variable does not have a customized extension.
|