Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dialing code
Message
 
To
01/10/2002 18:50:23
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00706628
Message ID:
00706720
Views:
29
>I have a phone field that i want to dial from it. if i have modem in my computer with com1 how in VFP i can set this field to dial from.
>
>Thanks

This code was previously posted here:
#DEFINE WAITSECONDS 4
#DEFINE ID_CANCEL   2
#DEFINE MB_OKCANCEL 1
#DEFINE MB_ICONSTOP 16
#DEFINE MB_ICONINFORMATION 64
#DEFINE GENERIC_READ  0x80000000
#DEFINE GENERIC_WRITE 0x40000000
#DEFINE CF_TEXT CHR(13) + CHR(10)

DECLARE INTEGER WriteFile IN Win32API;
  INTEGER hFile, STRING @lpbuffer,;
  INTEGER nNumberOfBytesToWrite,;
  INTEGER @lpNumberOfBytesWritten,;
  STRING @lpOverlapped
DECLARE INTEGER CreateFile IN Win32API;
  STRING @lpFileName, INTEGER dwDesiredAccess,;
  INTEGER dwShareMode,;
  STRING @lpSecurityAttributes, INTEGER dwCreationDisposition,;
  INTEGER dwFlagsAndAttributes, INTEGER hTemplateFile
DECLARE INTEGER CloseHandle IN Win32API;
  INTEGER hObject
DECLARE INTEGER FlushFileBuffers IN Win32API;
  INTEGER hFile

PROCEDURE DialNumber
  
  LPARAMETERS PhoneNumber, CommPort
  
  LOCAL lcmsg, lnport, lnwritten, lcmnd,;
    lnstop
  lcmsg = "Please pickup the phone and choose OK to dial " + PhoneNumber
  IF MESSAGEBOX(lcmsg, MB_ICONINFORMATION + MB_OKCANCEL, "Dial Number") # ID_CANCEL
    lnport = CreateFile(CommPort, GENERIC_READ + GENERIC_WRITE, 0, 0, 3, 0, 0)
    IF lnport > 0
      lnwritten = 0
      lcmnd = "ATDT" + PhoneNumber + CF_TEXT
      IF WriteFile(lnport, @lccmnd, LEN(lcmnd), @lnwritten, 0) # 0
        * Flush the buffer to assure the data was written
        = FlushFileBuffers(lnport)
        * Wait to make sure it's been dialed
        lnstop = SECONDS() + WAITSECONDS
        DO WHILE SECONDS() < lnstop
          DoEvents
        ENDDO
        * Hang up command
        lccmnd = 'ATH0' + CF_TEXT
        = WriteFile(lnport, @lccmnd, LEN(lcmnd), @lnwritten, 0)
        = FlushFileBuffers(lnport)
        * Close up
        = CloseHandle(lnport)
      ENDIF
    ENDIF
  ENDIF
  RETURN
ENDPROC

Just an opinion... Not a fact.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform