Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determining if Variable/Object Exists
Message
From
20/07/1998 06:02:11
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
20/07/1998 05:55:46
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00118329
Message ID:
00119200
Views:
22
>>Is there a way to determine if a variable or an object exists in memory?
>>
>>I want to test to see if a form exists before I try to open it again.
>>
>>Any help is appreciated!
>>
>>Jeff
>Jeff,
>Type() is the key as Nancy and Nigel said. With form existence checking this might not be adequate though. Forms as an object might be hard to find, because it's possible you could open many different forms with the same name property (ie:"form1"). Only the .scx differs. You either test .scx name or keep a var ref to form when opening to later test existence.
* do form anyForm name ("oMyForm") linked
>lParameters cFormRefName, cSCXName
>lExistForm = (type(cFormRefName) = "O" ;
>              and !isnull(cFormRefName) ;
>              and eval(cFormName+".baseclass") = "Form")
>if lExistForm
>   &cFormName..show() && Exists show it
>else
>   do form (cSCXName) name (cFormName) linked
>endif
>
>* W/o using name clause of "do form"
>* do form anyForm          && Now scx is anyForm.scx
>lParameters cSCXName
>lExistsForm = .f.
>for each oForm in _Screen.forms && Check in forms collection
<strong>Correction</strong>
>   if sys(1272,oForm) = cSCXName+"."  && Set exact off
<strong>   if sys(1271,oForm) = cSCXName  && Full scx path&name</strong>
>      lExistsForm = .t.  && Found it
>      oForm.show()       && Show and make active
>      exit
>   endif
>endfor
>if !lExistsForm
>   do form (cSCXName)
>endif
The first method has advantage of referring to form at runtime using var ref "Name". ie: "myFormName.left = 12" would let its left property set from anywhere in app or refresh with "myFormName.refresh()"(provided myFormName is alive - cool myFormName is like thisform for that form). And from anywhere you could release that form with "release myFormName" (as reverse when form is released var myFormName is released). Many use these name vars kept in oApp application object, in an array.
>Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform