Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare ALL properties - MyForm1.scx MyForm2.scx 1

Status
Not open for further replies.

milosv

Vendor
Nov 6, 2003
27
SI
Hi,
How to display difference between two forms. ALL properties. I try COMPOBJ(), but no work to me.
Any suggestion or maybe FAQ number.
I use VFP 8 and I am BEGGINER in VFP.
Thanks!
Milos
 
Milos,

It's not clear whether you want to compare the properties or the values of the properties.

Either way, you can use AMEMBERS() to get the names of the properties into an array. Do that with both the forms. Then loop through one array; for each element, scan the second array to compare the properties (or their values).

Hope this makes sense.

Mike


Mike Lewis
Edinburgh, Scotland
 
You can spin thru each form to get the objects and save them into a table. Do that for both forms and then run a SQL SELECT with a FULL JOIN. Anything with a match will be on both forms, anything on the left but NULL on the right will have a value in the first form only, and anything with a value on right but a NULL on the left will give you the objects that occur just on the second form.


* basic code for spinning thru objects. You will need to modify it to create the tables and full join SQL.

FOR EACH loTxt IN THISFORM.Objects
IF UPPER(loTxt.baseClass) = "TEXTBOX"
* do nothing - just for demonstration purposes.
ENDIF

* here is where you would add to the table.

lcCmd = "THISFORM." + loTxt.Name + ".VALUE"
MESSAGEBOX(&lcCmd)
ENDFOR



* one final note. I wrote this code in the reply window of tek-tip and have not tested it.

Jim Osieczonek
Delta Business Group, LLC
 
Jim,

Just to amplify on your code, I guess you'd also have to drill down into any container controls on the form. For example, if the form contains a page frame, you'd have to loop through all its pages, then loop through the controls on each page.

Mike


Mike Lewis
Edinburgh, Scotland
 
Jim, Mike,

I agree with both. Think that is for beginner in VFP as am I ,this is to difficult.
Nevertheless thank you! (I will still a little wait...)

Kind regards,
Milos [blush]


 
Mike,
I have two projects with equal (I think!) form. In the first is all OK in second NO. Probably one is a little modified.I can't find a difference.[mad]
I'm thinking that me will this still happen. As beginner I will sure many times use this comparison.

Milos
 
Milos,

A useful trick is to right-click in the property window -- just above the tabs -- and select 'non-default properties only'. This will show you only the properties that you have modified. That should make it easier to see the problem.

Mike


Mike Lewis
Edinburgh, Scotland
 
Mike,
I always use "non default properties only" when comparing two forms. I have "page frame" on these forms. It is very time dilatory. I found a program OBJINSPECTOR.PRG on the internet. Do you think it could help me, and if so, how?? The program is located on
In comlex forms it takes many hours to compare all "properties", so it would make sense to write a program that would output the differnces.
I am waiting to your response.

Kind regards,
Milos [neutral]
 
Hi Milos,

This is a crude utility, use it at your own risk. If this helps I am happy. This is an extract from my form editing tool which I am unable to share openly. So I quickly extracted only some part to make a comparison. Anyway, the form editing tool is getting obsolete after VFP8, which has all the facilities to look up parent codes easily.
********************************************************
**************************************************
** Program : GsEdit.Prg
** Author : Subramanian.G
** Utility to compare two forms.
**************************************************
** PROCEDURE gsEdit

PRIVATE gsANSI, gsSafety, gsExact, gsoForm, gsPEM, gsPEM1, gsPEM2
LOCAL cForm1, cForm2

**************************************************
** Close all tables and display a help message
gsANSI = SET("ANSI")
gsSAFETY = SET("SAFETY")
gsEXACT = SET("EXACT")

SET ANSI ON
SET SAFETY OFF
SET EXACT ON
SET DELETED ON
SET ENGINEBEHAVIOR 70

CLOSE TABLES ALL
**************************************************
** Get the first form
cForm1 = getForm("Select the first form")
IF EMPTY(cForm1)
=MESSAGEBOX("No Form Selected")
RETURN .f.
ENDIF

