Having fun with xBasic and the v10 Object Exporer and sub forms
The following 2 questions were sent in by a customer over the weekend
The questions are in blue and replies from Selwyn at Alpha are in black
Question 1:
Can you do me a big favor.
I need a xbasic routine that will:
go thru all open forms
enumerate thru each control on form
and write out all of the properties of each control and its value.
here is how you can do this in a5
dim formList as c
formList = a5.Form_Enum()
formList = sortsubstr(formlist,crlf())
'FOR demonstration purporses, limit to first 5 forms
formList = word(formList,1,crlf(),5)
dim txt as c = ""
dim txt2 as c = ""
for each fm in formList
dim f as p
f = form.load(fm.value)
on error resume next
txt2 = ""
'http://support.alphasoftware.com/alphafivehelpv10/Methods/_OBJECT_.CHILD_ENUM%28%29.htm
'Use the .child_enum() method to list all of the child objects, their properties and each property value.
txt2 = f.Child_Enum("p;r;o=f=v")
'the list is returned in a format that is not as friendly as it could be, so clean it up.
txt2 = stritran(txt2,".f.","__false__")
txt2 = stritran(txt2,".t.","__true__")
txt2 = stritran(txt2,"=.",".")
txt2 = stritran(txt2,"__false__",".f.")
txt2 = stritran(txt2,"__true__",".t.")
txt = txt + crlf(2) + "Form name: " + fm.value + crlf() + replicate("-",100) + crlf(3)
txt = txt + txt2 + crlf()
f.close()
next
showvar(txt)
this will produce a list that looks like this:
Form name: AlphabetButtons@c:\alphasports\customer.ddd
----------------------------------------------------------------------------------------------------
Alphabetbuttons.Code.Iseditable=.f.
Alphabetbuttons.Code.Onfetch=""
Alphabetbuttons.Code.Oninit=""
Alphabetbuttons.Code.Onexit=""
Alphabetbuttons.Code.Canexit=""
Alphabetbuttons.Code.Ontimer=""
Alphabetbuttons.Code.Onsave=""
Alphabetbuttons.Code.Cansave=""
Alphabetbuttons.Code.Canchange=""
Alphabetbuttons.Code.Onenter=""
Alphabetbuttons.Code.Onactivate=""
Alphabetbuttons.Code.Ondeactivate=""
Alphabetbuttons.Code.Onkey=""
Alphabetbuttons.Code.Asksaveenter=""
Alphabetbuttons.Code.Asksavechange=""
Alphabetbuttons.Code.Events=""
Alphabetbuttons.Event.Onfetch=""
Alphabetbuttons.Event.Oninit=""
......
Question 2:
> I have a little problem with xbasic getting references to and from a sub-form
> I just need the syntax for these
>
> Main form (clients) has
> embedded browse (browse1)
> sub-form object name (client_sub)
>
> I need to set colors on a
> field (first_name) that is on the subform
> also the enable attribute
>
> place text to lblStatus that is on the subform
>
if you open the object explorer, it will help you get your syntax correct.
please watch video
http://screencast.com/t/NjFjMDZlNTUt
The following 2 questions were sent in by a customer over the weekend
The questions are in blue and replies from Selwyn at Alpha are in black
Question 1:
Can you do me a big favor.
I need a xbasic routine that will:
go thru all open forms
enumerate thru each control on form
and write out all of the properties of each control and its value.
here is how you can do this in a5
dim formList as c
formList = a5.Form_Enum()
formList = sortsubstr(formlist,crlf())
'FOR demonstration purporses, limit to first 5 forms
formList = word(formList,1,crlf(),5)
dim txt as c = ""
dim txt2 as c = ""
for each fm in formList
dim f as p
f = form.load(fm.value)
on error resume next
txt2 = ""
'http://support.alphasoftware.com/alphafivehelpv10/Methods/_OBJECT_.CHILD_ENUM%28%29.htm
'Use the .child_enum() method to list all of the child objects, their properties and each property value.
txt2 = f.Child_Enum("p;r;o=f=v")
'the list is returned in a format that is not as friendly as it could be, so clean it up.
txt2 = stritran(txt2,".f.","__false__")
txt2 = stritran(txt2,".t.","__true__")
txt2 = stritran(txt2,"=.",".")
txt2 = stritran(txt2,"__false__",".f.")
txt2 = stritran(txt2,"__true__",".t.")
txt = txt + crlf(2) + "Form name: " + fm.value + crlf() + replicate("-",100) + crlf(3)
txt = txt + txt2 + crlf()
f.close()
next
showvar(txt)
this will produce a list that looks like this:
Form name: AlphabetButtons@c:\alphasports\customer.ddd
----------------------------------------------------------------------------------------------------
Alphabetbuttons.Code.Iseditable=.f.
Alphabetbuttons.Code.Onfetch=""
Alphabetbuttons.Code.Oninit=""
Alphabetbuttons.Code.Onexit=""
Alphabetbuttons.Code.Canexit=""
Alphabetbuttons.Code.Ontimer=""
Alphabetbuttons.Code.Onsave=""
Alphabetbuttons.Code.Cansave=""
Alphabetbuttons.Code.Canchange=""
Alphabetbuttons.Code.Onenter=""
Alphabetbuttons.Code.Onactivate=""
Alphabetbuttons.Code.Ondeactivate=""
Alphabetbuttons.Code.Onkey=""
Alphabetbuttons.Code.Asksaveenter=""
Alphabetbuttons.Code.Asksavechange=""
Alphabetbuttons.Code.Events=""
Alphabetbuttons.Event.Onfetch=""
Alphabetbuttons.Event.Oninit=""
......
Question 2:
> I have a little problem with xbasic getting references to and from a sub-form
> I just need the syntax for these
>
> Main form (clients) has
> embedded browse (browse1)
> sub-form object name (client_sub)
>
> I need to set colors on a
> field (first_name) that is on the subform
> also the enable attribute
>
> place text to lblStatus that is on the subform
>
if you open the object explorer, it will help you get your syntax correct.
please watch video
http://screencast.com/t/NjFjMDZlNTUt