Everybody's made valid points.
Of course, extensive use of PUBLIC should be avoided (that's for you, Monika).
Of course, declaring PUBLIC mem. vars. may open a can of worms (Mike is right).
But if you are discrete and careful enough in using PUBLIC (and that comes with practice), then it can become a real breakthrough when you have to instantiate the same form more than once. That's what I had to do in my last major project. I designed a form to show a document's pages. "Document", BTW, may be a single page in a plain blue-bar GL-like report, or report is a set of statements/letters/etc. But this Data Screen for showing pages is always an instance of the same data Image form, "frmDatIm".
Now, when the page/doc is found in the database and ready to be "exposed" (
![[smile] [smile] [smile]](/data/assets/smilies/smile.gif)
) I do the following:
Code:
lcFrmName = WindowWithDocExists(lcDocAlias) && UDF returns empty str if it doesn't.
IF !EMPTY(lcFrmName)
&lcFrmName..Visible = .T.
&lcFrmName..WindowState = 0
&lcFrmName..ZOrder(0)
&lcFrmName..cmdBar.PageDn.SetFocus
ELSE
lcFrmName = "frmDat_" + lcAppID + "_" + lcDocKey
(Mike! Note how I build the form's instance's name - speaking of naming conventions.)
Code:
lcCommand = "PUBLIC " + lcFrmName
&lcCommand
lcCommand = "DO FORM 'frmDatIm.SCX' NAME " + ;
lcFrmName + ;
" WITH [" + lcDocAlias + "], [" + ;
lcFrmName + ;
"], [" + lcAppID + "], [" + lcDocKey + ;
"], [" + .Name + "], [" + lcSrcValue + "]"
&lcCommand
ENDIF
where lcAppID is the report ("Application"

identifier, lcDocAlias is a recordset (SQL cursor) with the records containing doc's pages, lcSrcValue is the search (criterium) value for highlighting in the displayed page's text, and lcDocKey - well, that's selfexplanatory.
Of course, on the exit from that screen, I have to release that variable-pointer on the form object.
This technique has been working flawlessly for a year now, at many customers'. (Not that I'm trying to show off or pat myself on the back...
![[blush] [blush] [blush]](/data/assets/smilies/blush.gif)
)
So the point is - PUBLIC is OK as long as you keep a watchful eye on them. But PRIVATE - well, I dislike them (to put it mildly) and never use in PRGs.
Regards,
Ilya