Page 1 of 1

New Keywords Low() and High()

Posted: Sat May 17, 2025 10:57 am
by Axolotl
Explanation (why this request)
I use the Enumeration very often.

Code: Select all

Enumeration EWindow 
  #WND_Main 
  #WND_Preview 
  ; ... 
EndEnumeration 

Enumeration EGadget 
  #GDT_btnRefresh 
  #GDT_lstPreview 
  ; ... 
EndEnumeration 
You can also continue the enumeration by naming it. For example In an include file.

Code: Select all

Enumeration EWindow 
  #WND_Editor 
  ; ... 
EndEnumeration 

Enumeration EGadget 
  #GDT_Editor_btnApply 
  #GDT_Editor_edtContent  
  ; ... 
EndEnumeration 
With these new procedures it could be possible to deal with all items.

Code: Select all

Low(<Enumeration>) 
High(<Enumeration>) 

Code: Select all

  ;// sample code 
  For idxWindow = Low(EWindow) To High(EWindow) 
    HideWindow(idxWindow, #True) 
  Next idxWindow 


Maybe there is a small problem with the use of the optional [step]
My work-around so far is like this:

Code: Select all

 
;// add this lines behind the first Enumeration 
Macro Lo_Window : #WND_Main : EndMacro  ; <= my style guide requires #WND_Main as the first Window (Value == 1) 
Macro Hi_Window : #PB_Compiler_EnumerationValue : EndMacro 
;// add this line behind the next Enumerations 
UndefineMacro Hi_Window : Macro Hi_Window : #PB_Compiler_EnumerationValue : EndMacro 

Re: New Keywords Low() and High()

Posted: Sat May 17, 2025 12:47 pm
by Demivec
Axolotl wrote: Sat May 17, 2025 10:57 am Explanation (why this request)
I use the Enumeration very often.
You can also continue the enumeration by naming it. For example In an include file.
Axolotl wrote: Maybe there is a small problem with the use of the optional [step]
Enumerations do not have to be sequential. Besides [step] you can set individual values at any time with [=].

Your idea doesn't sound like new keywords, it sounds like new compiler functions.
They would really be useful with named enumerations. I don't see a real need for them otherwise.

There are possible workarounds but I won't go into those as this isn't the forum for questions on coding. :wink:


@Edit: This posting was edited numerous times before it took its final form (in case you wondered why the message contents changed after you read it).

Re: New Keywords Low() and High()

Posted: Sat May 17, 2025 3:53 pm
by Axolotl
@Demivec. You are right, Keyword is not a proper name for this. On the other hand I would not make any suggestion on implementation.

BTW: I added a work-around already, even if this is not the right place to do so. Because I was not asking for any work-arounds.