Differences

This shows you the differences between two versions of the page.

Link to this comparison view

ada.command_line [2012/01/14 20:28]
thomaslocke created
ada.command_line [2012/01/14 20:35] (current)
thomaslocke [Introduction]
Line 1: Line 1:
 ===== Introduction ===== ===== Introduction =====
  
-The [[http://​adaic.org/​standards/​05rm/​html/​RM-A-15.html|Ada.Command_Line]] package enables the Ada program to access the command line arguments set by the command that invoked the program. It is the Ada version of the C //argv// and //argc[[n]]// system. ​+The [[http://​adaic.org/​standards/​05rm/​html/​RM-A-15.html|Ada.Command_Line]] package enables the Ada program to access the command line arguments set by the command that invoked the program. It is the Ada version of the C //argv// and //argc[n]// system. ​
  
 If the environment supports it, it is also possible to set the Ada program'​s exit status with //​Ada.Command_Line//​. If the environment supports it, it is also possible to set the Ada program'​s exit status with //​Ada.Command_Line//​.
Line 9: Line 9:
 > If the external execution environment supports passing arguments to a program, then Argument_Count returns the number of arguments passed to the program invoking the function. Otherwise it returns 0. The meaning of “number of arguments” is implementation defined. > If the external execution environment supports passing arguments to a program, then Argument_Count returns the number of arguments passed to the program invoking the function. Otherwise it returns 0. The meaning of “number of arguments” is implementation defined.
  
-Note the closing sentence: **The meaning of “number of arguments” is implementation defined**. What this means, is that you cannot trust a given argument string to yield the same result for all environments. //​Argument_Count//​ is highly dependant on factors such as OS, shell, and compiler.+Note the closing sentence: **The meaning of “number of arguments” is implementation defined**. What this means, is that you cannot trust a given argument string to yield the same result for all environments. //​Argument_Count//​ is highly dependant on factors such as operating system, shell, and compiler.
  
 ===== Using Ada.Command_Line ===== ===== Using Ada.Command_Line =====
Line 138: Line 138:
 If no arguments are given when running the program, you will end up with a //null range// loop: //(1 .. 0)//. This is perfectly valid and the result is as expected: The loop is terminated immediately. If no arguments are given when running the program, you will end up with a //null range// loop: //(1 .. 0)//. This is perfectly valid and the result is as expected: The loop is terminated immediately.
  
-[[Ada.Command_Line.Argument|Example Source]]+[[Ada.Command_Line.Argument Example Source]]
  
 ===== Ada.Command_Line.Command_Name ===== ===== Ada.Command_Line.Command_Name =====
Line 177: Line 177:
 As you can see, in an environment that supports argument passing, the //​Command_Name//​ function returns the exact string used to invoke the program. ​ As you can see, in an environment that supports argument passing, the //​Command_Name//​ function returns the exact string used to invoke the program. ​
  
-[[Ada.Command_Line.Command_Name|Example Source]]+[[Ada.Command_Line.Command_Name Example Source]]
  
 ===== Ada.Command_Line.Set_Exit_Status ===== ===== Ada.Command_Line.Set_Exit_Status =====
Line 226: Line 226:
 //echo $?// outputs the exit code of the most recently executed program. On the first execution, we get a failure because no arguments are given. On the second execution, we get a success because exactly one argument is given. On the third execution, we get the special exit code 3 because more than one argument is given. //echo $?// outputs the exit code of the most recently executed program. On the first execution, we get a failure because no arguments are given. On the second execution, we get a success because exactly one argument is given. On the third execution, we get the special exit code 3 because more than one argument is given.
  
-[[Ada.Command_Line.Set_Exit_Status|Example Source]]+[[Ada.Command_Line.Set_Exit_Status Example Source]]
  

Navigation