Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Oncomm event not firing in mscomm
Message
De
14/01/2002 13:09:32
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Divers
Thread ID:
00604408
Message ID:
00604454
Vues:
32
SNIP

>Take a look at http://fox.wikis.com/wc.dll?Wiki~MsComm32~VFP.
>You can also try to search for 'mscomm' in the message area for a recent discussion about mscomm. You cann narrow the search by looking for messages that involve Andrus Moor.

Thanks, I've researched both the UT and the wiki link above. All I've found in the UT is to ensure that RThreshold = 1 or at least greater than zero. The wiki above mentioned not relying on oncomm to fire, but to bind your own oncomm. I don't understand from the example in the wiki how to do that with my code below. Any pointers? Everything works except the oncomm event does not fire. The wiki uses the following as an example of binding:


************* FROM THE WIKI **********************************
If the code similar to the template below is being used, you've already attached VFP code to the OnComm? event.


DEFINE CLASS oncomm AS basecustomclass
PROCEDURE oncomm
*-- Some code here...
ENDPROC
ENDDEFINE

Then put In your code:

loModemComm = NEWOBJECT("MSCOMMLib.MSComm")
loEventHandler = NEWOBJECT("OnComm", "Comm")
loVFPCOM = NEWOBJECT("VFPCOM.ComUtil")
loVFPCOM.BindEvents(loModemComm, loEventHandler)


However, when I try anything close to the above, I get 'class defintion of vfpcom not found.' So I cannot continue.
PUBLIC ComForm
ComForm = CREATEOBJECT('Form')
ComForm.AddObject("MsCom","MSCOMMCLASS")
DO GetVer
DO PlayMsg
RETURN

DEFINE CLASS MsCommClass AS OLEControl
	OLECLASS = [MSCOMMLib.MSComm.1]
	PROCEDURE WaitForResponse
		LPARAMETERS lnDelayInSeconds
		LOCAL lnStartTime
		lnStartTime = SECO()
		DO WHILE SECO() <= (lnStartTime + lnDelayInSeconds) ;
				AND NOT SECO() < lnStartTime
			DOEVENTS()
		ENDDO
	ENDPROC
	PROCEDURE OnComm
		*---Receive Data
		WAIT WINDOW ALLTRIM(STR(THIS.CommEvent))
		IF THIS.CommEvent = 2
			IF THIS.InBufferCount>0
				lcString = THIS.Input
				IF !(lcString == "")
					WAIT WINDOW "SUCCESS! Version Retrieved: "+lcString
				ENDIF
			ELSE
				WAIT WINDOW "Tracy! Data Should have been Received..."
			ENDIF
		ENDIF
	ENDPROC
ENDDEFINE

PROCEDURE GetVer
	WITH ComForm.MsCom
		.RThreshold = 1
		.SThreshold = 1
		.Settings = [9600,n,8,1]
		.RTSEnable = .F.
		.InputLen = 0
	ENDWITH
	m_port=1
	ComForm.MsCom.CommPort = m_port
	ComForm.MsCom.PortOpen = .T.
	ComForm.MsCom.Output="~VER "+CHR(13)
	ComForm.MsCom.WaitForResponse(2)
	lcString=ComForm.MsCom.Input
	WAIT WINDOW lcString NOWAIT
	ComForm.MsCom.PortOpen = .F.
RETURN

PROCEDURE PlayMsg
	WITH ComForm.MsCom
		.RThreshold = 1
		.SThreshold = 1
		.Settings = [9600,n,8,1]
		.RTSEnable = .F.
		.InputLen = 0
	ENDWITH
	m_port=1
	ComForm.MsCom.CommPort = m_port
	ComForm.MsCom.PortOpen = .T.
	ComForm.MsCom.Output = "~PLAY " + chr(13)
	ComForm.MsCom.Output = "M " + chr(13)
	ComForm.MsCom.PortOpen = .F.
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"
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform