Business Shell (BUSH) Guide
Author: Ken Burtch

Home Page | Introduction | Tutorials | Reference | Packages | Hacking

Packages
4.1 Using Packages
4.2 text_io (Console I/O)
4.3 text_io (File I/O)
4.4 sound
4.5 source_info
4.6 System
4.7 numerics
4.8 strings
4.9 command_line
4.10 lock_files
4.11 cgi
4.12 calendar
4.13 units
4.14 arrays
4.15 files
4.16 db (Database)
4.17 stats
4.18 pen
4.19 mysql
4.20 os
4.21 directory_operations
| This part of the guide contains detailed descriptions of the BUSH built-in packages. ### 4.1 Using Packages AdaScript contains hundreds of built-in constants, variables, functions and procedures. Many of these are grouped into collections called packages. AdaScript includes the following packages: arrays - contains general array operations calendar - contains time operations cgi - CGI variables and HTML cookie handling command_line - the script name, parameters and return value db - PostgreSQL database interface directory_operations - manage directories files - contains general file and directory operations lock_files - create and destroy lock files mysql - MySQL database interface numerics - contains mathematical functions and constants os - miscellaneous operating system functions pen - graphics, drawing and animation sound - play sounds, music or adjust the system mixer source_info - the script file name and current statistics stats - statistics on numeric arrays strings - contains string operations System - contains information about the computer a script is running units - conversion between common measurements These packages are referenced by name and are described in detail later in this guide. To use a function or constant inside a package, prefix the function with the name of the package. For example, to use the "length" function in the "strings" package, refer to it as "strings.length". `=> ? strings.length( "PegaSoft" )` `8` The built-in Text_IO package is treated as an inherent part of the language and doesn't use a prefx of "Text_IO". This is the only package that doesn't use a package prefix. Parameters to a command have a mode which determine how the parameter is treated: in - the parameter is read only. This is not the same as C/C++/Java's call-by-value because an in parameter is a constant and the value cannot be changed. out - the paramter is write only. BUSH can create a new variable automatically (if this feature has not been disabled by the user). in out - the parameter is read and changed by the command. The variable must exist. This is the same as call-by-reference in languages like C/C++/Java. return value - the type of value returned for functions. #### An Example n := strings.length( s )
return the number of characters in the string Example: n := strings.length( "bounce" ); -- retuns 6 Ada Equivalent: Ada.Strings.Unbounded.Length Parameters:
s | in | universal_string | required | the string to count
n | return value | natural | required | the number of characters
This example uses the description of the strings.length function. Here is how to read the description. "n := strings.length( s )" shows the syntax of the function...often this is all you need to look at to remind yourself of how to use the function. Following this is a summary of what the function does, including an example. If this is a GCC Ada function, the full name of the Ada function appears in the "Ada Equivalent" section. This is to help you move your BUSH scripts to other Ada-based tools and languages. Finally, there is a detailed list of parameters. In the case of strings.length, there is one parameter. It is an "in" parameter and it is required (there is no default value for the parameter). The parameter is a universal_string type (any kind of string variable). strings.length returns a natural value (a zero or positive integer) which is the number of characters in the string. Back to Top