Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Modem Dialing through VFP...
Message
From
01/05/1998 17:33:31
 
 
To
16/04/1998 19:31:21
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00092631
Message ID:
00096429
Views:
20
>>>>Trying to dial the phone using modem through COM1 in VFP. No luck!
>>>>
>>>>I've got the routine below:
>>>>---------------------------
>>>>
>>>>function dialer
>>>>parameters telnum,cport
>>>>
>>>>local keypress, handle, tcom, dialstr
>>>>
>>>>* cport = 1
>>>>* telnum = alltrim(str(telnum))
>>>> dialstr="ATDT"+telnum
>>>> WAIT 'Press Enter to Dial, any other key to cancel' WINDOW NOWAIT
>>>> keypress=INKEY(0,'H')
>>>> IF keypress = 13
>>>> tcom='COM'+alltrim(str(cport))
>>>> handle=FOPEN("&tcom",12) && attempt to open port
>>>> IF handle < 0
>>>> WAIT "Can't Open Communications Port, Check Setup" WINDOW
>>>> RETURN
>>>> ENDIF
>>>> =FPUTS(handle,dialstr) && dial number
>>>> WAIT 'Dialing... Lift Phone and press any key' WINDOW
>>>> =FPUTS(handle,"ATH") && hang up modem
>>>> =FPUTS(handle,"ATZ") && init modem
>>>> =FCLOSE(handle)
>>>> ENDIF
>>>>ENDFUNC
>>>>
>>>>
>>>>I keep getting the error in the routine "Can't open ...port."
>>>>
>>>>Any ideas? I'd really rather not purchase a $300 comm package and complicate VFP further. Why won't this work? My modem is on COM1 with IRQ4 and works just fine through other programs in W95.
>>>>
>>>>TIA!
>>>>
>>>>Mark
>>>
>>>VFP comes with a limited comm OCX, MSCOMM.. This should do what you want. There is a doc on it's usage in the libraries here too!
>>
>>
>>Tony,
>>
>>Thanks -- forgot about that, but probably just suppressed it; I tried it once and never got it to do anything. I'll check out the UT library.
>>
>>Thanks again,
>>
>>Mark
>
>
>Mark,
> Here is some sample code to try:
>
>Picture>
>
>omputer onsulting
>Services Tips Links Books Search
>
>
>
>
>
>CODE FOR DIALING A PHONE:
>(with accompanying gotchas and application ideas)

>VISUAL BASIC 4.0: (same mscomm control)
>
>com1.commport=3
>com1.settings="28800,N,8,1"
>com1.portopen=.t.
>com1.output="ATDT999-9999"+chr(13)
>com1.portopen=.f.
>

>VISUAL FOXPRO 5.0: (same mscomm control)
>
>thisform.com1.commport=3
>thisform.com1.settings="28800,N,8,1"
>thisform.com1.portopen=.t.
>thisform.com1.output="ATDT999-9999"+chr(13)
>thisform.com1.portopen=.f.
>
>
>
>That is the basic code, but watch for these gotchas:
>
>
>
>
>
>1) If the line your sending codes out to does not have a dial tone because you are not dialing a phone, but some sound equipment or some other equipment that does not send any carrier freq or anything, but only waits for your tone to be dialed, you must place an H1 before the DT of the output string to place the modem in offhook mode. Then you will have to send an H0 to reset the modem before your next tone sent.
>
>2) If you receive a "No dialtone" message also put an X0 or X1 in line depending on your modem to rid the message.
>
>3) If you find your AT commands between portopen and portclose are not executing it is most likely a timing issue. That is, one command is executing at the speed of your modem while the speedy VFP and your computer is already sending the next few so they don't get executed. Use commas after the DT to pause or use WAIT WINDOW "Commandx" TIMEOUT 2 between commands to slow things using command messages to aid you in seeing what's happening. Watch for this one especially if you are using a slower modem.
>
>
>
>Send mail to tvoss@computer-consulting.com with questions or comments about this web site.
>Copyright © 1996 Computer Consulting
>Last modified: March 24, 1998


Tony -- problem solved! Thank you so much for your input; it was quite helpful.

Sincerely,

Mark
Previous
Reply
Map
View

Click here to load this message in the networking platform