Markish


Hi,
I have been using a base class library ( say X) for my application development. Now that I've created a new base class library (say Y). I want to change the class library for all the objects (in all forms in my project). I wrote a small program something like

Code Snippet

mscx_ct=Adir(mscx,'*.SCX')
mct=1
do while mct<=mscx_ct
mfnam=mscx(mct)
use &mfnam
repl all classloc with "Y"
mct=mct+1
use
enddo

The above code works fine with objects which are not contaiers. For container objects like command group , the member class location needs to be changed.

Please let me know a procedure to change it if exists.

Best regards,
Markish





Re: Change of Class Library ...

CetinBasoz


I don't understand how this code works in the first place. Anyway if you say it's working for you then check properties column.






Re: Change of Class Library ...

Markish

Hi Cetin,

Thank you for the direction. The code is working. The properties column, is it enough I add an entry(new line) in the memo field with member class

Best regards,

Markish







Re: Change of Class Library ...

Markish

Hi,

I tried working in that direction. Somewhere down the line I tried to edit the properties memo field like this.

Code Snippet

CASE INLIST(mold_class,"TEXTBOX","LABEL") mnew_class="d"+LOWER(mold_class)

REPLACE class WITH mnew_class, classloc WITH mclassloc

COPY MEMO properties TO temp.txt

SELECT 0

CREATE TABLE temp (text c(200),mpara c(50),mvalue c(150),mnvalue C(150))

APPEND FROM temp.txt sdf

GO top

DO whil !EOF()

mpos=AT("=",text)

REPLACE mpara WITH UPPER(SUBSTR(text,1,mpos-1)),;

mvalue WITH SUBSTR(text,mpos+1,LEN(text)-mpos)

SKIP

ENDDO

INDEX on mpara TO temp

SET INDEX TO temp

SET CLASSLIB TO &mclassloc ADDITIVE

mobj=CREATEOBJECT(mnew_class)

*** Backcolor

IF SEEK("BACKCOLOR")

REPLACE mnvalue WITH ALLTRIM(STR(mobj.backcolor))

ENDIF

*** Forecolor

IF SEEK("FORECOLOR")

REPLACE mnvalue WITH ALLTRIM(STR(mobj.forecolor))

ENDIF

*** Fontbold

IF SEEK("FONTBOLD")

REPLACE mnvalue WITH IIF(mobj.fontbold,".T.",".F.")

ENDIF

**** Font Name

IF SEEK("FONTNAME")

REPLACE mnvalue WITH ALLTRIM(mobj.FONTNAME)

ENDIF

IF SEEK("FONTSIZE")

REPLACE mnvalue WITH ALLTRIM(STR(mobj.FONTSIZE))

ENDIF

IF SEEK("DISABLEDFORECOLOR")

REPLACE mnvalue WITH ALLTRIM(STR(mobj.DISABLEDFORECOLOR))

ENDIF

IF SEEK("DISABLEDBACKCOLOR")

REPLACE mnvalue WITH ALLTRIM(STR(mobj.DISABLEDBACKCOLOR))

ENDIF

IF SEEK("HEIGHT")

REPLACE mnvalue WITH ALLTRIM(STR(mobj.HEIGHT))

ENDIF

SET INDEX TO

GO top

SET ALTERNATE TO temp1

SET ALTERNATE on

DO WHILE !EOF()

ALLTRIM(mpara)+" = "+ALLTRIM(IIF(!EMPTY(ALLTRIM(mnvalue)),trim(mnvalue),TRIM(mvalue)) )

SKIP

ENDDO

SET ALTERNATE off

SET ALTERNATE to

SELECT a

APPEND MEMO properties FROM temp1.txt overwrite

CASE mold_class="COMMANDBUTTON"

....

..

The probjem I face is,

There are some trailing spaces in each and every line in the properties memo field

ther is a eof character (^Z) at the end of the properties. So I get "invalid record " when I try to open the edited scx. (modi form...).

Please let me know if any alternative method to aproach this.

Best regards,

Markish






Re: Change of Class Library ...

Naomi Nosonovsky

There is a class in UT Downloads by Glen Domeracki that does what you're attempting to do.

Here is a link to it http://www.universalthread.com/wconnect/wc.dll 2,54,33,9955 which works only after you log into this site.

Here is the class description:

NewClass is designed to safely change classes in forms and classlibraies. I wrote it years ago after having made many "BASE CLASS" mistakes with VFP3.0. It allows you to select the form which you need to change, and then displays a list of classes used in that form. You then select a classlib which will be used for replacement classes. When you select one of the classes in the form class list the library list will display a list of classes with the same base class as that which is selected in the form class list. There is a checkbox on this form which allows you to optionally list all library classes rather than matching base classes only. After having selected a class to change you may then select an item in the library list. When the ADD button is clicked this change is placed into the Queue list. You may repeat this as many times as you like to change multiple classes in one session. You may also remove items from the queue. After making all selections you can press the apply button and the original files are backed up with extensions like t00 - t99, x00 - x99, After the files are successfuly backed up the queued changes are applied, the lists updated and you are allowed to continue.





Re: Change of Class Library ...

Markish

Hi,

Thanks a lot for this. This is what I've been trying to do. I'll check with this. Still any help in the code I've written (Just I want to know what is the problem with that)

Best regards,

Markish






Re: Change of Class Library ...

CetinBasoz

Code Snippet

Case Inlist(mold_class,"TEXTBOX","LABEL")

mnew_class="d"+Lower(mold_class)

Replace Class With mnew_class, ;

classloc With mclassloc, ;

properties With ResetProperties(properties,;

"BACKCOLOR,FORECOLOR,"+;

"FONTBOLD,FONTNAME,FONTSIZE,DISABLEDFORECOLOR,DISABLEDBACKCOLOR,HEIGHT")

*CASE ...

* ...

Procedure ResetProperties

Lparameters tcProperties, tcPropertyListToReset

Local Array aReset[1]

For ix=1 To Alines(aReset,m.tcPropertyListToReset,.T.,',')

If Atcline(aReset[m.ix],m.tcProperties) > 0

tcProperties = Strtran( m.tcProperties, ;

MLINE(m.tcProperties,;

Atcline(aReset[m.ix],m.tcProperties))+Chr(13)+Chr(10), '',1,1,1)

Endif

Endfor

Return m.tcProperties

endproc