INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Classes and Objects

A utility to reset the Base classes chosen as a derived class in your forms and insert the inroduced classes. And more to imagine ! by ramani
Posted: 5 Dec 02 (Edited 5 Dec 02)

*************************************************
* Author : Ramani (Subramanian.G)
**         FoxAcc Software / WInners Software
**         ramani_g@yahoo.com
* 1. Purpose : To infuse new class name
*              in the place of base class in forms
* 2. Does modification to all forms in the open projects
* ...  SO open only the required project
* 3. Will ask you which base classes you want to modify
* ... with samples and you can add more or delete a few
* 4. After running the gsNewCls..
* .......  add the NewClass craeted to project
*
* 5. How run .. In the command window =gsNewCls()
*************************************************
** gsNewCls.PRG... Save the code as gsNewCls.PRG
*************************************************

SET CONFIRM OFF
SET SAFETY OFF
** Accept the newClass name
cClass = INPUTBOX("Give a name for new class ?", ;
                  "New Class Name")
IF EMPTY(cClass)
   =MESSAGEBOX("No class name given ",0+16,"I quit")
   RETURN
ENDIF

** Create a table to refer for convertion
CREATE TABLE myClass (cBaseClass C(15), cNewClass C(15))

** Insert into this table some of the base classes and suggested NewClass
INSERT INTO myClass (cBaseClass, cNewClass) ;
    VALUES ("TextBox","b_TextBox")
INSERT INTO myClass (cBaseClass, cNewClass) ;
    VALUES ("CheckBox","b_CheckBox")
INSERT INTO myClass (cBaseClass, cNewClass) ;
    VALUES ("EditBox","b_EditBox")
INSERT INTO myClass (cBaseClass, cNewClass) ;
    VALUES ("Grid","b_Grid")
INSERT INTO myClass (cBaseClass, cNewClass) ;
    VALUES ("Label","b_Label")

** Browse the table for developer input
** Use Ctrl+Y or Ctrl+T to insert or delete
BROW
SET DELETED ON
** Now create the new classes
SCAN FOR !EMPTY(cBaseClass) AND !EMPTY(cNewClass)
   tBaseClass = ALLTRIM(LOWER(cBaseClass))
   tNewClass = ALLTRIM(LOWER(cNewClass))
   CREATE CLASS &tNewClass OF &cClass AS &tBaseClass NOWAIT
ENDSCAN

** Now the convertion
LOCAL cFormFile, i, p

FOR p = 1 TO application.Projects.Count
   FOR i =  1 TO application.Projects(p).Files.Count
      cFormFile = application.Projects(p).Files(i).NAME
      IF UPPER(JUSTEXT(cFormFile)) = "SCX"
         WAIT WINDOW cFormFile NOWAIT
         SELECT 0
         USE (cFormFile) ALIAS myForm
         SCAN
           SELECT myClass
           LOCATE FOR ALLTRIM(UPPER(cBaseClass))== ;
                      ALLTRIM(UPPER(myForm.Class))
           IF FOUND()
              REPLACE myForm.Class WITH ;
                     ALLTRIM(LOWER(myClass.cNewClass)), ;
                 myForm.BaseClass WITH ;
                     ALLTRIM(LOWER(myClass.cBaseClass)), ;
                 myForm.ClassLoc WITH ;
                     ALLTRIM(LOWER(cClass))+".vcx"
           ENDIF
           SELECT myForm
         ENDSCAN
         USE
      ENDIF
   ENDFOR
ENDFOR
** Development ebnvironment
SET CONFIRM ON
SET SAFETY ON
SET DELETED OFF
CLOSE ALL
**
RETURN
*************************************************
** EOF
*************************************************

** The code is provided as freeware with no warranty
** CAUTION : This will modify all forms in your project
** Use at your risk.
*************************************************
** Can be modified easily to redefine classes.
*************************************************

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close