VFP developers faces problem when he had to make structure change in his source project regarding Data-environment. Then he had to make a lot manual efforts to change every form or any specific form.
Bellow is example code with function fmb_DenvNull which can help to remove Data environment cursors references in one one call.
Bellow is example code with function fmb_DenvNull which can help to remove Data environment cursors references in one one call.
********************************************* * Reset Form Dataenvironment to NULL * form_dataen.prg * Author: Zia Mughal (2013) * Copy right (R) Pcland Software inc. Pakistan ********************************************* SET SAFETY off SET CONFIRM OFF CLOSE DATABASES =adir(scxlist,"*.scx") create table scxname ( fname c(30)) index on fname tag fname USE IF ! USED("scxname.dbf") USE scxname ALIAS scxname again IN 11 ENDIF SELECT scxname append from array scxlist IF ! BOF() GO top ENDIF SCAN SELECT scxname if fmb_DenvNull(fname)= .f. MESSAGEBOX('Error Restting Dataenvironment to NULL in Form: ' +; scxname.fname,0+16,"Pcland.com.pk") ENDIF ENDSCAN USE MESSAGEBOX('All files Successfulyy cleared Dataenvironment: ',0+64,; "Pcland.com.pk") RETURN ************************** FUNCTION fmb_DenvNull PARAMETERS lcfile *************************** LOCAL llresult, lcstring STORE .f. TO llresult lcstring = "Top = 0" + CHR(13)+ "Left = 0" + CHR(13) + "Width = 0"+ CHR(13)+;
"Height = 0" + CHR(13) + "DataSource = .NULL." + CHR(13) +; "Name = 'Dataenvironment'" IF !FILE(lcfile) RETURN .f. ENDIF USE &lcfile ALIAS prs IN 1 SELECT prs IF ! BOF() GO top ENDIF LOCATE FOR objname='Dataenvironment' AND class='dataenvironment' IF FOUND() replace [properties] WITH lcstring replace [reserved2] WITH '1' replace [reserved4] WITH '1' DELETE ALL FOR class='cursor' pack STORE .t. TO llresult ENDIF USE RETURN llresult ENDFUNC ***********************
Cheers!
No comments:
Post a Comment