>>>Has anyone used named pipes to communicate between a FoxPro (FPW/VFP)
>>>application and another application?
>>><snip>
>>>
>>>Larry Huisingh
>>
>>I've done this before with a FoxPro timer. IOW, check the pipe at certain intervals, if there is anything there, grab it and empty the file. Then the C prog will load a new message and so on and so forth. And also loop if fopen() fails because the other prog has the file open. The drawback is VFP timers are problematic in certain situations.
>
>Do you have any sample code you could share? Are there separate steps such as
>
>1) checking the pipe for a message
>2) grabbing the message
>3) emptying the file
>
>What code would you use for each step? I have only tried issuing a FREAD that I assumed did all three but that may be too much of an assumption.
>
>Larry
Well, you would need to create custom object based on timer with the following in the timer event code.
This is a simple pseudo example that would obviously need to be much more robust depending on the situation.
local lcMessage, lnHandle
lnHandle = fopen('MyPipeFile',12)
if lnHandle < 1
return -1
endif
lcMessage = fgets(lnHandle)
do case
case empty(lcMessage)
fclose(lnHandle)
return 0
case !empty(lcMessage)
fclose(lnHandle)
fcreate('MyPipeFile')
endcase
Then,
local oTimer
oTimer = createobject('MyTimerClass')
oTimer.interval = 1000
oTimer.enabled = .T.
Eric Kleeman - EDS Consulting Services
MCP Visual FoxPro
MCSD C#.NET
Hua Hin Thailand
Los Angeles California