The WinDev tutorial describes a component as "a building block that can be re-used in an unlimited number of projects (and in executables)".
WinDev includes a couple of sample projects to illustrate this capability.
The CountryComponent project contains set of procedures which you export as a component. One of these procedures returns a list of countries from a Classic HyperfileSQL table, located in the application directory. The other four procedures return varying kinds of information related to the passed ISO country code (if you're not familiar with ISO country codes you can get more information on the ISO.org web site).
Here's the code for the CountryList procedure:
PROCEDURE CountryList(sSort="NAME",sSeparator=CR,bDetail=False) sList is string sSortItem is string SWITCH sSort CASE "NAME" : sSortItem = "COUNTRY" CASE "CODE" : sSortItem = "ISOCODE" OTHER CASE : Error("The parameter used in CountryList() is false.") RESULT "" END // Browse the countries FOR ALL COUNTRY ON sSortItem IF bDetail THEN sList = sList + COUNTRY.ISOCODE + TAB + COUNTRY.COUNTRY + sSeparator ELSE sList = sList + COUNTRY.COUNTRY + sSeparator END END //Delete the last separator sList = sList[[1 TO Length(sList)-Length(sSeparator)]] RESULT sList
The other procedures are smaller; CountryCurrency is typical:
PROCEDURE CountryCurrency(sIsoCode) HReadSeek(COUNTRY, ISOCODE, sIsoCode) IF NOT HFound() THEN RESULT "BAD" END RESULT COUNTRY.COUNTRYCURRENCY
Exporting any portion of a project as a component is a pretty straightforward wizard-driven process. Choose Workshop | External Component | Define a new component from this project. Give the component a name:
Choose what to include:
Decide which of the elements will be exposed for access by other projects. Since the example app contains only procedures and no windows or other potentially usable elements, only the procedure set is a candidate. Interestingly it's the procedure set that's exported, not individual procedures.
That's basically it for the wizard that defines the component. Now you need to go through another wizard if you want to generate the component. This wizard begins automatically after the first one completes.
The first screen looks eerily familiar:
This is the same as the definition wizard, and it's not clear to me why you'd want a different set (a subset) of elements in the component as compared to what you defined the component to contain. Or something like that.
The next screen is a repeat as well:
There are a couple of screens related to multi-language support, and then this on versioning:
After that there are some prompts for component information, accompanying image, and the like. WinDev also generates some skeleton documentation:
And it can create a help file:
You can decide whether you want to allow user macro code (probably not, unless you're confident it won't be abused), and you choose how to publish the component.
I'd already used the SCM, so that option made sense to me. But what in the world is the Reusability Center? Did I miss something?
And another screen on backups, which I initially found a bit confusing.
I think this is really the same thing as a tag in a version control system. And it seems that there's some French language data left behind by the person who created the example; I believe PaysComposant translates as CountryComponent.
The last step is to give the component files a name:
I deliberately didn't add my component to the SCM because I wanted to find out more about this Reusability Center, but after completing the wizard I got this window:
So I gave in and added the element to the SCM.
But I still wanted to know about this Reusability Center. I found a document online, but the menu option it described (under Tools) didn't exist in my version of WinDev. I ran the nearest analog - something called WDTool. And I got this:
Hmm. Lots of interesting stuff here. On a hunch I tried the Resource Management Center, and Presto! The Reusability Center!
Only I have no idea how to use it.
But I found it!