Library Function in QBASIC
A function is a built-in formula or a ready-made program that helps us to perform a certain task such as mathematical, financial, logical, etc. A function manipulates data passes to it and returns either a string or a numeric value. There are two types of functions in QBASIC Programming.
- User-defined function
- Built-in function
User-defined function: It is created by the programmer to perform the operations as per the requirements. It can be a numeric or string function.
Built-in function: It is a pre-defined program which is provided by QBASIC to perform some task easily. It gives many more built-in functions for manipulating strings, numbers. It makes our work easy. It is also known as Library functions.
There are two types of built in function: Numeric (Mathematical) and Built-in (Library) functions
Numeric (Mathematical Functions:
- MOD : It returns reminder, when one number is divide by another number.
- INT : It returns an integer of a given number.
- CINT : It returns nearest rounding numeric value from -32768 to 32767 as argument.
- SQR : It calculate and return the square root of non-negative number
- SGN : It returns the sign of numeric value.
- SIN : It returns the sign value of given number.
- COS : It is used to obtain the cosine value of a number.
- TAN : It returns the tangent of a number.
- ABS : It returns corresponding positive value.
String Functions
- LCASE$ : It converts string values to lowercase.
- UCASE$ : It converts string values to uppercase.
- LEFT$ : It extract and return the numbers of characters from the left of a string.
- RIGHT$ : It extract and return the numbers of characters from the right of a string.
- MID$ : It is used to pick up the required strings from the string.
- LTRIM$ : It is used to remove the spaces from the left of the string.
- RTRIM$ : it is used to remove the spaces from the right of the string.
- VAL : If both strings are started with numeric value. This function can perform mathematical calculations among them.
- ASC : It returns ASCII value of a character.
- CHR$ : It returns character value of given ASCII code.
- STR$ : It converts numeric value to string value, which cannot be used for mathematical calculation.
- SPACE$ : It is used to put blank space.
- TAB : It is used to put Tab.
- DATE$ : It returns the current date.
- TIME$ : It returns the current time.
- LEN : It returns the length of a given string.
- STRING$ : It returns a string of a specified length made up of a repeating character.
- INSTR$ function: It searches for one string inside another and returns the position of first character. General form: INSTR([m,]x$,y$)