Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What is the easiest way to duplicate a class in a VCX
Message
De
12/12/2008 10:17:42
Mike Sue-Ping
Cambridge, Ontario, Canada
 
 
À
11/12/2008 23:03:58
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01366733
Message ID:
01366938
Vues:
11
>>I have a class library with a combobox that I've customized by adding additional properties and methods. Now I want to use it as a starting point for another combobox class. Can I duplicate it without having to manually rebuild the entire thing as a new class? I thought that the Class Browser might do it but I don't see anything there.
>
>Without any intention to ignore the excellent advice on refactoring, I will share this little utility with you. :-)
>
>Peter
>
>
>***************************************************************************
>**&RS PROCEDURE  CopyClass_RS
>***************************************************************************
>**Purpose.....: Copy a class from one VCX to the same or another VCX
>**Parameters..: tcClassName1	-- the class to copy
>**	tcClassLib1	-- the library containing the class
>**	tcClassName2	-- the new name of the class if different
>**	tcClassLib2	-- the new class library (VCX) if different
>**Returns.....: true if successfull
>**Notes.......:
>**Example.....:
>**Project.....: Rodes Design Utilities
>**Authors.....: Peter Robinson & Dale Strickler
>**Copyright...: (c) Rodes Design 2006
>**Created.....: &&RS 2006.05.27
>**History.....:
>***************************************************************************
>lparameter		tcClassName1, tcClassLib1, tcClassName2, tcClassLib2
>
>local			tcClassName1, tcClassName2
>
>if not type("tcClassName1") == "C"
>    Msg_RS("<Invalid parameter> 1")
>    return .f.
>else
>    tcClassName1	= lower(alltrim(tcClassName1))
>endif
>
>if not type("tcClassLib1") == "C"
>    Msg_RS("<Invalid parameter> 2")
>    return .f.
>else
>    tcClassLib1		= lower(alltrim(tcClassLib1))
>endif
>
>if not type("tcClassName2") == "C" or empty(tcClassName2)
>    tcClassName2	= tcClassName1
>else
>    tcClassName2	= lower(alltrim(tcClassName2))
>endif
>
>if not type("tcClassLib2") == "C" or empty(tcClassLib2) or tcClassLib1 == tcClassLib2
>    tcClassLib2		= ""
>else
>    tcClassLib2		= alltrim(tcClassLib2)
>endif
>
>if empty(tcClassLib2)
>    set safety off
>    delete file CopyClass_RS.vcx
>    delete file CopyClass_RS.vct
>    set safety on
>    tcClassLib2	= "CopyClass_RS"
>endif
>
>add class &tcClassName1 of &tcClassLib1 to (tcClassLib2)
>
>if tcClassName2 <> tcClassName1
>    rename class &tcClassName1 of (tcClassLib2) to &tcClassName2
>endif
>
>if tcClassLib2 = "CopyClass_RS"
>    add class &tcClassName2 of (tcClassLib2) to &tcClassLib1
>    delete file "CopyClass_RS.vcx"
>    delete file "CopyClass_RS.vct"
>endif
>
Peter, that is indeed, an excellent little utility. Thanks.

Naomi, I used Peter's utility instead of your method. It was just too easy doing it his way to ignore.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform