Error: ... value in for loop must be numeric or character

increment of for loop must be numeric

increment when looping over characters must be an integer

final value in for loop must have same type as initial

There are three allowed types of for statement.

These error messages arise when the expression in a from or to part of a for statement does not result in a value of type numeric or a character (a string of length 1). The allowed numeric values are integers, fractions and floats. If the actual value is a real constant but not an integer, fraction or float, you could use evalf to make it into a float.

Examples:

> for i from a to 3 do print(i) od;

Error, initial value in for loop must be numeric or character

> for i from 1 to sqrt(10) do print(i) od;

Error, final value in for loop must be numeric or character

> for i from 1 to evalf(sqrt(3)) by sqrt(2) do print(i) od;

Error, increment of for loop must be numeric

> for i from evalf(sqrt(2)) to evalf(sqrt(10)) by evalf(sqrt(3)) do print(i)
od;

1.414213562

3.146264370

> for i from "a" to "z" by 1/2 do print(i) od;

Error, increment when looping over characters must be an integer

> for i from 1 to "d" do print(i) od;

Error, final value in for loop must have same type as initial

> for i in F(a,b,c) do print(i) od;

a

b

c

See also: for , evalf , numeric

Maple Advisor Database R. Israel, 1997