Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DragDrop - Syntax Error

Status
Not open for further replies.

Neil Toulouse

Programmer
Mar 18, 2002
882
0
0
GB
Hi guys!

I think I have been staring at this for too long now so some fresh eyes would be appreciated!

This is a dead simple form, 2 buttons where one is 'draggable' (ADD).

Code:
*** Create instance of form
oCustomForm = CREATEOBJECT('Custom_Form')
oCustomForm.SHOW()
***

**************
* CLASS CODE *
**************

DEFINE CLASS Custom_form AS FORM

	TOP = 7
	LEFT = 10
	HEIGHT = 459
	WIDTH = 552
	DOCREATE = .T.
	BORDERSTYLE = 1
	CAPTION = "Custom Fields"
	CONTROLBOX = .F.
	NAME = "FRMCUSTOM"
	WINDOWTYPE = 1
	XOffSet = 0
	YOffSet = 0

	ADD OBJECT cmdexit AS COMMANDBUTTON WITH ;
		TOP = 418, ;
		LEFT = 451, ;
		HEIGHT = 27, ;
		WIDTH = 84, ;
		CAPTION = "Exit", ;
		TABINDEX = 15, ;
		NAME = "cmdExit"

	ADD OBJECT cmdAddTxt AS COMMANDBUTTON WITH ;
		TOP = 385, ;
		LEFT = 451, ;
		HEIGHT = 27, ;
		WIDTH = 84, ;
		CAPTION = "Add", ;
		TABINDEX = 15, ;
		NAME = "cmdAddTxt", ;
		VISIBLE = .T.

	PROCEDURE cmdexit.CLICK
		THISFORM.RELEASE()
	ENDPROC

	PROCEDURE cmdAddTxt.MOUSEMOVE
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		LOCAL lnResult
		IF nButton = 1
			WITH THISFORM
				.XOffSet = nXCoord – THIS.LEFT
				.YOffSet = nYCoord - THIS.TOP
			ENDWITH
			THIS.DRAG
		ENDIF

	ENDPROC

	PROCEDURE cmdAddTxt.DRAGDROP
		LPARAMETERS oSource, nXCoord, nYCoord
		THIS.PARENT.DRAGDROP(oSource, nXCoord, nYCoord)
	ENDPROC

	PROCEDURE DRAGDROP
		LPARAMETERS oSource, nXCoord, nYCoord
		oSource.LEFT = nXCoord - THISFORM.XOffSet
		oSource.TOP = nYCoord - THISFORM.YOffSet
	ENDPROC

ENDDEFINE
**************************************************

The problem is I get a Syntax error on the .XOffSet = nXCoord – THIS.LEFT in the cmdAddTxt.MouseMove event. This is VFP8, and the code is mostly from the help file on drag & drop!

TIA!

Neil


I like work. It fascinates me. I can sit and look at it for hours...
 
Neil,
I don't know what is happen but when I Changed MouseMove to this:
Code:
 PROCEDURE cmdAddTxt.MOUSEMOVE
        LPARAMETERS nButton, nShift, nXCoord, nYCoord
        LOCAL lnResult
        IF nButton = 1
           THISFORM.XOffSet = (nXCoord -thisform.cmdAddTxt.Left)
           THISFORM.YOffSet = (nYCoord - THISform.cmdAddTxt.TOP)
            THIS.DRAG
        ENDIF
    ENDPROC
no error messages appears.

Borislav Borissov
 
Thanks Borislav! Glad it wasn't me going mad! The odd thing is it only fell over on that line - the YOffSet line worked fine!

Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
Neil,
I think you should send a BUG report to MS.

Borislav Borissov
 
Was just about to submit the bug report, but when I cut & pasted the code into my email client (Lotus Notes), it would appear a rogue character has crept in instead of the minus sign, but is shown on the VFP screen as a minus sign!

A screen shot of it here:


So I deleted it, added the minus again, and now it works. I do believe I cut & pasted the code from the help file.

Needless to say it is a bit worrying though!

I like work. It fascinates me. I can sit and look at it for hours...
 

Neil,

You're right. I can see it now. It's probably an en dash (ASCII 150), whereas a normal minus sign is ASCII 45. If you look very closely, you can see the difference.

If you copied from the Help file, then the Help file is at fault. Perhaps you should report it using the Send comments about this topic to Microsoft link at the foot of the Help page.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Hi guys!

Just to confirm and end this thread, it is a problem with the help file. I cut and pasted straight from the help page and into Lotus Notes and the error appeared. I have informed MS of the problem!

BTW, we have had a few threads in the past where certain constructs wouldn't work without adding ThisForm to them. Maybe this is an unrelated related problem! We need to keep it in mind ;-)

Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top