Ӧ
Computer Applications
1999 198 Vol.19No.8 1999



Visual FoxProеĽӿͨ
־աֿ
ժҪҪVisual FoxPro нӿͨоʵVisual FoxProӿͨŵַ
ؼʡӿͨţMSCommؼ
Visual FoxPro һǿݿϵͳDBMSǿӻݹϢϵͳƽ̨ڿСݿϵͳ˵Visual FoxPro һּõĿߣǶһЩݴ뽻ԶϵͳڲVisual FoxPro FoxPro ʱȴǳҪԭ֮һǣVisual FoxPro FoxPro ָ֧빦ܣ·ӿͨʵȽѣǶVisual FoxPro  FoxProĹ㷺ʹá
Visual FoxProFoxProĽӿͨоʵֽӿͨŵַ
1APIʵֽӿͨ
FoxProAPIʵCC++̺ʹFoxProԵñõĳͨһĹ淶Э鴫ݲпչ FoxProĹܣǴӽӿͨǶʵCC++нӿͨţַFoxProеĽӿͨŷҪFoxProⲿAPIдC򣬱FoxProṹ䣨LCKLCKкPROEXT.Xļģͺ͸FoxPro API壬CC++дʱС#include <proext.x>ΪCʱͷļʱ˵APIӦһFoxInfoṹָFoxProûݣҪпӦõĿ̣
Set library to drive path library name
FoxProAPIʵֱȽϸӵĽӿڹܣڱȽϼ򵥵ĽӿڹܣʵֻҪҪϣʵֵĽӿͨŹCC++̣ΪִļEXEļֱFoxProṩRUNüɣ磺
Run *.exe /s/t
Return
ֹҪڲƽ̨DOS£ Windows£԰ѱõĳΪWindowsµӦóļAPPļͬ
Run *.app
Return
2DDEʵֽӿͨ
̬ݽDDEDynamic Data ExchangeMicrosoft WindowsһֻܣDDEWindowsӦó֮ͨĳͨԻĳЭ齻ıݺͼݣĳͨԻĳЭʵָһϵضDDEʵDDEʱһҪһٶΪͻӦһٶΪDDEʵֵľ£FoxProΪDDEͻ 򡰷ݣ
DDEInitiate(): 򿪳ʼͨ
DDERequest():򡰷ݣ
DDETeminate():롰ĳӡ
ڳʼͨʱͨмѡ񣬶ӦüʱжͨǷWinWordΪģʵݵĴ洢طͨDDEͨFoxProеļУDDEʾͼ


ͼ1DDEʾͼ
DDEMicrosoftWindowsʱʵֵһֻܣҪʵWindowsͬӦó֮ĽݣַԵȱܹDDEͨŵӦóǱָģޣҪֱͨں·豸絥Ƭͨţַʵ·ͨʱȽѡ
3MSCommؼͨ
 FoxPro 2.5-2.6Visual FoxPro 3.0Microsoft˾ƳVisual FoxPro 5.0汾Microsoft˾OCXֳActiveXActiveXʵWindows 95ԴģӦVisual C++Visual FoxProVisual BasicӦóУΪĿ˺ܴ󷽱㡣ԭȵActiveXOLEؼ룬ActiveXǽCOM 淶Ļ֮ϡCOM淶 Microsoft˾ڿͻ/ṩһӦͬһ׼˼ǰֹ淶дĳԻ漰ԡƽַ̨⡣ActiveXǰһ淶дõһؼѳʵ˻Windowsƽ̨ĲͬԵͨãActiveXУṩûһͨſؼMSCommֿؼֱʵ·豸絥ƬдͨţӦȽϼ򵥡УMSCommؼ뵥ƬдͨţƿصĴ򿪺͹رգԼжϿص״̬ʹ洢ݵȹܡ
Visual FoxPro 5.0ActiveXʾѡMSCommؼӵVisual FoxPro 5.0ؼУؼͼһ绰ελͼڱĿؼʼ¼гʼÿؼ
Thisform.MSComm1.CommPort = 1
&&ѡ񴮿1
Thisform.MSComm1.Settings = "9600,N,8,1"
&&趨ͨʱĲʡУλλֹͣλ
Thisform.MSComm1.InputLen = 0
&&ȡ
Thisform.MSComm1.PortOpen = True
&&ͨſ
Thisform.MSComm1.InputMode=0
&&ͨģʽΪ0ģʽ
ڽݽ֮ǰӦ淶Ƭ֮ͨͨʱͨЭ飬ƶͨЭʱüˣеݴ͸ʽΪ

ʼλ1nλλ

ʵֵԴ
**ʱ¼**
Thisform.activate()
thisform.MSComm1.init()
thisform.timer1.enabled=.t.
Return
**ʱ,ÿ 0.1 ɨ贮״̬һβָ**
Thisform.timer1.timer()
Do while thisform.comerror=.t.
&&ͨŲִ
Wait window "ͨŴ"
timeout 20 nowait at 25,85
Do form chkcomm.scx
&& ִмͨ״̬ı
If inkey()=27
&& ESCѭ
Exit
Endif
Wait clear
Enddo
If thisform.orderopen=.t. 
&&жǷ񷢳
If thisform.commstatus=.f.
&&жͨŵ״̬
Exit
Else
Thisform.commopen()
Endif
Endif
If thisform.orderclose=.t.
&&жǷ񷢳ص
If thisform.commstatus=.f.
&&жͨŵ״̬
Exit
Else
Thisform.commclose()
Endif
Endif

Return
Thisform.commclose()
Parameter x, y
&&뿪صλò
Private commreturn
Thisform.comsendstring=chr(5)+chr(x)+chr(y)
&&ÿʼַ
Thisform.comsendcmd(7)
&&ַ
Commreturn=substr(thisform.commreturn,3,2)
Thisform.comsendstring=chr(7)+commreturn
Thisform.comsendcmd(7)

Return
Thisform.commopen()
Parameter x, y
&&뿪صλò
Private commreturn
Thisform.comsendstring=chr(6)+chr(x)+chr(y)
&&ÿʼַ
Thisform.comsendcmd(3) 
&&ַ

Return
 ϳУµ磺comerrororderopenorderclosecommstatuscomsendstringԣ·comsendcmdȣ͹صáͨŹУǵ豸״̬úͨ·ĴٶȣӦʵʱ㴫Ҫ
߼飺־ա˶ʿоо򣺹ҵءֿڡ¸ѹ
о
ߵλ־աֿϽͨѧѧԺĴɶ610031
ο
1ݡǮȪ.΢ϵͳԭ.: й,1997
2ݡ.Visual FoxPro 5.0 ȫֲ. :,1997
3ݡɽ,.FoxPro 2.5-2.6 for Windowsָ.ɶ:ӿƼѧ,1995 
ո:1999-02-18
