>Hi David -
>I think Lewis Carol would have a field day with the way were working here.
>(He refered once to the name of the song, the title of the song and what the song is called - three different things!)
>Anyway, "name" clearly means lots of different things here too.
>Is the name of the scx the name of the form. No!
>When we DO FORM myFormName
>we're talking about the name of the scx. Once instantiated the name of the form can be quite different. (For some peculiar reason my forms are named the same as the SCX with an frm in front)
>I don't really want to reference a form by name, although I often want to know if a form of a given name is running already (and there could be many). I would like to know if you *can* refer to a form by name.
>
>>
>>Inside form methods
always use thisform or this. Outside a form you can use the _screen.Forms[] collection or _screen.ActiveForm or your own forms manager object (but hardcoding a reference to an app object or form manager object can come back to hinder you). If one form is talking to another pass references from one to the other
do form xyz with thisform this let's xyz easily work with any caller form.
>>
>>Coding to a specific form object name restricts you too much especially when dealing with multi-instance forms.
>>
>>>That all makes sense. I was thinking of "forms" at the time. Does that mean we can't or shouldn't refer to a form by name?
Hi David,
At runtime if your form.name is manually coded to be unique then you could use it for forms collection provided you work with single instances. Rather thisform and do .. with this (thisform) is one good way. Also you could have a formcontrol class at app level to control all instances of all forms. By this way you could keep multipl instances of a form(set) and yet control them individualy. Here is a very simple formcontrol example :
oFormManager = createobject("FormControl")
oFormManager.NewInstance("c:\temp\itest.scx")
read events
define class FormControl as Custom
Protected FormInstances[1,2]
procedure NewInstance
lParameters cSCXName
with this
dimension .FormInstances[alen(.FormInstances,1)+1,2]
.FormInstances[alen(.FormInstances,1),1] = cSCXName
.FormInstances[alen(.FormInstances,1),2] = "F"+sys(2015)
cVarname = .FormInstances[alen(.FormInstances,1),2]
public &cVarName
do form (cSCXName) name (cVarName) linked with cVarName
return alen(.FormInstances,1)
endwith
endproc
procedure CascadeInstances
lParameters cSCXName
nLeft = 0
nTop = 0
for ix=1 to alen(this.FormInstances,1)
if Type("this.FormInstances[ix,2]") = "C" ;
and Type(this.FormInstances[ix,2]) = "O" ;
and !isnull(eval(this.FormInstances[ix,2])) ;
and this.FormInstances[ix,1] = cSCXName
with eval(this.FormInstances[ix,2])
.left = nLeft
.Top = nTop
endwith
nLeft = nLeft + 20
nTop = nTop + 20
endif
endfor
endproc
enddefine
Cetin