Error, controlling variable of for loop must be a name - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : System : Error Message Guide : controllingvariableforloopmustbename

Error, controlling variable of for loop must be a name

 

Description

Examples

See Also

Description

The for name clause specifies the for loop's control variable. The name may be any expression for which the type(expr, name) command returns a value of true.

 

This error message occurs when the control variable used in the for loop is not of type name, that is, expressions for which the type(expr, name) command returns a value of false.

Examples

Example 1

In this case, the control variable has been omitted.

for  from 6 by 2 to 10 doprintiend do

Error, controlling variable of for loop must be a name

6by2to10doprintiend do


Solution:

The name i has been designated as the control variable.

for i from 6 by 2 to 10 doprintiend do

6

8

10

(2.1)

Example 2

This error occurs because the specified controlling variable is not a name.

total0:

for sinx from 1 to 10 do totaltotal+2 end do:

Error, controlling variable of for loop must be a name

from1to10dototaltotal+2enddo:

type'sinx', 'name'

false

(2.2)


Solution:

Replace sinx with an expression for which type(expr, name) returns true. For example, replacing sinx with x corrects the error.

for x from 1 to 10 do totaltotal+2 end do:

total

20

(2.3)

See Also

for loops,  repetition statements in the programming guide, type/name


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam