Home Page | Introduction | Tutorials | Reference | Packages | Hacking |
AdaScript includes the following packages:
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
Parameters to a command have a mode which determine how the parameter is treated:
The built-in Text_IO package, which contains put_line and get_line,
is treated as an inherent part of the language and doesn't use a prefx
of "Text_IO".
Write expression e with an appended line feed (new line) character Example: put_line( 3*2 ); Ada Equivalent: Ada.Text_IO.Put_Line, Ada.Strings.Unbounded.Text_IO.Put_Line, etc. Parameters:
put_line can take any type of parameter except limited types. This includes enumerated types. Output can be redirected to standard error by using standard_error as the file. The default file is standard_output. => put_line( standard_error, "an error occurred!" ); |
Write expression e with optional numeric formatting Example: put( 3*2 ); Ada Equivalent: Ada.Text_IO.Put, Ada.Strings.Unbounded.Text_IO.Put, Ada.Text_IO.Editing Parameters:
put can take any type of parameter except limited types. This includes enumerated types. Output can be redirected to standard error by using standard_error as the file. The default file is standard_output. |
write a line feed (new line) Example: new_line; Ada Equivalent: Ada.Text_IO.New_Line Parameters:
Output can be redirected to standard error by using standard_error as the file. The default file is standard_output. |
read a string until the end of line is encountered. The default file is standard_input. Example: s := get_line; Ada Equivalent: Ada.Text_IO.Get_Line, Ada.Strings.Unbounded.Text_IO Parameters:
|
read the first character from a line on standard input and return it as c Example: get( ch ); Ada Equivalent: Ada.Text_IO.Get_Line, Ada.Strings.Unbounded.Text_IO Parameters:
|
put_line expression e to standard output Restrictions: disabled with pragma ada_95 Example: ? 3*2; Ada Equivalent: none (AdaScript extension taken from BASIC language) Parameters:
The question mark command "?" is a short-form for put_line to standard output. It is intended as a command line convenience. |
Read a character from standard input. Don't write the character. Restrictions: disabled with pragma ada_95 Example: ch := inkey; Ada Equivalent: none (AdaScript extension) Parameters:
get is provided for compatibility for Ada 95 but get is not very convenient. inkey is a more useful function for reading a keypress. |
The file_type constants standard_input, standard_output and standard_error can be used to redirect I/O to standard input, output or error respectively.
Ada's get_immediate is not implemented.
AdaScript's I/O system implements a subsection of the Ada Text_IO library.
The Text_IO package has a predefined enumerated type, file_mode, which determines if a file should be read (in_file), written (out_file) or should append to an existing file (append_file).
Open existing file f as pathname p in file mode m. Example: open( data, in_mode, "/home/ken/data.txt" ); Restrictions: out_mode not allowed in restricted shells Ada Equivalent: Ada.Text_IO.Open Parameters:
|
Create a new file or open an existing file for writing. Also, create temp files. Example: create( temp_file ); Restrictions: out_mode not allowed in restricted shells Ada Equivalent: Ada.Text_IO.Create Parameters:
|
Reopen open file f in optional new file mode m Example: reset( temp_file, in_mode ); Restrictions: out_mode not allowed in restricted shells Ada Equivalent: Ada.Text_IO.Reset Parameters:
|
Return true if file f is open Example: if is_open( data ) then ... Ada Equivalent: Ada.Text_IO.Is_Open Parameters:
|
Return true if all data has been read from in_mode file f Example: if end_of_file( data ) then ... Ada Equivalent: Ada.Text_IO.End_Of_File Parameters:
|
Return true if at the end of line for file f Example: if end_of_line( data ) then ... Ada Equivalent: Ada.Text_IO.End_Of_Line Parameters:
|
Close and save the open file f Example: close( data ); Ada Equivalent: Ada.Text_IO.Close Parameters:
|
Close and delete the open file f Example: delete( temp_file ); Restriction: not allowed in restricted shells Ada Equivalent: Ada.Text_IO.Delete Parameters:
|
Read a line from standard input and discard it Example: s := get_line; Ada Equivalent: Ada.Text_IO.Skip_Line Parameters:
|
Redirect standard_input to an open file Example: set_input( data_file ); Ada Equivalent: Ada.Text_IO.Set_Input Parameters:
Use set_input( standard_input ) to return to standard input. |
Redirect standard_output to an open file Example: set_output( data_file ); Ada Equivalent: Ada.Text_IO.Set_Output Parameters:
Use set_output( standard_output ) to return to standard output. |
Redirect standard_error to an open file Example: set_error( data_file ); Ada Equivalent: Ada.Text_IO.Set_Error Parameters:
Use set_error( standard_error ) to return to standard error. |
Return the number of lines read or written (with put_line, the number of lines explicitly put to that file) Example: if line( f ) > 33 then ... Ada Equivalent: Ada.Text_IO.Line Parameters:
This function will work with standard_input, standard_output and standard_error. However, it does not take into account lines read or written by operating system commands. |
Return the pathname of the open file. Example: put_line( "error in file " & name( f ) ); Ada Equivalent: Ada.Text_IO.Name Parameters:
This function will work with standard_input, standard_output and standard_error. However, it does not return a pathname since these files have no known pathnames. |
Return the mode of the open file Example: if mode( f ) = in_file then ... Ada Equivalent: Ada.Text_IO.Mode Parameters:
|
This function will work with standard_input, standard_output and standard_error.
The Text_IO package also defines three file aliases. These can be used anywhere a file_type variable is expected.
=> f : file_type
=> create( f, out_file, "data.out" )
=> put_line( f, "Added to file" )
=> ? name( f )
data.out
=> ? mode( f )
out_file
=> ? line( f )
1
standard_input, standard_output and standard_error can be redirected with the appropriate command to an open file.
=> set_output( f )
From now on, all output going to standard output is written to the file_type variable f. The current_output function refers to the file being written to (in this case, f). Output redirected to f is not counted by the line function.
The file is closed with close.
=> close( f )
Play a WAV or AU sound file through /dev/dsp. If priority is given, use real-time scheduling to sechedule the playback priority. Example: sound.play( "waterfall.wav" ); Ada Equivalent: none (BUSH extension) Parameters:
|
Play an audio CD in /dev/cdrom (or an alternative CD device if specified). Example: sound.playcd; Ada Equivalent: none (BUSH extension) Parameters:
|
Stop the current audio CD. Example: sound.stopcd; Ada Equivalent: none (BUSH extension) Parameters: none |
GCC Ada equivalent: GNAT.Source_Info
Return the name of the script as identified in a procedure block (if any) Example: put_line( source_info.enclosing_entity ); Ada Equivalent: GNAT.Source_Info.Enclosing_Entity Parameters:
|
Return the name name of the script file, no path information. It is the basename for the script. Example: put_line( source_info.file ); Ada Equivalent: GNAT.Source_Info.File Parameters:
|
Return the line number of the line being currently being executed. Example: put_line( source_info.line ); Ada Equivalent: GNAT.Source_Info.Line Parameters:
|
Return the size of the compiled script Example: put_line( source_info.script_size ); Restrictions: not allowed with pragma Ada_95 Ada Equivalent: none (AdaScript extension) Parameters:
|
Return the filename and current line number separated by a colon Example: put_line( source_info.source_location ); Ada Equivalent: GNAT.Source_Info.Source_Location Parameters:
|
Return the number of symbols (variables, etc.) defined Example: put_line( source_info.symbol_table_size ); Restrictions: not allowed with pragma Ada_95 Ada Equivalent: none (AdaScript extension) Parameters:
|
GCC Ada equivalent: System
=> ? System.Memory_Size
4294967296
GCC Ada Equivalent: numerics combines several Ada.Numerics child packages and type attributes
Predefined numeric constants:
Absolute value (abs) is not technically a part of the numerics package
but is documented here.
return the absolute value of e Example: f := abs( e ); Ada Equivalent: built-in abs function Parameters:
|
trig arcsin function Example: f := arcsin( e ); Ada Equivalent: Ada.Numerics.Generic_Elementary_Functions.arcsin Parameters:
|
trig arcsinh function Example: f := arcsinh( e ); Ada Equivalent: Ada.Numerics.Generic_Elementary_Functions.arcsinh Parameters:
|
trig arctan function Example: f := numerics.arctan( x, y ); Ada Equivalent: Ada.Numerics.Generic_Elementary_Functions.arctan Parameters:
|
trig arctanh function Example: f := arctanh( e ); Ada Equivalent: Ada.Numerics.Generic_Elementary_Functions.arctanh Parameters:
|
trig arccos function Example: f := numerics.arccos( e ); Ada Equivalent: Ada.Numerics.Generic_Elementary_Functions.arccos Parameters:
|
trig arccosh function Example: f := arccosh( e ); Ada Equivalent: Ada.Numerics.Generic_Elementary_Functions.arccosh Parameters:
|
trig arccot function Example: f := numerics.arccot( x, y ); Ada Equivalent: Ada.Numerics.Generic_Elementary_Functions.arccot Parameters:
|
trig arccoth function Example: f := arccoth( e ); Ada Equivalent: Ada.Numerics.Generic_Elementary_Functions.arccoth Parameters:
|
truncate decimal part, round up Example: f := ceiling( 5.5 ); Ada Equivalent: 'ceiling attribute Parameters:
|
return float x with sign of float y Example: f := numerics.copy_sign( 5.5, -1.0 ); Ada Equivalent: 'copy_sign attribute Parameters:
|
trig cosine function Example: f := numerics.cos( numerics.pi ); Ada Equivalent: Ada.Numerics.Generic_Elementary_Functions.cos Parameters:
|
trig cosh functionExample: f := cosh( e ); Ada Equivalent: Ada.Numerics.Generic_Elementary_Functions.cosh Parameters:
|
trig cotangent function Example: f := numerics.cot( numerics.pi ); Ada Equivalent: Ada.Numerics.Generic_Elementary_Functions.cos Parameters:
|
trig coth function Example: f := coth( numerics.pi ); Ada Equivalent: Ada.Numerics.Generic_Elementary_Functions.coth Parameters:
|
even function Example: f := numerics.even( 2 ); -- true Ada Equivalent: N/A ( x mod 2 = 0 ) Parameters:
|
exp function Example: f := exp( 1.0 ); Ada Equivalent: Ada.Numerics.Generic_Elementary_Functions.exp Parameters:
|
Ada's exponent attribute Example: f := numerics.exponent( 10.0 ); -- returns 4 Ada Equivalent: 'exponent attribute Parameters:
|
truncate decimal part, round down Example: f := numerics.floor( 5.5 ); Ada Equivalent: 'floor attribute Parameters:
|
Ada's fraction attribute Example: f := numerics.fraction( 10.0 ); -- returns 0.625 Ada Equivalent: 'fraction attribute Parameters:
|
Ada's leading part attribute (not quite sure what this does) Example: f := numerics.leading_part( x, y ); Ada Equivalent: 'leading_part attribute Parameters:
|
log function Example: f := numerics.log( e ); Ada Equivalent: Ada.Numerics.Generic_Elementary_Functions.log Parameters:
|
Ada's machine attribute (not sure what this does) Example: f := numerics.machine( 10.0 ); -- returns 10.0 Ada Equivalent: 'machine attribute Parameters:
|
return the larger of x and y Example: f := numerics.max( 1.0, 2.0 ); Ada Equivalent: 'max attribute Parameters:
|
return the message digest 5 fingerprint of string s Example: sig := numerics.md5( "Checksum for this message" ); Ada Equivalent: none, uses MD5 package (www.AdaPower.com) Parameters:
|
return the smaller of x and y Example: f := numerics.max( 1.0, 2.0 ); Ada Equivalent: 'min attribute Parameters:
|
odd function Example: f := numerics.odd( 1 ); -- true Ada Equivalent: N/A ( x mod 2 = 1 ) Parameters:
|
return the ASCII value (position) of character c Example: p := numerics.pos( 'a' ); -- returns 97 Ada Equivalent: 'pos attribute Restrictions: pos of enumerated types not supported Parameters:
|
generate a random floating-point number between zero and one Example: i := integer( numerics.truncation( numerics.random * 10 )+1 ) ); -- returns 1 to 10 Ada Equivalent: Ada.Numerics.Float_Random.Random Parameters:
|
generate a random positive number between 1 and p Example: r := numerics.rnd( 10 ); -- 1 to 10 Ada Equivalent: none (BUSH extension) Parameters:
|
rotate expression e up to 64 bits left by natural b bits Example: p := numerics.rotate_left( 16, 2 ); Ada Equivalent: Interfaces.Rotate_Left Parameters:
|
rotate expression e up to 64 bits right by natural b bits Example: f := numerics.rotate_right( 16, 2 ); Ada Equivalent: Interfaces.Rotate_Right Parameters:
|
remainder of a floating point divide of x by y Example: f := numerics.remainder( 16.5, 2.0 ); Ada Equivalent: 'remainder attribute Parameters:
|
truncate decimal part, round to nearest. Round up on .5 Example: f := numerics.rounding( 5.5 ); Ada Equivalent: 'rounding attribute Parameters:
|
multiply floating point number by 2 to the power of integer y Example: f := numerics.scaling( 5.5, 3 ); Ada Equivalent: 'scaling attribute Parameters:
|
return a natural integer, unique to this session. That is, the first invocation returns zero, the second returns one and so forth. The number returns to zero when it exceeds System.Max_Integer. Example: f := numerics.serial; Ada Equivalent: none (BUSH extension) Parameters:
|
shift expression e up to 64 bits left by natural b bits Example: f := numerics.shift_left( 16, 2 ); Ada Equivalent: Interfaces.Shift_Left Parameters:
|
shift expression e up to 64 bits right by natural b bits Example: f := numerics.shift_right( 16, 2 ); Ada Equivalent: Interfaces.Shift_Right Parameters:
|
shift expression e up to 64 bits right by natural b bits, preserving sign Example: f := numerics.shift_right_arithmetic( 16, 2 ); Ada Equivalent: Interfaces.Shift_Right_Arithmetic Parameters:
|
trig sine function Example: f := numerics.sin( numerics.pi ); Ada Equivalent: Ada.Numerics.Generic_Elementary_Functions.sin Parameters:
|
trig sinh function Example: f := numerics.sinh( numerics.pi ); Ada Equivalent: Ada.Numerics.Generic_Elementary_Functions.sinh Parameters:
|
square root of e Example: f := numerics.sqrt( 9.0 ); Ada Equivalent: Ada.Numerics.Generic_Elementary_Functions.sqrt Parameters:
|
Sturge's method: compute a grouping size for data with a low value of l, high value of h, and a sum total of t Example: f := numerics.sturges( 18, 64, 421 ); Ada Equivalent: none (AdaScript extension) Parameters:
|
trig tangent function Example: f := numerics.tan( numerics.pi ); Ada Equivalent: Ada.Numerics.Generic_Elementary_Functions.tan Parameters:
|
trig tanh function Example: f := tanh( e ); Ada Equivalent: Ada.Numerics.Generic_Elementary_Functions.tanh Parameters:
|
truncate decimal part Example: f := numerics.truncation( 5.5 ); Ada Equivalent: 'truncation attribute Parameters:
|
round to nearest even number if exactly between two integers. That is, 5.5 will round up to 6 and 6.5 will round down to 6. Example: f := numerics.unbiased_rounding( 5.5 ); Ada Equivalent: 'unbiased_rounding attribute Parameters:
|
convert string s to a numeric value (inverse of strings.image). If the number is positive, the string must begin with a space or an exception will be raised. Example: f := numerics.value( " 32.5" ) * numerics.value( "-1.2" ); Ada Equivalent: 'value attribute Parameters:
|
GCC Ada equivalent: Ada.Strings.Unbounded, GNAT.Regexp, GNAT.Regpat
Ada implements three different kinds of strings: standard "fixed" strings, bounded strings and unbounded strings. They are implemented in different packages and are incompatible with one another. The standard strings are implemented as arrays and cannot be used in BUSH since AdaScript has no array capabilities. BUSH implements strings as Ada unbounded strings.
For ease of use, string literals (like "hello world") are universal_string types in AdaScript, but are fixed string types in Ada. String literals should properly be converted to an unbounded string using the to_unbounded_string (to_unbounded_string( "hello world" ) even though AdaScript doesn't enforce this.
Likewise unbounded strings should be declared as "unbounded_string" type variables. For ease of use, BUSH uses "string" instead.
When porting a script to Ada, unbounded_string types, to_unbounded_string and to_string functions should be used.
There are 5 enumerated types used by the string functions:
return the occurrences in string s of substring p Example: n := strings.count( "baby", "b" ); -- returns 2 Ada Equivalent: Ada.Strings.Unbounded.Count Parameters:
|
return the natural cth substring of s delimited by character d (typically a comma). Double quotes will escape the delimiter. For use with Comma Separated Value files. Example: s := strings.csv_field( "a/b/c", 2, '/' ); -- returns "b" Ada Equivalent: none (AdaScript extension) Parameters:
|
A bad position returns an empty string (like the Linux/UNIX cut command).
replace the natural fth substring of s delimited by character d (typically a comma) with string t. Double quotes will escape the delimiter. For use with Comma Separated Value files (or ASCII.TAB for tab separated value file). Example: strings.csv_replace( "a/b/c", 2, "x", '/' ); -- now "a/x/c" Ada Equivalent: none (AdaScript extension) Parameters:
|
A bad position returns an empty string (like the Linux/UNIX cut command).
return a string with character positions positive l to natural h deleted Example: r := strings.delete( "bowl", 4, 4 ); -- returns "bow" Ada Equivalent: Ada.Strings.Unbounded.Delete Parameters:
|
A bad position raises an exception.
return the character located at positive position p Example: c := strings.element( "baby", 2 ); -- returns 'a' Ada Equivalent: Ada.Strings.Unbounded.Element Parameters:
|
A bad position raises an exception.
return the natural cth substring of s delimited by character d. This is similar to PERL split. Example: s := strings.field( "a/b/c", 2, '/' ); -- returns "b" Ada Equivalent: none (AdaScript extension) Parameters:
|
A bad position returns an empty string (like the Linux/UNIX cut command).
return true if string globbing expression e Example: b := strings.glob( "app*", "apple" ); -- returns true Ada Equivalent: GNAT.RegPat.Match (Note: Match not Glob) Parameters:
|
Glob characters include:
return the first natural c characters of string s Example: r := strings.head( "minimum", 3 ); -- returns "min" Ada Equivalent: Ada.Strings.Unbounded.Head Parameters:
|
A bad count raises an exception.
true if the string completely contains alphanumeric chararacters (that is, the same as is_letter and is_digit). Example: r := strings.is_alphanumeric( "hello" ); -- returns true Ada Equivalent: none (AdaScript extension). Ada.Character_Handling.Is_Alphanumeric does the equivalent for a single character. Parameters:
|
true if the string completely contains basic Latin-1 letters (A..Z, a..z, AE Diphtong, Icelandic Eth, Icelandic Thorn, German Sharp S). Accented characters are not included. Example: r := strings.basic( "hello" ); -- returns true Ada Equivalent: none (AdaScript extension). Ada.Character_Handling.Is_Basic does the equivalent for a single character. Parameters:
|
true if the string completely contains control chararacters (ASCII/Latin-1 0..31 and 127..159). Example: r := strings.control( "hello" ); -- returns false Ada Equivalent: none (AdaScript extension). Ada.Character_Handling.Is_Control does the equivalent for a single character. Parameters:
|
true if the string completely contains numeric digits (ASCII/Latin-1 48..57). Example: r := strings.is_digit( "1234567890" ); -- returns true Ada Equivalent: none (AdaScript extension). Ada.Character_Handling.Is_Digit does the equivalent for a single character. Parameters:
|
true if the string appears to be a fixed point number (that is, a number with a decimal point). No check is made to see if the number is representable by AdaScript. Example: r := strings.is_fixed( "340.12" ); -- returns true Ada Equivalent: none (AdaScript extension). Parameters:
|
true if the string completely contains printable characters (that is, not is_control). Example: r := strings.is_graphic( "hello" ); -- returns true Ada Equivalent: none (AdaScript extension). Ada.Character_Handling.Is_Graphic does the equivalent for a single character. Parameters:
|
true if the string completely contains hexadecimal numeric characters. Example: r := strings.is_hexadecimal_digit( "FE00" ); -- returns true Ada Equivalent: none (AdaScript extension). Ada.Character_Handling.Is_Hexadecimal_Digit does the equivalent for a single character. Parameters:
|
true if the string completely contains Latin-1 letters (that is, is_basic plus accented characters). Example: r := strings.is_letter( "hello" ); -- returns true Ada Equivalent: none (AdaScript extension). Ada.Character_Handling.Is_Letter does the equivalent for a single character. Parameters:
|
true if the string completely contains Latin-1 lower-case letters. Example: r := strings.is_lower( "hello" ); -- returns true Ada Equivalent: none (AdaScript extension). Ada.Character_Handling.Is_Lower does the equivalent for a single character. Parameters:
|
true if the string appears to be an 8 or 10 character slashed date. No check is made to see if the date is a real date. Example: r := strings.is_slashed_date( "11/22/2003" ); -- returns true Ada Equivalent: none (AdaScript extension). Parameters:
|
true if the string completely contains special printable characters such as punctuation marks (that is, is_graphic and not is_alphanumeric). Example: r := strings.is_special( "!" ); -- returns true Ada Equivalent: none (AdaScript extension). Ada.Character_Handling.Is_Special does the equivalent for a single character. Parameters:
|
true if the string completely contains Latin-1 upper-case letters. Example: r := strings.is_upper( "HELLO" ); -- returns true Ada Equivalent: none (AdaScript extension). Ada.Character_Handling.Is_Upper does the equivalent for a single character. Parameters:
|
convert numeric n to a string (inverse of numerics.value) Example: r := strings.image( 35 ); -- retuns "35" Ada Equivalent: 'image attribute Parameters:
|
Return the first position of substring p in string s. Similar to PERL index and rindex. Example: n := strings.index( "catapult", "tap" ); -- returns 3 Ada Equivalent: Ada.Strings.Unbounded.Index Parameters:
|
return the first non-blank position in string s Example: n := strings.index_non_blank( " moon" ); -- retuns 2 Ada Equivalent: Ada.Strings.Unbounded.Index_Non_Blank Parameters:
|
return a string with substring n inserted before position positive b Example: r := strings.insert( "ale", 2, "pp" ); -- returns "apple" Ada Equivalent: Ada.Strings.Unbounded.Insert Parameters:
|
return the number of characters in the string Example: n := strings.length( "bounce" ); -- retuns 6 Ada Equivalent: Ada.Strings.Unbounded.Length Parameters:
|
s contains pairs of substrings delimited by character d. Return the right-hand substring of the pair beginning with left-hand field t. Example: s := strings.lookup( "a/b/c/d", "c", '/' ); -- returns "d" from pair "c/d" Ada Equivalent: none (AdaScript extension) Parameters:
|
A bad position returns an empty string.
return true if string matches regular expression with PERL extensions. This is similar to PERL m//. Example: b := strings.match( "^app", "apple" ); -- returns true Ada Equivalent: GNAT.RegExp.Match Parameters:
|
Match characters include:
Note: There's a known bug in GNAT 3.12 and 3.13 which causes strings.match
to fail.
make a temporary file name using template p (like UNIX/Linux mktemp command) Example: r := strings.mktemp( "tempXXXXXX" ); Ada Equivalent: none (AdaScript extension) Parameters:
|
return a string with substring n overwriting positions starting at positive p Example: r := strings.overwrite( "goose", 2, "ee" ); -- returns "geese" Ada Equivalent: Ada.Strings.Unbounded.Overwrite Parameters:
|
s contains substrings delimited by character d. Replace the fth substring field with new substring t. Example: strings.replace( s, 2, "*", '/' ); -- if s is "a/b/c", it is now "a/*/c" Ada Equivalent: none (AdaScript extension) Parameters:
|
A bad position returns an empty string.
return a string with positions positive l to natural h replaced by substring n Example: r := strings.replace_slice( "goose", 2, 3, "ee" ); -- returns "geese" Ada Equivalent: Ada.Strings.Unbounded.Replace_Slice Parameters:
|
A bad low position will raise an exception.
return a substring between the positions positive l and natural h Example: r := strings.slice( "realize", 2, 4 ); -- returns "eal" Ada Equivalent: Ada.Strings.Unbounded.Slice Parameters:
|
A bad low position will raise an exception.
split string s into a left substring l and a right substring r at or to the left of character position p. split will attempt to split on the nearest space. Example: strings.split( "hello there", l, r, 9 ); -- l is "hello " and r is "there" Ada Equivalent: none (AdaScript extension) Parameters:
|
A bad position will be constrained to legal values.
return the last natural c characters of string s Example: r := strings.tail( "maximum", 3 ); -- returns "mum" Ada Equivalent: Ada.Strings.Unbounded.Head Parameters:
|
A bad count raises an exception.
convert the string to basic letters (as defined for is_basic). Example: r := strings.to_basic( "hello" ); -- retuns "hello" Ada Equivalent: none (AdaScript extension). Ada.Character_Handling.To_Basic does the equivalent for a single character. Parameters:
|
convert the string to printable character by replacing control characters with "[# n]" where n is the ASCII/Latin-1 position. Example: r := strings.to_escaped( "hello" & ASCII.CR ); -- retuns "hello[# 13]" Ada Equivalent: none (AdaScript extension). Parameters:
|
return the string in lower-case Example: r := strings.to_lower( "bOunce" ); -- retuns "bounce" Ada Equivalent: none (AdaScript extension) Parameters:
|
return the string in proper (or mixed or title) case Example: n := strings.to_proper( "proper" ); -- retuns "Proper" Ada Equivalent: none (AdaScript extension) Parameters:
|
convert unbounded string s to string s Example: s := strings.to_string( some_unbounded_string ); Ada Equivalent: Ada.Strings.Unbounded.To_String Parameters:
|
convert unbounded string s to string s Example: u unbounded_string := strings.to_unbounded_string( "test" ); Ada Equivalent: Ada.Strings.Unbounded.To_Unbounded_String Parameters:
|
return the string in upper-case Example: n := strings.to_upperr( "BoUNCE" ); -- retuns "BOUNCE" Ada Equivalent: none (AdaScript extension) Parameters:
|
remove leading and/or trailing spaces from string s Example: r := strings.trim( " many " ); -- returns "many" Ada Equivalent: none (AdaScript extension) Parameters:
|
return the ASCII character with value n (inverse of numerics.pos) Example: r := strings.val( 65 ); -- returns 'A' Ada Equivalent: 'val attribute Parameters:
|
GCC Ada equivalent: Ada.Command_Line
return the number of script arguments (the same as $#). Exclude BUSH option switches. Example: if command_line.argument_count > 0 then ... Ada Equivalent: Ada.Command_Line.Argument_Count Parameters:
|
return a command line argument (the same as $n where n is a number). The arguments do not include option swithes interpreted by BUSH. Example: put_line( "First argument is " & command_line.argument( 1 ) ); Ada Equivalent: Ada.Command_Line.Argument Parameters:
|
A bad argument number will raise an exception.
return the the name of the script or BUSH interpreter (the same as $0) Example: put_line( command_line.command_name & " is this script" ); Ada Equivalent: Ada.Command_Line.Command_Name Parameters:
|
return the number of variables in the operating system environment. Example: for i in 1..command_line.environment.environment_count loop ... Ada Equivalent: Ada.Command_Line.Environment.Environment_Count Parameters:
|
return an operating system environment value in the form of "VAR=value". Example: put_line( "First value is " & command_line.environment.environment_value( 1 ) ); Ada Equivalent: Ada.Command_Line.Environment.Environment_Value Parameters:
|
A bad environment value number will raise an exception.
set the status code to be returned by the script to the calling program Example: command_line.set_exit_status( 0 ); -- all is well Ada Equivalent: Ada.Command_Line.Set_Exit_Status Parameters:
|
GCC Ada Equivalent: GNAT.Lock_Files
create a lock file named file in optional directory dir. Retry up to retries (natural) times, waiting for wait (duration) seconds between retries. Default for wait/retries in 1.0 second and almost forever. Example: lock_files.lock_file( "test_lock.lck" ); Ada Equivalent: GNAT.Lock_Files.Lock_File Parameters:
|
If the file cannot be locked, BUSH reports an error.
delete the lock file name file in optional directory dir. Example: lock_files.unlock_file( "test_lock.lck" ); Ada Equivalent: GNAT.Lock_Files.Unlock_File Parameters:
|
Using the CGI package, programmers can write scripts that run when invoked by web servers using the Common Gateway Interface (CGI). Bush's large feature set and strong error checking make it ideal for writing web server applications.
The examples directory contains a script called minimal_cgi, a CGI script that displays form variables.
procedure minimal_cgi is -- Demonstrate Bush's CGI interface -- based on AdaCGI's minimal.adb example -- To run this script directly (without a HTTP server), set the -- environment variable REQUEST_METHOD to "GET" and the variable -- QUERY_STRING to either "" or "x=a&y=b". begin cgi.put_cgi_header; cgi.put_html_head( "Minimal Form Demonstration" ); if cgi.input_received then cgi.put_variables; else put_line( "<form method=" & ASCII.Quotation & "POST" & ASCII.Quotation & ">What's your name?<input name=" & ASCII.Quotation & "username" & ASCII.Quotation & "><input type=" & ASCII.Quotation & "submit" & ASCII.Quotation & "></form>" ); end if; cgi.put_html_tail; end minimal_cgi;To run it without a web server, define exported strings QUERY_STRING and REQUEST_METHOD. If there is no information to process (QUERY_STRING is an empty string) it will return a form, otherwise it will display the value of the CGI variables.
=> QUERY_STRING : string := "" => pragma export( shell, QUERY_STRING ) => REQUEST_METHOD : string := "GET" => pragma export( shell, REQUEST_METHOD ) => bush examples/minimal_cgi.bush content_type: text/html <html><head><title>Minimal Form Demonstration</title> </head><body> <form method="POST">What's your name?<input name="username"><input type="submit"></form> </body></html> => QUERY_STRING : string := "x=a&y=b" => bush examples/minimal_cgi.bush content_type: text/html <html><head><title>Minimal Form Demonstration</title> </head><body> <pre> <b>x</b>: <i>a</i> <b>y</b>: <i>b</i> </pre> </body></html>The CGI package uses the standard Ada types except for one additional enumerated type:
True if there were errors parsing. Example: if cgi.parsing_errors then ... Ada Equivalent: CGI.Parsing_Errors Parameters:
|
True if there were CGI variables passed to the script. Example: if cgi.input_received then ... Ada Equivalent: CGI.Input_Received Parameters:
|
True if an "IsIndex" request was made. Example: if cgi.is_index ... Ada Equivalent: CGI.Is_Index Parameters:
|
Identify the CGI standard that was used to communicate with the web server. Example: if cgi.cgi_method = cgi.get then ... Ada Equivalent: CGI.CGI_Method Parameters:
|
Return the value of a CGI variable (a form field). Example: username := cgi.value( "username" ); Ada Equivalent: CGI.Value Parameters:
|
Return true if a CGI variable (a form field) exists. Example: if cgi.key_exists( "credit_card_expiry_date" ) then ... Ada Equivalent: CGI.Key_Exists Parameters:
|
Return the number of times the variable name (or name of a form field) occurs. Example: for k in 1..cgi.key_count( "phone_number" ) loop ... Ada Equivalent: CGI.Key_Count Parameters:
|
Return the total number of variables, including duplicates with the same name. occurs. Example: for k in 1..cgi.argument_count loop ... Ada Equivalent: CGI.Argument_Count Parameters:
|
Return the name of pth CGI variable. Example: first_variable := cgi.key( 1 ); Ada Equivalent: CGI.Key Parameters:
|
Return the value of the pth CGI variable. Example: first_value := cgi.key_value( 1 ); Ada Equivalent: CGI.Value (NOTE: a different name) Parameters:
|
True if a CGI variable v has value s. Example: if cgi.key_value_exists( "country", "US" ) then ... Ada Equivalent: CGI.Key_Value_Exists Parameters:
|
Write the CGI header to current_output, including two carriage returns. This header determines the form of the program's reply (by default, an HTML document). Example: first_value := cgi.key_value( 1 ); Ada Equivalent: CGI.Value (NOTE: a different name) Parameters:
|
Write a simple HTML header to current_output, including a title and optional mailto link to the page author. Example: cgi.put_html_head( "Search results", "itdept@yourorg.com" ) Ada Equivalent: CGI.Put_HTML_Head Parameters:
|
Write a simple HTML <h1> to <h6> heading. Example: cgi.put_html_heading( "OmniCorp Sales Statistics", 1 ) Ada Equivalent: CGI.Value (NOTE: a different name) Parameters:
|
Complete an HTML document by writing " to current_output. Example: cgi.put_html_tail; Ada Equivalent: CGI.Put_HTML_Tail; Parameters: none |
Write a short HTML document containing an error message. Use cgi.put_cgi_header first. Example: cgi.put_error_message( "the disk is full" ) Ada Equivalent: CGI.Put_Error_Message Parameters:
|
Display the CGI variables in HTML format. Use for debugging. Example: cgi.put_variables; Ada Equivalent: CGI.Put_Variables; Parameters: none |
Return the URL of the script. Example: script_url := cgi.my_url; Ada Equivalent: CGI.My_URL Parameters:
|
Count the number of lines is value s, 0 if an empty string. Example: if cgi.line_count( address ) > 4 then ... Ada Equivalent: CGI.Line_Count Parameters:
|
Count the number of lines in the value of variable v, 0 if an empty string. Example: if cgi.line_count_of_value( address ) > 4 then ... Ada Equivalent: CGI.Line_Count_Of_Value Parameters:
|
Return the pth line of string s. Example: second_line := cgi.line( address, 2 ); Ada Equivalent: CGI.Line Parameters:
|
Return the pth line of the value of CGI variable v. Example: second_line := cgi.line( "address", 2 ); Ada Equivalent: CGI.Value_Of_Line Parameters:
|
Decode HTML-encoded %HH hexadecimal characters into their corresponding ASCII characters. If b is true, translate plus signs to spaces. Example: s := cgi.url_decode( encoded_url ); Ada Equivalent: CGI.URL_Decode Parameters:
|
Encode the string using %HH hexadecimal characters. If b is true, translate plus signs to spaces. Example: encoded_url := cgi.url_encode( s ); Ada Equivalent: CGI.URL_Decode Parameters:
|
Encode the string escaping illegal HTML characters. For example, '>' becomes >). Example: safe_html := cgi.html_encode( "This is <illegal> HTML!" ); Ada Equivalent: CGI.HTML_Encode Parameters:
|
Set a cookie's properties. Call this before Put_CGI_Header. Example: cgi.set_cookie( "last_visit", "none" ); Ada Equivalent: CGI.Set_Cookie Parameters:
|
Get the value of pth instance of cookie c. Example: cookie := cgi.cookie_value( "date_visited" ); Ada Equivalent: CGI.Cookie_Value Parameters:
|
Return the number of cookies. Example: for i in 1..cgi.cookie_count loop ... Ada Equivalent: CGI.Cookie_Count Parameters:
|
cgi.get_environment is not implemented: it is already available through the command_line package.
Limited arithmetic: a duration can be added or subtracted from a calendar.time value. "calendar.clock - 1.0" subtracts 1 second from the current time. "calendar.clock + 2.5" adds 2.5 seconds to the current time.
Comparing times: time values can be compared with >, >=, <, <=, =, /=, in, and not in.
Return the current time. Example: current_time := clock; Ada Equivalent: Ada.Calendar.Clock Parameters:
|
Return the year of the given time. Example: the_year := calendar.year( t ); Ada Equivalent: Ada.Calendar.Year Parameters:
|
Return the year of the given time. Example: the_month := calendar.month( t ); Ada Equivalent: Ada.Calendar.Month Parameters:
|
Return the day of the given time. Example: the_year := calendar.day( t ); Ada Equivalent: Ada.Calendar.Day Parameters:
|
Return the seconds of the given time. Example: the_seconds := calendar.seconds( t ); Ada Equivalent: Ada.Calendar.Seconds Parameters:
|
Return the year, month, day and seconds value for the given time. Example: calendar.split( t, year, month, day, secs ); Ada Equivalent: Ada.Calendar.Split Parameters:
|
Create a time from year, month, day and seconds values. Example: the_time := calendar.time_of( 2002, 3, 15, 125.6 ); Ada Equivalent: Ada.Calendar.Time_Of Parameters:
|
=> current_time : calendar.time := calendar.clock => ? calendar.year( current_time ) 2002 => calendar.seconds( current_time ) 8.19477557630540E+04 => return
Converts inches to millimeters. Example: ml := units.inches2mm( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts millimeters to inches. Example: in := units.mm2inches( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts feet to centimeters. Example: cm := units.feet2cm( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts centimeters to feet. Example: ft := units.cm2feet( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts yards to meters. Example: m := units.yards2m( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts meters to yards. Example: yd := units.m2yards( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts miles to kilometers. Example: km := units.miles2km( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts kilometers to miles. Example: mi := units.km2miles( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts lightyears to parsecs. Example: pc := units.ly2pc( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts parsecs to lightyears. Example: ly := units.pc2ly( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts square inches to square centimeters. Example: cm2 := units.sqin2sqcm( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts square centimeters to square inches. Example: in2 := units.sqcm2sqin( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts square feet to square meters. Example: m2 := units.sqft2sqm( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts square meters to square feet. Example: ft2 := units.sqm2sqft( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts square yards to square meters. Example: m2 := units.sqyd2sqm( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts square meters to square yards. Example: yd2 := units.sqm2sqyd( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts acres to metric hectares. Example: h := units.acres2hectares( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts metric hectares to acres. Example: ac := units.hectares2acres( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts square kilometers to square miles. Example: mi2 := units.sqkm2sqmiles( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts square miles to square kilometers. Example: km2 := units.sqmiles2sqkm( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts imperial (British) ounces to grams. Example: g := units.oz2grams( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts grams to imperial (British) ounces. Example: oz := units.grams2oz( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts pounds (weight) to kilograms. Example: kg := units.lb2kg( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts kilograms to pounds (weight). Example: lb := units.kg2lb( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts tons to metric tonnes. Example: mt := units.ton2tonnes( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts metric tonnes to tons. Example: t := units.tonnes2tons( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts imperial (British) fluid ounces to milliliters. Example: ml := units.floz2ml( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts milliliters to imperial (British) fluid ounces. Example: floz := units.ml2floz( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts U.S. fluid ounces to milliliters. Example: ml := units.usfloz2ml( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts milliliters to U.S. fluid ounces. Example: floz := units.ml2usfloz( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts U.S. fluid ounces to imperial (British) fluid ounces. Example: floz := units.usfloz2floz( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts imperial (British) fluid ounces to U.S. fluid ounces. Example: usfloz := units.floz2usfloz( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts imperial (British) pints to metric liters. Example: liters := units.pints2l( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts metric liters to imperial (British) quarts. Example: quarts := units.l2quarts( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts imperial (British) gallons to metric liters. Example: liters := units.gal2l( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts metric liters to imperial (British) gallons. Example: gals := units.l2gal( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts metric cubic centimeters to imperial (British) fluid ounces. Example: floz := units.cucm2floz( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts imperial (British) fluid ounces to cubic centimeters. Example: cm3 := units.floz2cucm( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts metric cubic centimeters to U.S. fluid ounces. Example: floz := units.cucm2usfloz( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts U.S. fluid ounces to cubic centimeters. Example: cm3 := units.usfloz2cucm( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts Fahrenheit temperatures to Celsius. Example: celcius := units.f2c( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts Celcius temperatures to Fahrenheit. Example: fahren := units.c2f( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts Kelvin temperatures to Celsius. Example: celcius := units.k2c( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts Celcius temperatures to Kelvin. Example: kelvin := units.c2k( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts bytes to megabytes. Example: kelvin := units.bytes2mb( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
Converts megabytes to bytes. Example: bytes := units.mb2bytes( 5.5 ); Ada Equivalent: none (BUSH extension) Parameters:
|
GCC Ada Equivalent: array attributes, GNAT sort packages
Bubble sort the array, treating the elements as strings or numbers depending on the element type. Example: arrays.bubble_sort( sales_array ); Ada Equivalent: Uses GNAT.Bubble_Sort. Parameters:
|
Bubble sort the array in descending order, treating the elements as strings or numbers depending on the element type. Example: arrays.bubble_sort_descending( sales_array ); Ada Equivalent: Uses GNAT.Bubble_Sort. Parameters:
|
Return the first (lowest) index of the array. Example: i := arrays.first( sales_array ); Ada Equivalent: 'first attribute Parameters:
|
Heap sort the array, treating the elements as strings or numbers depending on the element type. Example: arrays.heap_sort( sales_array ); Ada Equivalent: Uses GNAT.Heap_Sort. Parameters:
|
Heap sort the array in descending order, treating the elements as strings or numbers depending on the element type. Example: arrays.heap_sort_descending( sales_array ); Ada Equivalent: Uses GNAT.Heap_Sort. Parameters:
|
Return the last (highest) index of the arrays Example: i := arrays.last( sales_array ); Ada Equivalent: 'last attribute Parameters:
|
Return the number of elements in the array (last index - first index + 1). Example: n := arrays.length( sales_array ); Ada Equivalent: 'length attribute Parameters:
|
Reverse the order of the elements in the array, moving the last element to the first position and the first element to the last position. Example: arrays.reverse( backwards_array ); Ada Equivalent: N/A Parameters:
|
Move all elements of the array one element toward the first position, moving the first element to the last position. Example: arrays.rotate_left( work_queue ); Ada Equivalent: N/A Parameters:
|
Move all elements of the array one element toward the last position, moving the last element to the first position. Example: arrays.rotate_right( work_queue ); Ada Equivalent: N/A Parameters:
|
Move all elements of the array one element toward the first element, overwriting the first element. Example: arrays.shift_left( work_stack ); Ada Equivalent: N/A Parameters:
|
Move all elements of the array one element toward the last element, overwriting the last element. Example: arrays.shift_right( work_stack ); Ada Equivalent: N/A Parameters:
|
Randomize the elements of the array. Example: arrays.shuffle( playing_card_array ); Ada Equivalent: N/A Parameters:
|
GCC Ada Equivalent: GNAT.OS_Lib, GNAT.IO_Aux
Return the filename for the path p. Example: b := files.basename( "/tmp/myfile.txt" ); -- returns "myfile.txt" Ada Equivalent: none (AdaScript extension) Parameters:
|
Return the directory portion of the path p. Example: s := files.dirname( "/tmp/myfile.txt" ); -- returns "/tmp" Ada Equivalent: none (AdaScript extension) Parameters:
|
Return true if the file at path p exists. The function works on directories and other special files. Example: b := files.exists( "/tmp/myfile.txt" ); Ada Equivalent: GNAT.IO_Aux.File_Exists Parameters:
|
Return true if the path p is an absolute path. Example: b := files.is_absolute_path( "/tmp/myfile.txt" ); -- returns true Ada Equivalent: GNAT.OS_Lib.Is_Absolute_Path Parameters:
|
Return true if the file at path p exists and is a directory. Example: b := files.is_directory( "/tmp/myfile.txt" ); -- returns false Ada Equivalent: GNAT.OS_Lib.Is_Directory Parameters:
|
Return true if the file at path p exists, is regular and is executable. Example: b := files.is_executable_file( "myscript.bush" ); Ada Equivalent: none (AdaScript extension) Parameters:
|
Return true if the file at path p exists, is regular and is readable. Example: b := files.is_readable_file( "/tmp/myfile.txt" ); Ada Equivalent: none (AdaScript extension) Parameters:
|
Return true if the file at path p exists and is a regular file. Example: b := files.is_regular_file( "/tmp/myfile.txt" ); -- returns true Ada Equivalent: GNAT.IO_Aux.File_Exists (but GNAT doesn't check for regular) Parameters:
|
Return true if the file at path p exists, is regular, is_readable and is not empty. Example: b := files.is_waiting_file( "/tmp/myfile.txt" ); Ada Equivalent: none (AdaScript extension) Parameters:
|
Return true if the file at path p exists, is regular and is writable. Example: b := files.is_writable_file( "/tmp/myfile.txt" ); Ada Equivalent: GNAT.OS_Lib.Is_Writable_File (but GNAT doesn't check for regular) Parameters:
|
Return the time a file was last changed. Example: t := files.last_modified( "/tmp/myfile.txt" ); Ada Equivalent: none (AdaScript extension) Parameters:
|
Return the size of the file at path p in bytes. The function works on directories and other special files. Example: b := files.size( "/tmp/myfile.txt" ); Ada Equivalent: GNAT.OS_Lib.File_Length (without opening file) Parameters:
|
If a file doesn't exist or is not accessible, an error will occur.
There is an enumerated type that controls the verbosity of tracing:
type db.trace_mode_type is ( db.trace_none, db.trace_db, db.trace_apq, db.trace_full );
There is an enumerated type that controls file access:
type db.mode_type is ( db.read, db.write, db.read_write );
There is an enumerated type that controls fetch order:
type db.fetch_mode_type is ( db.sequential_fetch, db.random_fetch );
There is an enumerated type that identifies the database engine:
type db.database_type is ( db.engine_postgresql, db.engine_mysql, db.engine_oracle, db.engine_sybase, db.engine_db2 );
Connect to database d using username u, path p, hostname h and port p. If no hostname or port are specified, connection is made by a UNIX socket instead of a network socket. Example: db.connect( "ken" ); Ada Equivalent: combines several APQ functions Parameters:
|
If a connection cannot be made, an error will occur.
Prepare a SQL statement to execute. If a is included, insert the next statement after the statement named a. Example: db.prepare( "select * from customers" ); Ada Equivalent: APQ.Prepare Parameters:
|
If a connection cannot be made, an error will occur.
Close a connection created by connect. Example: db.disconnect; Ada Equivalent: APQ.Disconnect; Parameters:
|
If a connection doesn't exist, an error will occur.
APQ reset command (not quite sure...). Reset the database connection. Example: db.reset; Ada Equivalent: APQ.Reset; Parameters:
|
If a connection doesn't exist, an error will occur.
True if Bush is connected to a database. Example: b := db.is_connected; Ada Equivalent: APQ.Is_Connected; Parameters:
|
If a connection doesn't exist, an error will occur.
Return the identity of the database engine Example: b := db.engine_of; Ada Equivalent: APQ.Engine_Of Parameters:
|
Last error message returned by database server. Example: err := db.error_message; Ada Equivalent: APQ.Error_Message; Parameters:
|
Last notice message returned by database server. Example: err := db.notice_message; Ada Equivalent: APQ.Notice_Message; Parameters:
|
True if in abort state. Example: b := db.in_abort_state; Ada Equivalent: APQ.In_Abort_State; Parameters:
|
If a connection doesn't exist, a not connected exception will occur.
True if column in the fetch result is undefined. Example: b := db.is_null; Ada Equivalent: APQ.Is_Null Parameters:
|
no_column and no_result exceptions may be raised
Return database options. Example: b := db.options; Ada Equivalent: APQ.Options Parameters:
|
True if set_trace was true (that is, if debug tracing is enabled). Example: b := db.is_trace; Ada Equivalent: APQ.Is_Trace Parameters:
|
Determine if debug tracing is enabled. Example: db.set_trace( false ); Ada Equivalent: APQ.Set_Trace Parameters:
|
True if set_rollback_on_finalize was true (that is, that when the script finishes, a rollback will be issued if the connection is still open). Example: b := db.will_rollback_on_finalize; Ada Equivalent: APQ.Will_Rollback_On_Finalize Parameters:
|
Determine if a rollback will be issued when the script ends and the database connection is still open (true) or no rollback (false). Default is true. Example: db.set_rollback_on_finalize( false ); Ada Equivalent: APQ.Set_Rollback_On_Finalize Parameters:
|
Begin tracing the database activity, storing the results at pathname f. Example: db.open_db_trace( "./trace.out" ); Ada Equivalent: APQ.Open_DB_Trace Parameters:
|
If a connection doesn't exist, an error will occur.
not_connected, file already open, file not found exceptions may be raised
Stop tracing the database activity and close the trace file. Example: db.close_db_trace; Ada Equivalent: APQ.Close_DB_Trace Parameters:
|
If a connection doesn't exist, an error will occur.
Start a database transaction, marking the position of a possible rollback. Example: db.begin_work; Ada Equivalent: APQ.Begin_Work Parameters:
|
in_abort_state exception may be raised
Erase the current query. Example: db.clear; Ada Equivalent: APQ.Clear Parameters:
|
If a connection doesn't exist, an error will occur.
Return the position of a query result column. This is the position in the query, not the database table. Example: third_column_position := db.column_index( "first name" ); Ada Equivalent: APQ.Column_Name Parameters:
|
no_column exception may be raised
Return the name of a query result column. The number is the position in the query, not the database table. Example: third_column_heading := db.column_name( 3 ); Ada Equivalent: APQ.Column_Name Parameters:
|
no_column exception may be raised
Return the number of columns (fields) from the last query. Example: number_of_columns := db.columns; Ada Equivalent: APQ.Columns Parameters:
|
no_result exception may be raised
Complete a database transaction. Example: db.commit_work; Ada Equivalent: APQ.Commit_Work Parameters:
|
in_abort_state exception may be raised
True if there are no more result (tuple) rows. Example: b := db.end_of_query; Ada Equivalent: APQ.End_Of_Query Parameters:
|
Fetch the next query result tuple row, or a specific result row. Example: db.fetch; Ada Equivalent: APQ.Fetch Parameters:
|
no_result or no_tuple exceptions may be raised.
Prepare SQL query s after a (?) Example: db.prepare( "select customer_no from customer" ); Ada Equivalent: APQ.Prepare Parameters:
|
Append text to an SQL query s after a (?) Example: db.append( " where customer_no > 5" ); Ada Equivalent: APQ.Append Parameters:
|
Start a new line and append line to SQL query s Example: db.append_line( "where customer_no > 5" ); Ada Equivalent: APQ.Append_Line Parameters:
|
Append text to SQL query s and surrounded text with single quotes. Example: db.append_quoted( "customer_name" ); Ada Equivalent: APQ.Append_Quoted Parameters:
|
Run a prepared database query. Example: db.execute; Ada Equivalent: APQ.Execute Parameters:
|
If a connection doesn't exist, an error will occur.
not sure the difference with execute. Example: db.execute_checked( "message" ); Ada Equivalent: APQ.Execute_Checked Parameters:
|
True to raise exceptions on query. Example: db.raise_exceptions( false ); Ada Equivalent: APQ.Raise_Exceptions Parameters:
|
True to report errors on query. Example: db.report_errors( false ); Ada Equivalent: APQ.Report_Errors Parameters:
|
Return to the start of a query's results. Example: db.rewind; Ada Equivalent: APQ.Rewind Parameters:
|
Rollback a database transaction, undoing all work since begin_work. Example: db.rollback_work; Ada Equivalent: APQ.Rollback_Work Parameters:
|
in_abort_state exception may be raised
Return the result row (tuple) number from the last fetch. Example: row_number := db.tuple; Ada Equivalent: APQ.Tuple Parameters:
|
no_tuple exception may be raised
Return the number of rows (tuples) from the last query. Example: row_number := db.tuples; Ada Equivalent: APQ.Tuples Parameters:
|
no_result exception may be raised
Return the column value as a string. Example: first_name := db.value( 3 ); Ada Equivalent: APQ.Value Parameters:
|
no_column, no_result, null_value and no_tuple exceptions may be raised
Calculate the average (mean) value of the array. Example: r := stats.average( numbers_collected ); Ada Equivalent: N/A Parameters:
|
Find the maximum (largest) value of the array. Example: r := stats.max( numbers_collected ); Ada Equivalent: N/A Parameters:
|
Find the minimum (smallest) value of the array. Example: r := stats.min( numbers_collected ); Ada Equivalent: N/A Parameters:
|
Calculate the standard deviation of the array elements. Example: r := stats.standard_deviation( numbers_collected ); Ada Equivalent: N/A Parameters:
|
Calculate the total value of the array by adding all elements. Example: r := stats.sum( numbers_collected ); Ada Equivalent: N/A Parameters:
|
Calculate the variance of the array elements. Example: r := stats.variance( numbers_collected ); Ada Equivalent: N/A Parameters:
|
End of Document