using ENUM keyword

Started by Baggey, January 26, 2024, 15:07:53

Previous topic - Next topic

Baggey

Hi, Ive Recently discovered an automatic way of making things = to 1,2,3,4,5 sequentially

BlitzmaxNG has the Command ENUM. The help system reveals nothing :-X

So ive attempted to get some code running
 
  Enum Mirror

Horizontal, Vertical, OneScreen_LO, OneScreen_HI

  End Enum


  Print Mirror.Horizontal   ' should be = 0
  Print Mirror.OneScreen_HI ' should be = 4

I would expect to see Horizontal=0, Vertical=1, OneScreen_LO=2, OneScreen_HI=3.

Maybe with Mirror.OneScreen_LO=2 or Mirror.2="OneScreen_LO" being returned!?

I really am not sure how to use this ENUM? Anyone

Kind Regards Baggey
Running a PC that just Aint fast enough!? i7 Quad core 16GB ram 1TB SSD and NVIDIA Quadro K620 . DID Technology stop! Or have we been assimulated!

ZX Spectrum 48k, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip. Im Misunderstood!

dawlane

Quote from: Baggey on January 26, 2024, 15:07:53Hi, Ive Recently discovered an automatic way of making things = to 1,2,3,4,5 sequentially

BlitzmaxNG has the Command ENUM. The help system reveals nothing :-X

So ive attempted to get some code running
 
  Enum Mirror

Horizontal, Vertical, OneScreen_LO, OneScreen_HI

  End Enum


  Print Mirror.Horizontal   ' should be = 0
  Print Mirror.OneScreen_HI ' should be = 4

I would expect to see Horizontal=0, Vertical=1, OneScreen_LO=2, OneScreen_HI=3.

Maybe with Mirror.OneScreen_LO=2 or Mirror.2="OneScreen_LO" being returned!?

I really am not sure how to use this ENUM? Anyone

Kind Regards Baggey
Have you tried looking here?
You'll find more stuff online than in the actual docs that come with BlitzMax NG.

Baggey

So thankyou @dawlane for the Link

Ive made a Runable piece of code in BlitzmazNG to do what i need for now. Hope someone else who is learning may find this useful  :D

  ' Used blitmax.org to find out how to use

  ' Written by Baggey for anyone to use. Hope you find this helpful. Learning all the time


  ' Here i declare a variable called Mirror so when i reference it i can see what TypeOFmirroring is being used
  ' The mirroring is what Some Computer systems use to fill up the rest of the ROM/RAM with repeating data
 
  ' Setting up an Enumeration lets us reference it as a "string or a value"
  ' This can be float, int, byte etc..
  Enum Mirror:Byte

Horizontal, Vertical, OneScreen_LO, OneScreen_HI

  End Enum

  Print
  ' To retrive the Number value we use the ".ordinal()" method to get it
  Print Mirror.OneScreen_HI.ordinal() ' should be = 3
  Print Mirror.Vertical.ordinal() ' should be = 1

  Print
  ' To find the String value
  Print Mirror.OneScreen_LO.tostring()
  Print Mirror.Horizontal.tostring()

  Print
  ' To find every Array element
  For Local TypeOFmirroring:Mirror = EachIn Mirror.Values()

    Print RSet(TypeOFmirroring.toString(),13) + " = " + TypeOFmirroring.Ordinal()
 
  Next

Kind Regards Baggey
Running a PC that just Aint fast enough!? i7 Quad core 16GB ram 1TB SSD and NVIDIA Quadro K620 . DID Technology stop! Or have we been assimulated!

ZX Spectrum 48k, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip. Im Misunderstood!