Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting Editbox's Line and Column position
Message
From
03/02/2009 07:16:29
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01378690
Message ID:
01378935
Views:
16
>>>Something like
>>>
>>>lnStart = Thisform.Edit1.SelStart
>>>lcCrLf = CHR(13) + CHR(10)
>>>
>>>lnOccurence = OCCURS(lcCrLf, LEFT(Thisform.Edit1.Text, lnStart))
>>>
>>>lcCommand = STREXTRACT(lcCrLf + Thisform.Edit1.Text, lcCrLf ,lcCrLf, lnOccurence + 1,2) 
>>>
>>>

Here is the release candidate 1.0 ;)
procedure thisform.Edit1.Keypress
Lparameters nKeyCode, nShiftAltCtrl
If  nKeyCode = 13
	lcCrLf					= Chr(13) + Chr(10)
	lccomand				= Thisform.select_command(This.SelStart, This.Value)
	*
	lnStart 				= Thisform.Edit1.SelStart
	lnlinetotxt				= Occurs(lcCrLf, Left(Thisform.Edit1.Text, lnStart))
	lnStart 				= Len(Thisform.Edit1.Text)
	lnlinetot				= Occurs(lcCrLf, Left(Thisform.Edit1.Text, lnStart))
	lcCommrest				= ""
	lcCommfw				= ""
	llgoprocess				= .f.
	*
	If  lnlinetotxt = lnlinetot
		If  ";" $ lccomand
		ELSE
			llgoprocess		= .t.
			lcCommrest		= thisform.check_fullcommand(Thisform.Edit1.Text, "backward", lnlinetotxt)
		ENDIF
	ELSE
		llgoprocess			= .t.
		
		*
		* get lines forward (if ; character inside current command
		*
		If  ";" $ lccomand
			lcCommfw		= thisform.check_fullcommand(Thisform.Edit1.Text, "forward", lnlinetotxt)
		Endif
		*
		* get lines backward
		*
		lcCommrest			= thisform.check_fullcommand(Thisform.Edit1.Text, "backward", lnlinetotxt)
	ENDIF
	IF  llgoprocess
		lcgocommand = ALLTRIM(Chrtran(lcCommrest+" "+lccomand+" "+lcCommfw, ";", " "))
		thisform.go_command(lcgocommand)
	endif
	If  lnlinetotxt=lnlinetot
	Else
		*vfp's behavior
		lcsend		= Chrtran(lcCommrest+lccomand+lcCommfw, ";", " ")
		This.Value	= This.Text + lcsend + lcCrLf
		This.SelStart	= Len(This.Text)+LEN(lcsend)+1
		NODEFAULT
		this.Refresh()
		Return .F.
	Endif
Endif
endproc


procedure thisform.select_command
Lparameters pnSelStart, pcvalue
lnStart            = Thisform.Edit1.SelStart
lcCrLf             = CHR(13) + CHR(10)
lnOccurence  = OCCURS(lcCrLf, LEFT(Thisform.Edit1.Text, lnStart))
lcCommand    = STREXTRACT(lcCrLf + Thisform.Edit1.Text, lcCrLf ,lcCrLf, lnOccurence + 1,2) 
RETURN lcCommand
endproc


procedure thisform.check_fullcommand
Lparameters pcText, pckind, pnlinetotxt
Alines(laLines, pcText)
lcCommret						= ""
If  pckind="backward"
	*
	* get lines backward
	*
	Do While pnlinetotxt>1
		If  Empty(laLines[pnlinetotxt]) .Or. Substr(Alltrim(laLines[pnlinetotxt]),1,1)="*"
		Else
			If  ";"$laLines[pnlinetotxt]
				lcCommret	= laLines[pnlinetotxt] + lcCommret
			Else
				pnlinetotxt = 1
				Loop
			Endif
		Endif
		pnlinetotxt		= pnlinetotxt - 1
	Enddo
Endif
If  pckind="forward"
	*
	* get lines forward (if ; character inside current command
	*
	lnlins			= lnlinetotxt+2
	Do While !lnlins > lnlinetot
		If  Empty(laLines[lnlins]) .Or. Substr(Alltrim(laLines[lnlins]),1,1)="*"
		Else
			lcCommret= lcCommret + laLines[lnlins]
			If  ";"$laLines[lnlins]
			Else
				lnlins  = lnlinetot+1
				Loop
			Endif
		Endif
		lnlins		= lnlins + 1
	Enddo
Endif
Return lcCommret
endproc
"Now to him who is able to do immeasurably more than all we ask or imagine, according to his power that is at work within us, Ephesians 3:20
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform