Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Mscomm control
Message
From
18/12/2006 12:31:34
 
 
To
17/12/2006 12:04:59
Arjun Bagojikop
Dynamic Super Software
Sangli, India
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Title:
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
MS SQL Server
Miscellaneous
Thread ID:
01178407
Message ID:
01178608
Views:
15
Just as a test, does this return anything (If you are prompted to insert a control when you run it, choose the Microsoft Communications Control Version 6.0 when the insert object popup appears)?
CLEAR ALL
RELEASE ALL
ON ERROR
ON ESCAPE
_VFP.autoyield = .T.

PUBLIC oform1

oform1=CREATEOBJECT([MODEMFORM])
oform1.SHOW
RETURN

DEFINE CLASS MODEMFORM AS FORM


	Top = 0
	Left = 0
	Height = 250
	Width = 478
	DoCreate = .T.
	Caption = "Serial Device/Modem Test"
	WindowType = 1
	AlwaysOnTop = .T.
	send = "''"
	Name = "COMFORM"
	llescape = .F.
	llexit = .F.
	DIMENSION acommports[1,2]


	ADD OBJECT lblresponse AS label WITH ;
		BackStyle = 0, ;
		Caption = "Serial Device Response:", ;
		Height = 24, ;
		Left = 14, ;
		Top = 58, ;
		Width = 144, ;
		Name = "lblResponse"


	ADD OBJECT cmdtest AS commandbutton WITH ;
		Top = 216, ;
		Left = 168, ;
		Height = 27, ;
		Width = 144, ;
		Caption = "Test Ports For Serial Device", ;
		Name = "cmdTest"


	ADD OBJECT lblavailableports AS label WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Available Communication Ports:", ;
		Height = 17, ;
		Left = 150, ;
		Top = 8, ;
		Width = 177, ;
		Name = "lblavailableports"


	ADD OBJECT lblports AS label WITH ;
		Alignment = 2, ;
		BackStyle = 0, ;
		Caption = "Label1", ;
		Height = 40, ;
		Left = 167, ;
		Top = 28, ;
		Width = 120, ;
		Name = "lblports"


	ADD OBJECT edit1 AS editbox WITH ;
		Height = 132, ;
		Left = 13, ;
		ReadOnly = .T., ;
		Top = 76, ;
		Width = 444, ;
		Name = "Edit1"


	ADD OBJECT ocxcomm AS mscommcontainer WITH ;
		Top = 1, ;
		Left = 402, ;
		Height = 69, ;
		Width = 66, ;
		Name = "ocxcomm"


	ADD OBJECT text1 AS textbox WITH ;
		Enabled = .F., ;
		Height = 23, ;
		Left = 372, ;
		TabStop = .F., ;
		Top = 216, ;
		Visible = .F., ;
		Width = 100, ;
		Name = "Text1"


	PROCEDURE waitforresponse
		LPARAMETERS lnDelayInSeconds

		IF TYPE('lnDelayInSeconds') <> "N"
			lnDelayInSeconds = 2
		ENDIF

		LOCAL lnStartTime
		lnStartTime = SECO()

		DO WHILE SECO() <= (lnStartTime + lnDelayInSeconds) ;
				AND NOT SECO() < lnStartTime
			DOEVENTS FORCE
		ENDDO

		thisform.storeit()
	ENDPROC


	PROCEDURE storeit
		svalue = THIS.ocxCOMM.INPUT
		ivalue = THIS.ocxCOMM.CommPort
		IF TYPE('svalue') = "C"
			THIS.aCommPorts(ivalue,2) = THIS.aCommPorts(ivalue,2) + svalue
			IF TYPE('thisform.edit1')<>"U"
				THISFORM.edit1.VALUE = THISFORM.edit1.VALUE + svalue
			ENDIF
		ENDIF
	ENDPROC


	PROCEDURE Error
		LPARAMETERS nError, cMethod, nLine
		IF INLIST(nError, 1429, 1426)
			LOCAL aErrArray(1)
			AERROR(aErrArray)
			IF [INVALID PORT NUMBER] $ UPPER(aErrArray(3)) OR ;
					[UNKNOWN OLE STATUS CODE] $ UPPER(aErrArray(3))
				glBadPort = .T.
			ENDIF
		ELSE
			MESSAGEBOX([Error #: ] + ALLT(STR(nError)) + CHR(13) + ;
				[Message: ] + MESSAGE() + CHR(13) + ;
				[Line with error: ] + ALLT(STR(nLine)) + CHR(13) + ;
				[Method: ] + cMethod)
		ENDIF
	ENDPROC


	PROCEDURE Init
		ON ERROR
		ON ESCAPE
		SET TALK OFF
		SET ECHO OFF

		PUBLIC glBadPort
		glBadPort = .F.

		LOCAL i, lcGoodPorts
		lcGoodPorts = []

		WITH THIS.ocxCOMM
			.RThreshold = 1
			.SThreshold = 1
			.Settings = [9600,n,8,1]
			.RTSEnable = .F.
			.InputLen = 0
		ENDWITH

		DIMENSION THIS.aCommPorts(1,2)
		this.acommPorts(1,1)=0
		this.acommPorts(1,2)=""
		FOR i = 1 TO 10
			WITH THIS.ocxCOMM
				.CommPort = i
				.PortOpen = .T.

				IF !glBadPort
					IF i > 1
						DIMENSION THIS.aCommPorts[ALEN(THIS.aCommPorts,1)+1,2]
					ENDIF
					gnPortNum = i
					IF ALEN(THISFORM.acommports,1) < gnPortNum
						DIMENSION THISFORM.acommports(gnPortNum,2)
						THISFORM.acommports(gnPortNum,2) = ''
						THISFORM.acommports(gnPortNum,1) = gnPortNum
					ENDIF
					THIS.aCommPorts(i,1) = i
					THIS.aCommPorts(i,2) = []
					lcGoodPorts = lcGoodPorts + ALLT(STR(i)) + [  ]
				ENDIF

				glBadPort = .F.
				IF .PortOpen
					.PortOpen = .F.
				ENDIF
			ENDWITH
		ENDFOR

		THIS.lblPORTS.CAPTION = lcGoodPorts
		RELEASE glBadPort

		THIS.edit1.disabledbackcolor = this.text1.backcolor
		THIS.edit1.backcolor = this.text1.backcolor

		this.refresh()
	ENDPROC


	PROCEDURE cmdtest.Click
		_VFP.AUTOYIELD=.T.

		FOR ia = 1 TO ALEN(thisform.aCommPorts,1)
			thisform.aCommPorts(ia,2) = ""
		ENDFOR

		thisform.edit1.value = ""
		thisform.edit1.refresh()

		PUBLIC gnPortNum
		LOCAL i, lnModemPort
		lnModemPort = 0

		_VFP.AUTOYIELD=.F.

		WITH THISFORM
			ON ESCAPE thisform.llexit = .t.
			FOR i = 1 TO ALEN(.aCommPorts,1)
				gnPortNum = i
						IF ALEN(.acommports,1) < i
							DIMENSION .acommports(i,2)
							.acommports(i,2) = ''
							.acommports(i,1) = i
						ENDIF
						IF TYPE('.aCommPorts(i,1)') <> "N"
							.acommports(i,1) = 0
							.acommports(i,2) = ''
						ENDIF
				IF .acommports(i,1) <= 0
					LOOP
				ENDIF
				WAIT WINDOW [Testing COM ] + ;
					ALLT(STR(.aCommPorts(i,1))) + [...] NOWAIT NOCLEAR
				.edit1.value = thisform.edit1.value + "**** COM PORT "+ALLTRIM(STR(i))+"  ****"+CHR(13)
				.edit1.refresh()
				.ocxCOMM.PortOpen = .F.
				.ocxCOMM.CommPort = .aCommPorts(i,1)
				.ocxCOMM.PortOpen = .T.
				.send = "ATZ"
				.ocxCOMM.OUTPUT = [ATZ] + CHR(13)
				.ocxCOMM.ONCOMM()
				.waitforresponse(2)
				.ocxCOMM.PortOpen = .f.
				.edit1.refresh()
				.send = "ATI0"
				.ocxCOMM.PortOpen = .T.
				.ocxCOMM.OUTPUT = [ATI0] + CHR(13)
				.ocxCOMM.ONCOMM()
				.waitforresponse(2)
				.ocxCOMM.PortOpen = .f.
				.edit1.refresh()
				.send = "ATDT"
				.ocxCOMM.PortOpen = .T.
				.ocxCOMM.OUTPUT = [ATDT]+CHR(13)
				.ocxCOMM.ONCOMM()
				.waitforresponse(3)
				.ocxCOMM.PortOpen = .f.
				.edit1.refresh()
				WAIT CLEAR
				IF EMPTY(.aCommPorts(i,2))
					WAIT WINDOW [Testing Additional Commands on COM ] + ;
						ALLT(STR(.aCommPorts(i,1))) + [...] NOWAIT NOCLEAR
					.ocxCOMM.PortOpen = .F.
					.ocxCOMM.CommPort = .aCommPorts(i,1)
					.ocxCOMM.PortOpen = .T.
					.ocxCOMM.Send = "ATDT1234567890"+CHR(13)
					.ocxCOMM.OutPut = "ATDT1234567890"+CHR(13)
					.ocxCOMM.ONCOMM()
					.waitforresponse(2)
					.edit1.refresh()
					.ocxCOMM.ONCOMM()
					.waitforresponse(3)
					.ocxCOMM.PortOpen = .f.
					.edit1.refresh()
				ENDIF
			ENDFOR
			.edit1.refresh()
			INKEY(.1)
			doevents force
			ON ESCAPE
			.ocxCOMM.PortOpen = .F.
		ENDWITH

		WAIT WINDOW [Compiling Results...] NOWAIT

		lnModemPort = 0
		WITH THISFORM

			lcmessage = ''
			FOR i = 1 TO ALEN(.aCommPorts,1)
				IF .aCommPorts(i,1) <> 0
					IF [OK] $ UPPER(.aCommPorts(i,2))
						lnModemPort = .aCommPorts(i,1)
						lcmessage = lcmessage + [Modem Found on COM ] + ALLT(STR(lnModemPort)) +CHR(13)
						IF [NO DIAL] $ UPPER(.aCommPorts(i,2))
							lcmessage = lcmessage + [-->NO DIALTONE DETECTED]+CHR(13)
						ELSE
							lcmessage = lcmessage + [-->DIALTONE DETECTED]+CHR(13)
						ENDIF
					ENDIF
				ENDIF
			NEXT i

		ENDWITH

		WAIT CLEAR
		IF  lnModemPort <> 0
			MESSAGEBOX(lcmessage,0+48+4096,'Test Results')
		ELSE
			MESSAGEBOX([No Modem Found.] ,0+48+4096, 'Test Results')
		ENDIF
	ENDPROC


	PROCEDURE cmdtest.Error
		LPARAMETERS nError, cMethod, nLine
		*~ Trap OLE error from the COMM .OCX


		*~ nError = 1429: we experienced an OLE error. This may
		*~ be because we tried to open or communicate via
		*~ the port and there is a non-standard object attached to
		*~ it (such as a printer). Do nothing here; it's not a modem
		*~ since we cannot open AND communicate with it.
		*~ You may want to enhance this error trap.

		IF INLIST(nError, 1429, 1426)
		ELSE
		*~  We experienced a non - OLE error. Report it.
			MESSAGEBOX([Error #: ] + ALLT(STR(nError)) + CHR(13) + ;
				[MESSAGE: ] + MESSAGE() + CHR(13) + ;
				[LINE WITH ERROR: ] + ALLT(STR(nLine)) + CHR(13) + ;
				[Method: ] + cMethod)
		ENDIF
	ENDPROC


ENDDEFINE

DEFINE CLASS mscommcontainer AS OLECONTROL
	OLECLASS = [MSCOMMLib.MSComm.1]
ENDDEFINE
>Hi
>All friends
>
>I am trying to use mscomm control when i try with landline dialing propelry Working
>but i have try to connect vai nokia 6020 serial port cable modem
>no dial tone but display on moble D123456790
>
>WITH this.Parent.olecontrol1
> portopen =.t.
> .output = "ATDT1234567890"+CHR(13)
>
> .portopen =.f.
>ENDWITH
>
>Arjun
>Thanks Advance
.·*´¨)
.·`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
Next
Reply
Map
View

Click here to load this message in the networking platform