1. John Fauss
  2. PowerBuilder
  3. Friday, 24 April 2020 21:51 PM UTC

The Object Browser window in the IDE contains a tab named "Enumerated" that lists all of the enumerated types supported by the PB version. As PB evolves, this list grows (2019 R2 contains 9 enumerated types not available in PB 2017 R2, for example).

I've created a PBNI extension DLL that contains functions for listing the item names and/or numeric values for any enumerated type, to assist me when I am dynamically coding DataWindow syntax, for example, but I would also like to be able to obtain a list of all of enumerated types...like the Object Browser does.

Does anyone know of a way to do this, other than entering all of the names by hand?

John

Michael Kramer Accepted Answer Pending Moderation
  1. Saturday, 25 April 2020 21:35 PM UTC
  2. PowerBuilder
  3. # 1

To obtain details on specific ENUM type you have PB reflection.

string function of_TestAnyEnum(string as_enumType)
   TypeDefinition metaType
   EnumerationDefinition enumType
   EnumerationItemDefinition enumItem
   long i
   string text

   metaType = FindTypeDefinition(as_enumtype)
   if IsNull(metaType) then return "! No such type !"
   if metaType.Category <> EnumeratedType! then return "! Not an enum type !"
   enumType = metaType

   // Actual sort order is reverse alphabetical !
   for i = UpperBound(enumType.Enumeration) to 1 step -1
      enumItem = enumType.Enumeration[i]
      text = enumItem.Name + " :: " + string(enumItem.Value) + "~r~n"
   next
   return text
end function

But your real question is how to get list of available enumerations for specific PB app? (read: which varies by PB release as you point out)

/Michael

Comment
  1. John Fauss
  2. Saturday, 25 April 2020 22:11 PM UTC
Hi, Michael - As you correctly state at the end, my question is how to obtain the list of enumerations supported by the PB version being used (such as SaveAsType, dwItemStatus). I really appreciate the code sample you provided, as it shows how to obtain the enumItem names and values in PB without having to use a PBNI extension. Yet, this was a good exercise to use to learn how to code a PBNI extension. Thank you for responding!
  1. Helpful
  1. Michael Kramer
  2. Sunday, 26 April 2020 14:07 PM UTC
Hi John, Definitely - good choice for a limited scope yet valuable PBNI tiny-project. Easily testable.

What surprised me is item order inside array = EnumerationDefinition.Enumeration. They are "Item.Name desc". I never would have guessed. In any case all enums I tested had min. value = 0. Also they all are defined in PBMVM190.dll (tested in PB 2019R). I wonder whether I can do LibraryDirectory of PBVM190.dll . . .
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Saturday, 25 April 2020 03:00 AM UTC
  2. PowerBuilder
  3. # 2

If it is anything like C/C++, the first value is 0, the next 1, and so on.

 

Comment
  1. John Fauss
  2. Saturday, 25 April 2020 22:00 PM UTC
You are correct, Roland, but this is not what I'm asking. I'm looking for a way to obtain the list of the enumerated types (such as Border, dwItemStatus. dwBuffer & SaveAsType) supported by the current version of PB being used. Once I can validate the name of the enumerated type, I can obtain the list of enumItem Names & Values.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.