formsCount(): Integer;
The formsCount method of the Application class returns the current number of active forms for the application. As this count is dynamic, you should not store it for later use.
The default MDI parent frame is not included in the list of returned forms.
The following example shows the use of the formsCount method to examine all active forms and unload all form instances except for the Menu form.
vars form : Form; indx : Integer; begin indx := app.formsCount; while indx >= 1 do form := app.forms(indx); if form.name <> "Menu" then form.unloadForm; endif; indx := indx - 1; endwhile; end;
If the logic loop results in a form being unloaded, the loop should process the forms in reverse order (as shown in the above example), as the value of formsCount is decreased by 1 after the unload and the forms array is contracted by the removal of the unloaded form.
A value of zero (0) is returned if this method is invoked from a server method.