Difference between revisions of "ObjectType:enumtype"

From Lavish Software Wiki
Jump to navigation Jump to search
 
(3 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
{{ObjectType-Vitals|enum|[[LavishScript]]none|same as Name|enum|no|void *}}
 
{{ObjectType-Vitals|enum|[[LavishScript]]none|same as Name|enum|no|void *}}
  
The enum type provides access to get and set available values for the type. The enum type can then be used directly as a LavishScript Object Type.
+
The enum type provides access to get and set available values for the type of enum. The enum type can then be used directly as a LavishScript Object Type.
  
 
== Members ==
 
== Members ==
 
* [[ObjectType:string|string]] '''Name''': Name of the enum type
 
* [[ObjectType:string|string]] '''Name''': Name of the enum type
* [[DataType:int64|int64]] '''ValueByName['''name''']''': Retrieves a value by its name
+
* [[ObjectType:int64|int64]] '''ValueByName['''name''']''': Retrieves a value by its name
 
* [[ObjectType:string|string]] '''NameByValue['''#''']''': Retrieves a name by a given value (or for flags, a set of names from the combined value)
 
* [[ObjectType:string|string]] '''NameByValue['''#''']''': Retrieves a name by a given value (or for flags, a set of names from the combined value)
  
Line 12: Line 12:
 
*'''SetValue['''name''','''#''']''': Assigns a value to a given name
 
*'''SetValue['''name''','''#''']''': Assigns a value to a given name
 
*'''GetIterator['''iterator''']''': Sets an iterator for iterating the available values
 
*'''GetIterator['''iterator''']''': Sets an iterator for iterating the available values
 +
 +
== Examples ==
 +
; register an "enumbers" enum and object type
 +
LavishScript:RegisterEnum[enumbers]
 +
; set values in the enum
 +
Enum[enumbers]:SetValue[zero,0]
 +
Enum[enumbers]:SetValue[one,1]
 +
Enum[enumbers]:SetValue[two,2]
 +
Enum[enumbers]:SetValue[three,3]
 +
Enum[enumbers]:SetValue[four,4]
 +
Enum[enumbers]:SetValue[five,5]
 +
Enum[enumbers]:SetValue[six,6]
 +
Enum[enumbers]:SetValue[seven,7]
 +
Enum[enumbers]:SetValue[eight,8]
 +
Enum[enumbers]:SetValue[nine,9]
 +
; convert integers to enumbers
 +
echo ${Int[0](enumbers)}
 +
echo ${Int[1](enumbers)}
 +
echo ${Int[2](enumbers)}
 +
echo ${Int[3](enumbers)}
 +
echo ${Int[4](enumbers)}
 +
echo ${Int[5](enumbers)}
 +
echo ${Int[6](enumbers)}
 +
echo ${Int[7](enumbers)}
 +
echo ${Int[8](enumbers)}
 +
echo ${Int[9](enumbers)}
  
 
== See Also ==
 
== See Also ==
* [[LavishScript]]
+
{{LavishScript:ObjectType}}
  
[[Category:LavishScript]]
 
 
[[Category:LavishScript Enums]]
 
[[Category:LavishScript Enums]]

Latest revision as of 16:31, 8 July 2018

Overview

Object Type Vitals
enum
Defined By LavishScriptnone
Inherits same as Name
Reduces To enum
Variable Object Type no
Uses Sub-Types void *
C/C++ Type {{{7}}}

The enum type provides access to get and set available values for the type of enum. The enum type can then be used directly as a LavishScript Object Type.

Members

  • string Name: Name of the enum type
  • int64 ValueByName[name]: Retrieves a value by its name
  • string NameByValue[#]: Retrieves a name by a given value (or for flags, a set of names from the combined value)

Methods

  • SetValue[name,#]: Assigns a value to a given name
  • GetIterator[iterator]: Sets an iterator for iterating the available values

Examples

; register an "enumbers" enum and object type
LavishScript:RegisterEnum[enumbers]
; set values in the enum
Enum[enumbers]:SetValue[zero,0]
Enum[enumbers]:SetValue[one,1]
Enum[enumbers]:SetValue[two,2]
Enum[enumbers]:SetValue[three,3]
Enum[enumbers]:SetValue[four,4]
Enum[enumbers]:SetValue[five,5]
Enum[enumbers]:SetValue[six,6]
Enum[enumbers]:SetValue[seven,7]
Enum[enumbers]:SetValue[eight,8]
Enum[enumbers]:SetValue[nine,9]
; convert integers to enumbers
echo ${Int[0](enumbers)}
echo ${Int[1](enumbers)} 
echo ${Int[2](enumbers)} 
echo ${Int[3](enumbers)} 
echo ${Int[4](enumbers)} 
echo ${Int[5](enumbers)} 
echo ${Int[6](enumbers)} 
echo ${Int[7](enumbers)} 
echo ${Int[8](enumbers)} 
echo ${Int[9](enumbers)} 

See Also

LavishScript Object Types