** Get the second form
cForm2 = getForm("Select the second form")
DO WHILE cForm1 = cForm2
=MESSAGEBOX("The first and second form chosen are the same",0)
cForm2 = getForm("Select the second form")
IF EMPTY(cForm2)
EXIT
ENDIF
ENDDO
IF EMPTY(cForm2)
=MESSAGEBOX("No Form Selected for comparison")
RETURN .f.
ENDIF
**************************************************
** Collect form1 PEMS
MODIFY FORM (cForm1) NOWAIT
IF ASELOBJ(laForm,1) < 1
=MESSAGEBOX(&quot;Cannot open Form One Selected&quot;)
RETURN .f.
ENDIF
gsoForm = laForm(1)
DO gsEdit1 WITH gsoForm
SELECT * FROM gsPEM INTO DBF gsPEM1 ORDER BY 1
CLOSE ALL
**
** Collect form2 PEMS
MODIFY FORM (cForm2) NOWAIT
IF ASELOBJ(laForm,1) < 1
=MESSAGEBOX(&quot;Cannot open Form One Selected&quot;)
RETURN .f.
ENDIF
gsoForm = laForm(1)
DO gsEdit1 WITH gsoForm
SELECT * FROM gsPEM INTO DBF gsPEM2 ORDER BY 1
CLOSE ALL
**************************************************
SELECT a.obj_ref, a.obj_pem, a.obj_val, a.obj_valC, ;
b.obj_val AS obj_val2, b.obj_valC AS obj_valc2, ;
b.obj_ref AS obj_ref2, b.obj_pem AS obj_pem2 ;
FROM gsPEM1 a FULL OUTER JOIN gsPEM2 b ;
ON a.obj_ref+a.obj_pem == b.obj_ref+b.obj_pem ;
ORDER BY a.obj_ref,a.obj_pem, b.obj_ref, b.obj_pem ;
INTO CURSOR gsPem

BROWSE FIELDS Name1 = ALLTRIM(obj_ref)+&quot;.&quot;+ALLTRIM(obj_pem):40, ;
obj_Val:H=&quot;Form1 Value&quot;:R, ;
obj_ValC:H=&quot;Form1 Value&quot;:R, ;
obj_ValC2:H=&quot;Form2 Value&quot;:R, ;
obj_Val2:H=&quot;Form2 Value&quot;:R, ;
Name2 = ALLTRIM(obj_ref2)+&quot;.&quot;+ALLTRIM(obj_pem2):40 ;
FONT &quot;CourierNew&quot;,11 IN SCREEN ;
Title &quot;Objects Comparison Listing&quot; ;
FOR NVL(obj_val,&quot;&quot;) # NVL(obj_val2,&quot;&quot;)
**************************************************
** Cleanup
ERASE gePem1.*
ERASE gePem2.*
**
SET ANSI &gsANSI
SET SAFETY &gsSAFETY
SET EXACT &gsEXACT
RELEASE ALL LIKE gs*
RETURN
**************************************************
** EOP
**************************************************
PROCEDURE gsEdit1
LPARAMETERS gsoForm

** Cursor to hold all the PEMs of objects
CREATE CURSOR gsPEM (obj_ref C(125), obj_pem C(25), ;
obj_type C(15), obj_name M, obj_val M, obj_valC C(15))
SCATTER MEMVAR BLANK

** get the objects PEM in a table
gsoNowObject = gsoForm
gscNowObjectParent = &quot;&quot;
DO getPEMs2

** Create an array to hold the objects temporarily
DIMENSION gsaObject(32500,2)
gsaObject(1,1) = gsoForm
gsaObject(1,2) = gsoForm.Name

** get the sub objects PEM in the same table as above
gsnObject = 1
gsnNextObject = 2
DO WHILE .t.
LOCAL oPage, oColumn, oButton
FOR EACH m.oThis IN gsaObject(gsnObject,1).Controls
gscNowObjectParent = gsaObject(gsnObject,2)+&quot;.&quot;
gsoNowObject = m.oThis
DO getPEMs1
DO CASE
CASE m.oThis.BaseClass == 'Pageframe'
LOCAL oPage
gscNowObjectParent = gsaObject(gsnObject,2)+&quot;.&quot;+oThis.Name+&quot;.&quot;
FOR EACH oPage IN m.oThis.Pages
gsoNowObject = m.oPage
DO getPEMs1
ENDFOR
CASE m.oThis.BaseClass == 'Grid'
LOCAL oColumn
gscNowObjectParent = gsaObject(gsnObject,2)+&quot;.&quot;+oThis.Name+&quot;.&quot;
FOR EACH oColumn IN m.oThis.Columns
gsoNowObject = m.oColumn
DO getPEMs1
ENDFOR
CASE m.oThis.BaseClass $ 'Commandgroup,Optiongroup'
LOCAL oButton
gscNowObjectParent = gsaObject(gsnObject,2)+&quot;.&quot;+oThis.Name+&quot;.&quot;
FOR EACH oButton IN m.oThis.Buttons
gsoNowObject = m.oButton
DO getPEMs1
ENDFOR
ENDCASE
ENDFOR
gsnObject = gsnObject+1
IF gsnObject = gsnNextObject
EXIT
ENDIF
ENDDO
*
RETURN
*********************************************************
PROCEDURE getPEMs1
** obtain contained objects for further probe
DO getPEMs2
LOCAL gscBclass
gscBclass = UPPER(gsoNowObject.BaseClass)
IF gscBclass == &quot;COLUMN&quot; oR gscBclass == &quot;CONTAINER&quot; ;
OR gscBclass == &quot;FORM&quot; OR gscBclass == &quot;PAGE&quot; ;
OR gscBclass == &quot;TOOLBAR&quot; oR gscBclass == &quot;CONTROL&quot;
gsaObject(gsnNextObject,1) = gsoNowObject
gsaObject(gsnNextObject,2) = gscNowObjectParent+gsoNowObject.Name
gsnNextObject = gsnNextObject+1
ENDIF
RETURN
*********************************************************
PROCEDURE getPEMs2
** Get the objects members
=AMEMBERS(gsoArray,gsoNowObject,1,&quot;C&quot;)

** Read the members and get them into a table
FOR gsnCount = 1 TO ALEN(gsoArray,1)
m.obj_ref = gscNowObjectParent+gsoNowObject.Name
m.obj_pem = gsoArray(gsnCount,1)
m.obj_type = gsoArray(gsnCount,2)
m.obj_name = m.obj_ref+&quot;.&quot;+m.obj_pem
** get the event/method code or propety value
DO CASE
CASE UPPER(ALLTRIM(m.obj_type)) = &quot;METHOD&quot;
m.obj_val = GETPEM(gsoNowObject,gsoArray(gsnCount,1))
CASE UPPER(ALLTRIM(m.obj_type)) = &quot;EVENT&quot;
m.obj_val = GETPEM(gsoNowObject,gsoArray(gsnCount,1))
CASE UPPER(ALLTRIM(m.obj_type)) = &quot;PROPERTY&quot;
gsCode = GETPEM(gsoNowObject,gsoArray(gsnCount,1))
IF TYPE(&quot;gsCode&quot;) = &quot;C&quot;
m.obj_val = GETPEM(gsoNowObject,gsoArray(gsnCount,1))
ENDIF
IF TYPE(&quot;gsCode&quot;) $ &quot;N&quot;
m.obj_val = ALLTRIM(STR(GETPEM(gsoNowObject,gsoArray(gsnCount,1))))
ENDIF
IF TYPE(&quot;gsCode&quot;) $ &quot;D&quot;
m.obj_val = DTOC(GETPEM(gsoNowObject,gsoArray(gsnCount,1)))
ENDIF
IF TYPE(&quot;gsCode&quot;) $ &quot;L&quot;
IF gsCode = .t.
m.obj_val = &quot;.t.&quot;
ELSE
m.obj_val = &quot;.f.&quot;
ENDIF
ENDIF
m.obj_valC = m.obj_val
ENDCASE
INSERT INTO gsPEM FROM MEMVAR
ENDFOR
RETURN
*********************************************************
PROCEDURE getform
LPARAMETERS tText
IF PCOUNT() < 1
tText = &quot;Select a Form&quot;
ENDIF
RETURN GETFILE(&quot;SCX&quot;,tText)
*********************************************************
** EOF
*********************************************************





____________________________________________
ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
Ramani,
Exactly this I am want
A star for you.

Milos [smile]
 
HI

You can now have a look in the following for a better version.

A form to compare two different versions of a form.
FAQ184-4512

:)

____________________________________________
ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
Hi ramani.
Very useful function.
I already use it.
I forget RIGHT-CLICK, NON DEFAULT PROPERTIES.
Another star for you.
Thanks again,
Milos :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top