Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
One response when I debug and other in runtime
Message
From
02/03/2006 06:44:54
 
 
To
02/03/2006 05:29:51
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01100771
Message ID:
01100796
Views:
9
>Hello,
>
>I'm trying to send SMS in VFP, and i need the Mscomm ActiveX control to do that.
>
>The code i'm using is following:
>
>thisform.oCom.Output = "AT" + Chr(13) + Chr(10)
>thisform.ocom.Refresh
>time = seconds()
>do while .t.
>	ReturnString = thisform.oCom.input
>	if at("OK", upper(ReturnString)) > 0
>		exit
>	endif
>	if seconds() > time + 5
>		exit
>	endif
>enddo
>?? ReturnString
>
>
>The above code do this:
> 1) First i send a command to the Phone with 'output' method of the ActiveX
> 2) Then i wait 5 seconds for a response from the phone (with the 'input' method), that should be something like this: "AT" + chr(13) + chr(10) + "OK" + chr(13)
> 3) The loop is breaked in 2 ways: the 5 seconds pass away or i get the word 'OK' in the return string from the phone
>
>But i get a "strange" behaviour:
>When i'm debuging this code to see what is wrong, the code works fine and i receive the correct string. When i'm running this code normally i get nothing.
>
>Does anyone know why?
>
>Thank you,
>Joaquim

Joaquim,

Never used it, but I'd say you have to read the input and buffer it

I suspect you only get one byte at a time or so

something like ( I leave the timeout to you)
ReturnString = ''
thisform.oCom.Output = "AT" + Chr(13) + Chr(10)
thisform.ocom.Refresh

do while right(m.ReturnString, 1) <> chr(10)
    doevents
    ReturnString = m.ReturnString + thisform.oCom.input
enddo

&& test for OK here
or (this is in the sample)
ReturnString = ''
thisform.oCom.Output = "AT" + Chr(13) + Chr(10)
thisform.ocom.Refresh

do while !( 'OK' + Chr(13) + Chr(10) $ m.ReturnString )
    doevents
    ReturnString = m.ReturnString + thisform.oCom.input
enddo
Gregory
Previous
Reply
Map
View

Click here to load this message in the networking platform