Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Copying The Data Environment
Message
From
14/02/1999 12:50:12
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
09/02/1999 22:41:12
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00185481
Message ID:
00187524
Views:
29
>>>Probably you want to copy the whole record, anyway, like:
* The one to get the new DataEnvironment
>>>USE MyForm1.scx
>>>* The one with the DataEnvironment you want in both
>>>USE MyForm2.scx IN 0
>>>* Get the right record (should be record # 2)
>>>LOCATE FOR [base]class="dataenvironment"
>>>FOR FldNum = 1 TO FCOUNT()
>>>	REPLACE ( FIELD(m.FldNum) ) WITH ("MyForm2." + FIELD(m.FldNum) )
>>>ENDFOR
>>>USE IN MyForm2
>>>USE IN MyForm1
HTH,
>>
>>P.S. - would a DELETE MyForm1's record then APPEND it from MyForm2 work? Or will Form Designer crash if you open a form and the DataEnvironment record isn't record # 2?
>>
>>Thanks,
>
>Whoa- wait a minute here guys. The above will surely replace one form's dataenvironment object with another form's, but it won't do anything for the cursor objects.
>
>SCX files work like this: Each record represents an object. Each record (except for the form itself) also references a parent object with its Parent property. Since DEs are their own object, and each cursor is its own object, to completely copy a form's DE from one scx to another, you would not only need to copy the DE object, but also each contained cursor.
>
>I don't know this for sure because I haven't tested it, but I would guess that VFP might get a little freaked out if the DE object wasn't the second record in the scx (it always is when VFP writes the scx). Also be careful that the form object is the first object after the last cursor in the DE.

I got an idea - why not write a builder which wouldn't actually build anything, but just create code to reconstruct the DE programmatically, and stuff such code in a method. I've done something like that while I was writing FPD2VFP scx2scx converter, and I've had a snippet which opened tables and set relations. In the converter I ran the snippet, and recorded aused() and relations, created a DE object and added all the cursors and relations to the DE object, and later saved it together with the converted form.

Now we could do this some other way round - we have a form with a DE, which will be lost when we SaveAsClass() - but then we may run this hypothetical builder which could add some code to form's Load, like this
 :
this.addobject("DE","Dataenvironment")
with this.de
   .addobject("cursor1","cursor")
   with .cursor1
      .property=whatever....
    endwith
   < and so on for all the cursors and relations  >
endwith
So, when the form which is saved as class is later CreateObject()ed, it will have its DE.

Note that I'm not volunteering for the task, I use SCXes :)

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform