Log In | Not a Member? | Support | |
SYNTAX
For name In parameter1 [parameter2]… DESCRIPTION The For… command is a loop control structure that executes the list of commands once for each parameter in the parameter list. Note that as it loops, For… assigns the current parameter to the variable name. This allows you to reference the parameter in your list of commands by using the variable {name}.
Note You can use pipe specification (|), conditional command terminators (&& and ||), and redirection operators (<, >, >>, ≥, ≥≥, ∑, and ∑∑), as long as they appear after End. When used in this manner, these special characters apply to all the commands in the list. INPUT None OUTPUT None STATUS
For… can return the following status codes:
PARAMETERS command1 [command2]… Specifies a list of commands to be executed once for each parameter. name Specifies the name of the variable to which the current parameter is assigned. This allows you to reference the parameter in your list of commands by using the variable {name}. parameter1 [parameter2]… Specifies a list of parameters, one for each iteration of the For… loop. OPTIONS None EXAMPLES In this example, the simple loop
For i In 1 2 3 returns the following:
i = 1 The following example compiles every file in the current directory whose name ends with a ".c" suffix. To do this, the MPW Shell first expands the filename pattern ≈.c, creating a list of the filename parameters. The enclosed commands are then executed once for each parameter in the list. Each time the loop is executed, the variable {File} represents the current parameter in the list. Note that {File} is enclosed in quotation marks in case the expanded filename contains spaces or other special characters.
For File In ≈.c The following example replaces multiple spaces with tabs (Entab) in the four files listed and prints them with headings. The name of each file is echoed after printing is complete.
For file in UserStartup•Mine Suspend Resume Quit You might want to use this set of commands, for instance, before making copies of the files to give to a friend. Putting tabs into the files saves considerable disk space, and printing them gives you some quick documentation to go with the files. SEE ALSO
|