At 12/15/2001 10:55 PM, you wrote:
Wen-jei,
I am beginner of pascal programing. I have a question about that I can't
use
a numeral as am element of enumerated data type such as "type
items=(1,2,3,4)". You may refer to the attached file to get more
information
You're mixing two different concepts. Enumeration is a series of constants, practically a simpler way to specify a series of constants. This means that the elements of the list have to be identifiers, not numbers like in your "type items = (1,2,3,4)" line.
What you are looking for is a subrange type, an integer whose range of possible values is reduced. You can declare it with the syntax "type items = 1..4".
It depends on your actual requirements whether you need this or not. In your program, you don't. If you step a variable from 4 to 1 with the compiler, you can be sure the value will iterate from 4 to 1 all right, there is no need for additional checking. But even if you need some range checking in other places, you probably don't want to have a hostile runtime error, so using a simple IF and showing your own error message (or correcting the error yourself is it is feasible in the actual situation) could be a much better alternative.
Bye,
Gábor
------------------------------------------------------------------- Gabor DEAK JAHN -- Budapest, Hungary.
E-mail: