[SparForte][Banner]
[Top Main Menu] Intro | Tutorials | Reference | Packages | Examples | Contributors   [Back Page]      [Next Page]  

Package Summary

[Ryu and Ken]

AdaScript contains hundreds of built-in constants, variables, functions and procedures. Many of these are grouped into collections called packages.

Built-in 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.

Using Built-in Package Subprograms

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.

Parameter Types

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. SparForte 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 SparForte 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.

 
[Right Submenu]

 Summary

 arrays

 calendar

 cgi

 command_line

 db/ postgresql

 directory_operations

 files

 lock_files

 mysql

 numerics

 os

 pen

 sound

 source_info

 stats

 strings

 System

 text_io

 units

[Back to Top] Back To Top [Small Forte Symbol]