Author Topic: Enumerations  (Read 1069 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
Enumerations
« on: June 06, 2018, 10:29:40 AM »
Enumerations are occasionally used to generate series of integer equates. typedef enum is also supported.

Code: [Select]


  '------------
  'ENUMERATIONS
  '============

  'SIMPLE ENUMERATION
  '==================

  enum ManyThings
    shoes
    ships
    sealing_wax
    cabbages
    kings
  end enum

  def show "%1: " %1

  print show cabbages


  'ENUMERATION FROM A BASE VALUE
  '=============================

  enum ManyThings
    shoes=11
    ships
    sealing_wax
    cabbages
    kings
  end enum

  print show ships


  'BITWISE ENUMERATION
  '===================
  '1 2 4 8 16 32 64 ...

  enum bit ManyThings
    shoes
    ships
    sealing_wax
    cabbages
    kings
  end enum


  'ENUMERATION USAGE
  '=================

  'Dim as ManyThings mt
  ManyThings mt
  mt=cabbages
  print mt