Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CTRL+S unreliable
Message
From
28/11/2006 11:46:47
 
 
To
27/11/2006 21:55:08
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01172633
Message ID:
01172974
Views:
16
John,

What I experience: A form has an editbox. The KeyPress event handles CTRL+S. It should save the edited text. What I notice is that this is normally not done in my case. It is done, however, when the debugger is actively involved (stepping in the code)!

This code should prove my point.
PUBLIC ofrmeditcfp

strtofile( "some text", "testfile.txt" )

ofrmeditcfp=createOBJECT("frmeditcfp", "testfile.txt")
ofrmeditcfp.Show

modi file "testfile.txt"
RETURN

DEFINE CLASS frmeditcfp AS form


	Height = 204
	Width = 454
	ShowWindow = 1
	DoCreate = .T.
	AutoCenter = .T.
	Caption = "Edit MPS-configuratiebestand"
	MinButton = .F.
	KeyPreview = .T.
	WindowType = 1
	*-- Name of configFP.
	cCFP = ('')
	*-- Drive+Dir+Filename of configFP.
	cDDF = ('')
	*-- Old text of ConfigFP.
	cOldCFP = ('')
	Name = "frmEditCFP"

	ADD OBJECT edtcfp AS editbox WITH ;
		FontName = "Courier New", ;
		Height = 204, ;
		Left = 0, ;
		Top = 0, ;
		Width = 456, ;
		ControlSource = "thisform.cCFP", ;
		Name = "edtCFP"

	PROCEDURE Resize
		with thisform
			.edtCFP.width  = .width
			.edtCFP.height = .height
		endwith
	ENDPROC

	PROCEDURE Init
		lparameter tcDDF

		local array laF[1,5]

		with thisform
			.cDDF    = m.tcDDF
			.cCFP    = filetostr( .cDDF )
			.cOldCFP = .cCFP
			.caption = 'Edit ' + .cDDF
			*
			if adir( laF, .cDDF ) = 0 ;
			or 'R' $ laF[ 1, 5 ] ;
			or 'D' $ laF[ 1, 5 ]
				*
				.caption = .caption + ' (ReadOnly)'
				.edtCFP.readonly = .T.
			endif
		endwith
	ENDPROC

	PROCEDURE KeyPress
		LPARAMETERS nKeyCode, nShiftAltCtrl

		with thisform
			do case
			case nKeyCode = 27
				if not ( .cCFP == .cOldCFP )
					if messagebox( "Discard changes?", 4+32, "Abort" ) = 7	&& if no
						nodefault
						return
					endif
				endif 
				nodefault
				thisform.cDDF = ''
				thisform.release()
			case inlist( nKeyCode, 23, 19 )		&& ctrl+w, ctrl+s
				nodefault
				thisform.release()
			endcase
		endwith
	ENDPROC

	PROCEDURE Unload
		with thisform
			if not empty( .cDDF ) and not ( .cCFP == .cOldCFP )
				strtofile( .cCFP, .cDDF, 0 )
			endif
		endwith
	ENDPROC
ENDDEFINE
>I dispute that there is a problem here except when using that line of code. When using:
>
>x=0
>DO WHILE x # 27
> x=INKEY(0)
> ?X
>ENDDO
>
>Each CTRL+S is reported accurately.
>
>
>>Aleksey,
>>
>>This is about CTRL+S.
>>
>>Walter Meester has been urging you to attent his problem. See BUG: CTRL+S misbehaviour Thread #1121615 Message #1121615. You have not participated in that thread.
>>
>>Other threads here, that go back several years, also indicate that someting is wrong with CTRL+S. Here is a piece of code:
>>
>>
? inkey(0),"<",inkey(0),"<",inkey(0),"<",inkey(0),"<"
>>
>>What I experience is that the first press of CTRL+S gives no reaction on screen, the second press shows TWO times the inkey value 19, the third press shows no reaction and the fourth press again shows TWO times the inkey value 19.
>>
>>Can you explain this?
>>
>>The deeper problem is that CTRL+S is reportedly terribly unreliable as a Save key combination.
Groet,
Peter de Valença

Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform