How to resolve the algorithm Enumerations step by step in the PureBasic programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Enumerations step by step in the PureBasic programming language

Table of Contents

Problem Statement

Create an enumeration of constants with and without explicit values.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Enumerations step by step in the PureBasic programming language

Source code in the purebasic programming language

Enumeration
   #Apple
   #Banana
   #Cherry
EndEnumeration

Enumeration 10200 Step 12 
  #Constant1           ; 10200
  #Constant2           ; 10212
  #Constant3           ; 10224
  #Constant4 = 10117   ; 10117
  #Constant5           ; 10229
EndEnumeration

Enumeration #PB_Compiler_EnumerationValue
  #Constant_A           ; 10241
  #Constant_B           ; 10242
EndEnumeration

;This starts the enumeration of a named group 'NamedGroup'.
Enumeration NamedGroup 5
  #Green                ; 5
  #Orange               ; 6
EndEnumeration

;EnumerationBinary will use values that are a double of the previous value (or starting value).
EnumerationBinary 
  #North                ; 1
  #West                 ; 2
  #South                ; 4
  #East                 ; 8
EndEnumeration

;This continues the enumeration of the previously named group 'NamedGroup'.
Enumeration NamedGroup
  #Yellow               ; 7
  #Red                  ; 8
EndEnumeration

  

You may also check:How to resolve the algorithm Ackermann function step by step in the Forth programming language
You may also check:How to resolve the algorithm First-class functions step by step in the zkl programming language
You may also check:How to resolve the algorithm Read a file line by line step by step in the Amazing Hopper programming language
You may also check:How to resolve the algorithm Loops/Foreach step by step in the Haskell programming language
You may also check:How to resolve the algorithm Nested function step by step in the Racket programming language