Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Tamar Granor
  Where is Tamar Granor?
 Elkins Park
 Pennsylvania - United States
 Tamar Granor
 To: Ilya Rabyy
  Where is Ilya Rabyy?
 Fountain Valley
 California - United States
 Ilya Rabyy
 Tags
Subject: RE: PUBl Vars Pro&Contra
Thread ID: 141897 Message ID: 142139 # Views: 43 # Ratings: 0
Version: Visual FoxPro 9 Category: General VFP Topics
Date: Tuesday, August 14, 2007 11:07:01 PM         
   


> Back to our muttons: one more scenario where one have to resort to PUBLICs (which I did, out of necessity) is where you have to instantiate the same screen (FORM, if you wish) with different names in the runtime - and you have no idea what data would be presented there in any instance of this form! To imagine that, think of something like PaintShop Pro, Word, or even VFP itself: those programs have no idea what users will do with them except that they will view and edit images in PSP, type some texts in Word and build some tables and/or put together some programs in VFP - that's it! And the key word is "GENERIC"! Now, with generic data retrieving program (good thing was it was archive, and I had not to worry about data entry pieces), you do not know what data and or how many different data applications/sets it is going to be used with, you know only the general outline of the tables' structures; you do not know subsequently, how many times your screen will be instantiated, but you have to give your end user the ability to bring up 2, 3, 5 instances of the same screens (each!) - and trace them in your program! Moreover: one screen instantiates more than one instance of another screen, and they have to interact with each other (and they ain't in parent/child relationship but independent entities). Now, if you have something like the following in, say, FORM.cmdGo.Click event procedure:
>
> IF FOUND("SomeQuery")
>    DO FORM "frmSomeForm.SCX" NAME frmSomeForm WITH SOMEQUERY.KeyFld
> ENDIF (FOUND())

> and, once you out of this procedure you lose any reference to this form you have instantiated here. Worse, even: you implicitly declared frmSomeForm memvar, which would be PRIVATE in scope and, therefore, destroyed one your procedure exits. Worse yet: you will have your instance of the form either eliminated (if it's LINKED) or - worse yet! - left "hung in the thin air"... and I don't have to elaborate any further, now, do I?
> However, if it's something like
>
> IF FOUND("SomeQuery")
>    lcFrmName = [frmDat_] + m.AppID + [_] + SOMEQUERY.DocKey
>    lcCommand = [PUBLIC ] + lcFrmName
>    &lcCommand
>    lcCommand = [DO FORM "frmData.SCX" NAME ] + lcFrmName + WITH SOMEQUERY.DocKey
>    &lcCommand
> ENDIF (FOUND())

> and you have your screen and solid reference onto it for the duration of the program or until your end user closes this screen.
>
> Another workaround would be saving the references on those instances in some temp cursor, but then again: the scope of the variable form-name is critical. This is where use of PUBLICs is justified.
>
> Sorry for the lengthy post, but I know how difficult it is for a database programmer to imagine a data-manipulating program that is 99% generic and data-independent.
>

Sorry, Ilya, but I don't see any reason to use public variables for that. A form manager object will handle the problem neatly. You instantiate forms and save a reference to the form in a collection of such references (or, pre-VFP 8, in an array) that is a member of the form manager object.

Tamar

COMPLETE THREAD

PUBl Vars Pro&Contra Posted by Thomas Bähr @ 8/13/2007 12:08:05 PM
RE: PUBl Vars Pro&Contra Posted by Andy Kramek @ 8/13/2007 12:14:19 PM
RE: PUBl Vars Pro&Contra Posted by Thomas Bähr @ 8/13/2007 12:57:40 PM
RE: PUBl Vars Pro&Contra Posted by Andy Kramek @ 8/13/2007 2:32:12 PM
RE: PUBl Vars Pro&Contra Posted by Thomas Bähr @ 8/13/2007 3:11:49 PM
RE: PUBl Vars Pro&Contra Posted by Andy Kramek @ 8/13/2007 7:56:45 PM
RE: PUBl Vars Pro&Contra Posted by Thomas Bähr @ 8/14/2007 11:44:08 AM
RE: PUBl Vars Pro&Contra Posted by Andy Kramek @ 8/14/2007 12:45:58 PM
RE: PUBl Vars Pro&Contra Posted by Thomas Bähr @ 8/14/2007 3:29:09 PM
RE: PUBl Vars Pro&Contra Posted by Tamar Granor @ 8/14/2007 11:01:24 PM
RE: PUBl Vars Pro&Contra Posted by Don Higgins @ 8/14/2007 6:08:45 PM
RE: PUBl Vars Pro&Contra Posted by Borislav Borissov @ 8/13/2007 8:06:04 PM
RE: PUBl Vars Pro&Contra Posted by Thomas Bähr @ 8/14/2007 11:29:35 AM
RE: PUBl Vars Pro&Contra Posted by Borislav Borissov @ 8/14/2007 11:52:47 AM
RE: PUBl Vars Pro&Contra Posted by Thomas Bähr @ 8/14/2007 3:32:44 PM
RE: PUBl Vars Pro&Contra Posted by Mike Yearwood @ 8/13/2007 8:47:49 PM
RE: PUBl Vars Pro&Contra Posted by Thomas Bähr @ 8/14/2007 11:33:59 AM
RE: PUBl Vars Pro&Contra Posted by Hugo Ranea @ 8/14/2007 7:16:32 PM
RE: PUBl Vars Pro&Contra Posted by Ilya Rabyy @ 8/13/2007 9:24:07 PM
RE: PUBl Vars Pro&Contra Posted by Andy Kramek @ 8/14/2007 1:56:56 PM
RE: PUBl Vars Pro&Contra Posted by Thomas Bähr @ 8/14/2007 3:53:24 PM
RE: PUBl Vars Pro&Contra Posted by Pamela Thalacker @ 8/14/2007 5:10:35 PM
RE: PUBl Vars Pro&Contra Posted by Mike Yearwood @ 8/14/2007 5:23:21 PM
RE: PUBl Vars Pro&Contra Posted by Pamela Thalacker @ 8/14/2007 5:50:03 PM
RE: PUBl Vars Pro&Contra Posted by Mike Yearwood @ 8/14/2007 6:33:05 PM
RE: PUBl Vars Pro&Contra Posted by Pamela Thalacker @ 8/14/2007 9:30:16 PM
RE: PUBl Vars Pro&Contra Posted by Mike Yearwood @ 8/14/2007 11:13:19 PM
RE: PUBl Vars Pro&Contra Posted by Mike Yearwood @ 8/14/2007 5:33:08 PM
RE: PUBl Vars Pro&Contra Posted by Ilya Rabyy @ 8/14/2007 5:51:13 PM
RE: PUBl Vars Pro&Contra Posted by Thomas Bähr @ 8/14/2007 9:10:42 PM
RE: PUBl Vars Pro&Contra Posted by Ilya Rabyy @ 8/14/2007 9:23:26 PM
RE: PUBl Vars Pro&Contra Posted by Andy Kramek @ 8/14/2007 9:03:19 PM
RE: PUBl Vars Pro&Contra Posted by Thomas Bähr @ 8/14/2007 9:08:02 PM
RE: PUBl Vars Pro&Contra Posted by Andy Kramek @ 8/14/2007 8:04:15 PM
RE: PUBl Vars Pro&Contra Posted by Andy Kramek @ 8/14/2007 8:21:41 PM
RE: PUBl Vars Pro&Contra Posted by Thomas Bähr @ 8/14/2007 9:00:41 PM
RE: PUBl Vars Pro&Contra Posted by Andy Kramek @ 8/14/2007 11:17:07 PM
RE: PUBl Vars Pro&Contra Posted by Ilya Rabyy @ 8/14/2007 5:42:39 PM
RE: PUBl Vars Pro&Contra Posted by Mike Yearwood @ 8/14/2007 6:36:33 PM
RE: PUBl Vars Pro&Contra Posted by Hugo Ranea @ 8/14/2007 7:28:15 PM
RE: PUBl Vars Pro&Contra Posted by Mike Yearwood @ 8/14/2007 7:57:11 PM
RE: PUBl Vars Pro&Contra Posted by Ilya Rabyy @ 8/14/2007 7:46:56 PM
RE: PUBl Vars Pro&Contra Posted by Mike Yearwood @ 8/14/2007 8:11:04 PM
RE: PUBl Vars Pro&Contra Posted by Ilya Rabyy @ 8/14/2007 8:31:23 PM
RE: PUBl Vars Pro&Contra Posted by Mike Yearwood @ 8/14/2007 8:37:53 PM
RE: PUBl Vars Pro&Contra Posted by Tamar Granor @ 8/14/2007 11:10:39 PM
RE: PUBl Vars Pro&Contra Posted by Andy Kramek @ 8/14/2007 8:00:32 PM
RE: PUBl Vars Pro&Contra Posted by Thomas Bähr @ 8/14/2007 9:05:56 PM
RE: PUBl Vars Pro&Contra Posted by Ilya Rabyy @ 8/14/2007 9:32:30 PM
RE: PUBl Vars Pro&Contra Posted by Mike Yearwood @ 8/14/2007 11:40:11 PM
RE: PUBl Vars Pro&Contra Posted by Ilya Rabyy @ 8/15/2007 5:29:29 PM
RE: PUBl Vars Pro&Contra Posted by Mike Yearwood @ 8/15/2007 8:36:16 PM
RE: PUBl Vars Pro&Contra Posted by Ilya Rabyy @ 8/16/2007 12:26:42 AM
RE: PUBl Vars Pro&Contra Posted by Mike Yearwood @ 8/16/2007 3:01:29 AM
RE: PUBl Vars Pro&Contra Posted by Ilya Rabyy @ 8/17/2007 5:12:06 PM
RE: PUBl Vars Pro&Contra Posted by Tamar Granor @ 8/14/2007 11:07:01 PM
RE: PUBl Vars Pro&Contra Posted by Tamar Granor @ 8/14/2007 10:58:35 PM
RE: PUBl Vars Pro&Contra Posted by Ilya Rabyy @ 8/15/2007 5:09:16 PM
RE: PUBl Vars Pro&Contra Posted by Vincent Byrne @ 8/14/2007 9:55:05 PM
RE: PUBl Vars Pro&Contra Posted by Andy Kramek @ 8/14/2007 11:17:48 PM
RE: PUBl Vars Pro&Contra Posted by Vincent Byrne @ 8/15/2007 8:10:06 PM
RE: PUBl Vars Pro&Contra Posted by Thomas Bähr @ 8/15/2007 10:50:53 AM