Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multiuser environment question
Message
From
07/09/2006 16:14:36
 
 
General information
Forum:
Visual FoxPro
Category:
Client/server
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01151640
Message ID:
01152064
Views:
33
This message has been marked as a message which has helped to the initial question of the thread.
One way that may work:
CLOSE ALL
CLEAR ALL
RELEASE ALL
CLEAR
ON ERROR DO errprg WITH ERROR()
SET SAFETY OFF
SET CONFIRM OFF

LOCAL lcnewvalue					&& line of code to add to the method
lcnewvalue = "SET EXCLUSIVE OFF"  	&& Add this line to the end of the method

=ADIR(myforms,'c:\forms\*.scx')		&& directory of forms
FOR i = 1 TO ALEN(myforms,1)			&& step through each form
	lcorgvalue = ''
	lcreplvalue = ''
	CLOSE ALL
	IF FILE('c:\forms\'+myforms(i,1))
		lcfile = 'c:\forms\'+ LEFT(myforms(i,1),AT('.',myforms(i,1))-1)
		?lcfile
		TRY
			lccommand = "MODIFY FORM "+lcfile+" NOWAIT"	&& specify the form to modify
			?lccommand
			&lccommand
			TRY
				ASELOBJ(laform, 1)
				loform = laform(1)
				IF TYPE('loForm') = "O" .AND. !ISNULL(loform) .AND. ALLTRIM(UPPER(loform.BASECLASS)) = "FORM" ;
						.AND. UPPER(PEMSTATUS(loform,'LOAD',3)) = "EVENT" ;
						.AND. UPPER(loform.NAME)<>"SCREEN"
					lcorgvalue = loform.READMETHOD('LOAD')
					lcorgvalue = NVL(lcorgvalue,'')
					lcorgvalue = STRTRAN(lcorgvalue,[CHR(13)chr(13)],CHR(13))
					?lcorgvalue
					IF TYPE(lcORgValue) = "C" .and. LEN(lcORgvalue) < 255 .and. ! "SET EXCLUSIVE OFF" $ UPPER(lcorgvalue)
						lcreplvalue = lcorgvalue+CHR(13)+ALLTRIM(lcnewvalue)+CHR(13)
						?lcreplvalue
						IF loform.WRITEMETHOD('LOAD',lcreplvalue)
							lcnewvalue = loform.READMETHOD('LOAD')
							? lcnewvalue + " ---->>>> ************* SUCCESS ****************"
							CLEAR TYPEAHEAD
							INKEY(.1)
							KEYBOARD '{CTRL+W}'
							KEYBOARD CHR(121)
							DOEVENTS
							IF LASTKEY() = 27
								EXIT
							ENDIF
						ELSE
							? "Error writing method to "+myforms(i,1)
						ENDIF
					ENDIF
				ELSE
					? myforms(i,1)+' form is not an object'
				ENDIF
			CATCH
				? 'Error accessing '+myforms(i,1)+' as a form'
			ENDTRY
		CATCH
			? ' Unable to modify '+myforms(i,1)
		ENDTRY
	ELSE
		? myforms(i,1)+ ' is not a file.'
	ENDIF
	IF LASTKEY() = 27
		EXIT
	ENDIF
ENDFOR
CLOSE ALL
CLEAR ALL
RETURN


PROCEDURE errprg
LPARAMETERS errnum
?"Error: "
??errnum
RETURN
Add a line to the interactivechange method of all controls on a form:
CLOSE ALL
LOCAL lcnewvalue	&& line of code to add to the method
lcnewvalue = "THISFORM.isupdated = .T."  && Add this line to the end of the method

*--Form with controls to modify in this example is testform.scx
*--This example modifies the interactivechange method of every combobox, textbox, editbox and listbox on form

MODIFY FORM c:\FORMS\testform NOWAIT	&& specify the form to modify

ASELOBJ(laform, 1)
loform = laform(1)
IF TYPE('loform.pageframe')<>"U" && our pageframes are always named pageframe, check for pageframe1, etc.
	FOR EACH lopage IN loform.PAGEFRAME.PAGES
		lcorgvalue = ""
		lcreplvalue = ""
		FOR EACH ocontrol IN lopage.CONTROLS
			IF ALLTRIM(UPPER(ocontrol.BASECLASS)) = "TEXTBOX" .OR. ALLTRIM(UPPER(ocontrol.BASECLASS)) = "EDITBOX" ;
					.OR. ALLTRIM(UPPER(ocontrol.BASECLASS)) = "COMBOBOX" ;
					.OR. ALLTRIM(UPPER(ocontrol.BASECLASS)) = "LISTBOX"
				lcorgvalue = ocontrol.READMETHOD('InteractiveChange')
				lcreplvalue = lcorgvalue+CHR(13)+ALLTRIM(lcnewvalue)+CHR(13)
				ocontrol.WRITEMETHOD('InteractiveChange',lcreplvalue)
			ENDIF
		ENDFOR
	ENDFOR
ELSE	&& no pageframe all controls are on the single page
	FOR EACH ocontrol IN loform.CONTROLS
		lcorgvalue = ""
		lcreplvalue = ""
		IF ALLTRIM(UPPER(ocontrol.BASECLASS)) = "TEXTBOX" .OR. ALLTRIM(UPPER(ocontrol.BASECLASS)) = "EDITBOX" ;
				.OR. ALLTRIM(UPPER(ocontrol.BASECLASS)) = "COMBOBOX" ;
				.OR. ALLTRIM(UPPER(ocontrol.BASECLASS)) = "LISTBOX"
			lcorgvalue = ocontrol.READMETHOD('InteractiveChange')
			lcreplvalue = lcorgvalue+CHR(13)+ALLTRIM(lcnewvalue)+CHR(13)
			ocontrol.WRITEMETHOD('InteractiveChange',lcreplvalue)
		ENDIF
	ENDFOR
ENDIF

WAIT WINDOW "Verify the changes." NOWAIT

RETURN
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Reply
Map
View

Click here to load this message in the networking platform