enum.monkey2 538 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. Namespace test
  2. #Reflect test
  3. Enum E
  4. A,B,C
  5. End
  6. Global G:E
  7. Function Main()
  8. Print Typeof<E>
  9. Local e:=E.A
  10. Print Typeof( e )
  11. Local type:=Typeof( e )
  12. For Local decl:=Eachin type.GetDecls()
  13. Local e:=decl.Get( Null )
  14. Print decl.Name+"="+e.EnumValue
  15. Next
  16. Local g:=TypeInfo.GetType( "test" ).GetDecl( "G" )
  17. 'one way To set an enum...
  18. g.Set( Null,type.MakeEnum( E.A ) )
  19. Print g.Get( Null ).EnumValue
  20. 'another way to set an enum...!
  21. g.Set( Null,type.MakeEnum( 2 ) )
  22. Print g.Get( Null ).EnumValue
  23. End