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

Command_Line Package

The command_line package provides communication between a script and the calling program. This package sets the exit status and processes command line option switches. command_line contains following routines:

GCC Ada equivalent: Ada.Command_Line


n := command_line.argument_count

return the number of script arguments (the same as $#). Exclude SparForte option switches.
Example: if command_line.argument_count > 0 then ...
Ada Equivalent: Ada.Command_Line.Argument_Count
Parameters:
n return value natural required the argument count


s := command_line.argument( p )

return a command line argument (the same as $n where n is a number). The arguments do not include option swithes interpreted by SparForte.
Example: put_line( "First argument is " & command_line.argument( 1 ) );
Ada Equivalent: Ada.Command_Line.Argument
PHP Equivalent: argv
Parameters:
p in positive required the argument number
s return value string required the value of the argument

A bad argument number will raise an exception.


s := command_line.command_name

return the the name of the script or SparForte interpreter (the same as $0)
Example: put_line( command_line.command_name & " is this script" );
Ada Equivalent: Ada.Command_Line.Command_Name
PHP Equivalent: argv[0]
Parameters:
s return value string required the name of the script or SparForte interpreter


n := command_line.environment.environment_count

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:
n return value natural required the argument count


s := command_line.environment.environment_value( p )

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
PHP Equivalent: $_ENV
Parameters:
p in positive required the argument number
s return value string required the value of the argument

A bad environment value number will raise an exception.


command_line.set_exit_status( n )

set the status code to be returned by the script to the calling program. (To read the exit status, use os.status.)
Example: command_line.set_exit_status( 0 ); -- all is well
Ada Equivalent: Ada.Command_Line.Set_Exit_Status
Parameters:
i in short_short_integer required the status code to return (0 for no error)
 
[Right Submenu]

 Summary

 arrays

 calendar

 cgi

 command_line

 db/ postgresql

 directory_operations

 enums

 files

 lock_files

 mysql

 numerics

 os

 pen

 sound

 source_info

 stats

 strings

 System

 text_io

 units

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