Dick,
PMFJI
Code: Select all
FUNCTION CheckOpenChildWindow( sObject AS SYMBOL,lClose AS LOGIC ,lFocus AS LOGIC ,lReturnWindow AS LOGIC) AS USUAL PASCAL
Really?
One function that either closes a window, sets focus or returns a window ?
I don't want to be arrogant, but this is a really bad example.
Have you guys ever heard of "The Single Responsibility Principle".
I would split this in:
FindOpenWindow() -> returns the Window object or NULL_OBJECT
CloseWindow() : uses FindOpenWindow() to find the window and when it is found then it closes the window with EndWindow() and removes it from the array by calling DeleteChildWindow .
Can return TRUE when found and FALSE when not found.
FocusWindow(): uses FindOpenWindow() to find the window and when it is found then it sets the focus to the window.
Can return TRUE when found and FALSE when not found.
And why are you returning the nWindow of the window when you are returning a value and not the object itself ?
Something else:
Your aOpenWindows array keeps growing (based on the code that you have shared)
AddChildWindow() always uses AAdd()
DeleteChildWindow and CheckOpenChildWindow with lClose parameter sets the element to NIL.
After you have opened and closed 100 windows you will have an array of 100 elements with 100 x NIL.
Opening the 101st window adds another element to that array.
I understand that the position in the array is important (because you are returning nWindow
from CheckOpenChildWindow) but normally you would ADel() the element where the object is and
shrink the array with one element ASize(aOpenWindows , ALen(aOpenWindows )-1).
Robert