PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → [WX] Enumerate Classes in Project
[WX] Enumerate Classes in Project
Débuté par Peter H., 22 juil. 2014 15:25 - 5 réponses
Posté le 22 juillet 2014 - 15:25
Hi,

I'm looking for a method to enumerate the classes that are part of a project but apparently there is no function for that...
EnumElement() doesn't return classes so that's a dead-end street.

Any ideas?

TIA,

Peter H.
Posté le 22 juillet 2014 - 17:22
Hi Peter,

Indeed, this is currently not available. The nearest information you can get is by using the ..Class property on any object created from a class.

But you can probably achieve what you try to do in another way. If you enumerate classes it's probably because you look for something. Make that something come to you instead. This is the way I've solve the same issue (like by using global public constant variables and auto-declaring classes, etc. Very simple, very effective, and many ways to implement it to answer specific needs.)

Best regards,
Alexandre Leclerc
Posté le 22 juillet 2014 - 17:41
Hi Alexandre,

Thanks for the info...

I came to the same conclusion myself in the meantime and have send an enhancement request to PCSoft Tech Support to foresee an EnumElement(enumClass) add-on to the standard WL function.

I'm developing a base framework (for hybrid WD-WB-WM projects) that will generate WLanguage OO Code in an automated way based on input from the user and elements available in the project. For certain patterns, the user needs to provide the base class names (e.g. oOrderHeader + oOrderDetailList) that will make up a combined class (in this case inheriting from a generic soHeaderDetail base class). Providing a list with available project classes is the most user-friendly way to do this. Since I don't need it at runtime (only from within a GO from the project) I might list all .wdc files from the project to get to the same result.

As a side-note, I'm planning on sharing this framework including documentation (via the PCSoft Repository) and a WXLive video session to the community (likely somehwere in August). Afterwards, if some hard-core WX adepts are interested, I would like to open it up (from an internet based HF SCM) to a team of core developers to have it evolve to a generic sort of WX RAD pattern...

Cheers,

Peter H.
Posté le 23 juillet 2014 - 13:55
Peter,

It there already a solution for programming the class file without doing a lot of manual copy & pasting?

Because the generation of code is really nice. But if it takes 10 hours to get everything in place it misses the point.

Pim
Posté le 24 juillet 2014 - 09:40
Hi Pim,

Indeed, this is an issue that renders 10 times faster in the beginning (auto-generation) to 10 times slower (manual creation of the WX object, copy-paste code to it).

I've raised again (done this already a couple of years ago as well) an enhancement request with PCSoft to be able to generate WX objects from either source code files in text format or from structures or objects that reflect such a WX object.

Hopefully something for version X2...

Cheers,

Peter H.
Posté le 24 juillet 2014 - 12:05
Peter H. a écrit :
Hi,

I'm looking for a method to enumerate the classes that are part of a project but apparently there is no function for that...
EnumElement() doesn't return classes so that's a dead-end street.

Any ideas?

TIA,

Peter H.


Hi Peter,
EnumElement doesn't work for classes, so there is three way
1/using wdu file to return classes name
2/you can write them into constant
CONSTANT
CLIENT_CLASS_NAME = "cClient"
PROD_CLASS_NAME = "cPROD"
....
END


3/ If you have a class per table (DB) so you can enumerate all tables and build name of class
// Récupère les fichiers décrits dans l'analyse et par programmation
ListeFichier is string
ListeFichier = HListFile()
sClassName is string
// Ajoute la liste des fichiers dans COMBO_COMBO1
FOR EACH STRING sTable OF ListeFichier
sClassName = "prefix"+sTable
END