X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=doc%2Fflow-control.texi;h=fb2df35291abab9fc193f1acfc5a9d1f472b052a;hb=refs%2Fheads%2Flexer;hp=868143b35a5a0ba8b73c5f628834f9b7a39cc87a;hpb=bd17d2af982332ee1791998361b1ac6731fe14fa;p=pspp diff --git a/doc/flow-control.texi b/doc/flow-control.texi index 868143b35a..fb2df35291 100644 --- a/doc/flow-control.texi +++ b/doc/flow-control.texi @@ -1,3 +1,4 @@ + @node Conditionals and Looping @chapter Conditional and Looping Constructs @cindex conditionals @@ -5,7 +6,7 @@ @cindex flow of control @cindex control flow -This chapter documents PSPP commands used for conditional execution, +This chapter documents @pspp{} commands used for conditional execution, looping, and flow of control. @menu @@ -72,6 +73,7 @@ expansion takes one of the following forms: var_list num_or_range@dots{} 'string'@dots{} + ALL num_or_range takes one of the following forms: number @@ -82,13 +84,11 @@ num_or_range takes one of the following forms: different variables, numbers, or strings into the block with each repetition. -Specify a dummy variable name followed by an equals sign (@samp{=}) and -the list of replacements. Replacements can be a list of variables -(which may be existing variables or new variables or some combination), -numbers, or strings. When new variable names are -specified, @cmd{DO REPEAT} creates them as numeric variables. When numbers -are specified, runs of increasing integers may be indicated as -@code{@var{num1} TO @var{num2}}, so that +Specify a dummy variable name followed by an equals sign (@samp{=}) +and the list of replacements. Replacements can be a list of existing +or new variables, numbers, strings, or @code{ALL} to specify all +existing variables. When numbers are specified, runs of increasing +integers may be indicated as @code{@var{num1} TO @var{num2}}, so that @samp{1 TO 5} is short for @samp{1 2 3 4 5}. Multiple dummy variables can be specified. Each @@ -100,12 +100,24 @@ each dummy variable is substituted; the second time, the second value for each dummy variable is substituted; and so on. Dummy variable substitutions work like macros. They take place -anywhere in a line that the dummy variable name occurs as a token, -including command and subcommand names. For this reason, -words commonly used in command and subcommand names should not be used -as dummy variable identifiers. - -If PRINT is specified on @cmd{END REPEAT}, the commands after substitutions +anywhere in a line that the dummy variable name occurs. This includes +command and subcommand names, so command and subcommand names that +appear in the code block should not be used as dummy variable +identifiers. Dummy variable substitutions do not occur inside quoted +strings, comments, unquoted strings (such as the text on the +@cmd{TITLE} or @cmd{DOCUMENT} command), or inside @cmd{BEGIN +DATA}@dots{}@cmd{END DATA}. + +New variable names used as replacements are not automatically created +as variables, but only if used in the code block in a context that +would create them, e.g.@: on a @cmd{NUMERIC} or @cmd{STRING} command +or on the left side of a @cmd{COMPUTE} assignment. + +Any command may appear within @subcmd{DO REPEAT}, including nested @subcmd{DO REPEAT} +commands. If @cmd{INCLUDE} or @cmd{INSERT} appears within @subcmd{DO REPEAT}, +the substitutions do not apply to the included file. + +If @subcmd{PRINT} is specified on @cmd{END REPEAT}, the commands after substitutions are made are printed to the listing file, prefixed by a plus sign (@samp{+}). @@ -114,31 +126,33 @@ are made are printed to the listing file, prefixed by a plus sign @vindex LOOP @display -LOOP [index_var=start TO end [BY incr]] [IF condition]. +LOOP [@var{index_var}=@var{start} TO @var{end} [BY @var{incr}]] [IF @var{condition}]. @dots{} -END LOOP [IF condition]. +END LOOP [IF @var{condition}]. @end display @cmd{LOOP} iterates a group of commands. A number of termination options are offered. Specify index_var to make that variable count from one value to -another by a particular increment. index_var must be a pre-existing -numeric variable. start, end, and incr are numeric expressions +another by a particular increment. @var{index_var} must be a pre-existing +numeric variable. @var{start}, @var{end}, and @var{incr} are numeric expressions (@pxref{Expressions}.) -During the first iteration, index_var is set to the value of start. -During each successive iteration, index_var is increased by the value of -incr. If end > start, then the loop terminates when index_var > end; -otherwise it terminates when index_var < end. If incr is not specified +During the first iteration, @var{index_var} is set to the value of @var{start}. +During each successive iteration, @var{index_var} is increased by the value of +@var{incr}. If @var{end} > @var{start}, then the loop terminates +when @var{index_var} > @var{end}; +otherwise it terminates when @var{index_var} < @var{end}. If @var{incr} is not specified then it defaults to +1 or -1 as appropriate. -If end > start and incr < 0, or if end < start and incr > 0, then the -loop is never executed. index_var is nevertheless set to the value of +If @var{end} > @var{start} and @var{incr} < 0, or if @var{end} < @var{start} and + @var{incr} > 0, then the +loop is never executed. @var{index_var} is nevertheless set to the value of start. -Modifying index_var within the loop is allowed, but it has no effect on -the value of index_var in the next iteration. +Modifying @var{index_var} within the loop is allowed, but it has no effect on +the value of @var{index_var} in the next iteration. Specify a boolean expression for the condition on @cmd{LOOP} to cause the loop to be executed only if the condition is true. If the @@ -157,7 +171,8 @@ loop, not at the beginning, so that the body of a loop with only a condition on @cmd{END LOOP} will always execute at least once. If neither the index clause nor either condition clause is -present, then the loop is executed MXLOOPS (@pxref{SET}) times. +present, then the loop is executed @var{max_loops} (@pxref{SET}) times. +The default value of @var{max_loops} is 40. @cmd{BREAK} also terminates @cmd{LOOP} execution (@pxref{BREAK}).