Accessing the highest ENUM value

General FreeBASIC programming questions.
marcov
Posts: 3455
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: Accessing the highest ENUM value

Post by marcov »

fxm wrote:- In many languages, none integer variable is implicitly convertible to a ENUM instance (and reciprocally), this one being strongly typed (declaration equivalent to the ENUM qualified as EXPLICIT with FreeBASIC), and an explicit CAST is required for such a conversion.
In addition, some languages treat enum are with consecutive values (without holes) as true enums, and enums with holes differently (less operations, or simply declare the operations not safe to non consecutive enums)

E.g. Pascal/Delphi only added the enums with holes for Windows header translation purposes, they have no real use in the language.
grindstone
Posts: 862
Joined: May 05, 2015 5:35
Location: Germany

Re: Accessing the highest ENUM value

Post by grindstone »

Correct me, if I'm wrong, but isn't FBs ENUM only a simplified (series of) #DEFINE ?

Isn't

Code: Select all

Enum
	zero
	one
	two
	three
	four
	five
End Enum
the same as

Code: Select all

#Define zero 0
#Define one 1
#Define two 2
#Define three 3
#Define four 4
#Define five 5
?
SARG
Posts: 1756
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Accessing the highest ENUM value

Post by SARG »

Try that :

Code: Select all

#define foo integer
dim as foo test
test=10

enum
foo= integer
end enum

dim as foo test2
test2=10
There is text replacement with define and enum is more a constant.
Post Reply