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.
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 )
The main difference between a socket and a file is that sockets are always "in" and "out". When opening a socket, do not specify a mode.
The name of the socket is a string containing the name of the server computer, followed by a colon and a port number. The port number is 80 (a web server) if no port is specified. Certain ports, such as those above 32767, are prohibited as a security precaution.
#!/bin/bush
-- download a web page
f : socket_type;
c : character;
open( f, "www.somewebserver.com" );
put( f, "GET /index.html HTTP/1.0" & ASCII.CR & ASCII.LF
);
put( f, "User-Agent: BUSHTest/1.0 (BUSHTest)" & ASCII.CR &
ASCII.LF );
put( f, ASCII.CR & ASCII.LF );
loop
get( f, c );
put( c );
exit when end_of_file( f );
end loop;
put_line( "End of web page" );
close( f );
The picture string may include:
=> put( 12.34, "***9.99" ) ; new_line
**12.34
=> put( 12.34, "###9.99" ) ; new_line
$12.34
=> put( 12.34, "+###9.99" ) ; new_line
+ $12.34
=> put( 12.34, "-###9.99" ) ; new_line
$12.34
=> put( 12.34, "<###9.99>" ) ; new_line
$12.34
=> put( -12.34, "<###9.99>" ) ; new_line
( $12.34)
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:
|
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:
|
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:
|
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:
|
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:
|
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.
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 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 delimited by character d 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 Example: r := strings.head( "minimum", 3 ); -- returns "min" Ada Equivalent: Ada.Strings.Unbounded.Head Parameters:
|
A bad count raises an exception.
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 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:
|
return true if string matches regular expression with PERL extensions e 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:
|
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.
return the last natural c characters Example: r := strings.tail( "maximum", 3 ); -- returns "mum" Ada Equivalent: Ada.Strings.Unbounded.Head Parameters:
|
A bad count raises an exception.
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:
|
remove leading and 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.
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:
|
End of Document