Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Connecting to named pipe from FP/VFP
Message
 
À
04/05/2001 12:37:42
Larry Huisingh
Lockheed Martin Information Technology
Richland, Washington, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00503564
Message ID:
00503631
Vues:
31
>>>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 &&You can make this more robust if you like.
endif

lcMessage = fgets(lnHandle)
do case
   case empty(lcMessage)
      fclose(lnHandle)
      return 0

   case !empty(lcMessage)
      fclose(lnHandle)
      fcreate('MyPipeFile') && Creates and overwrites with empty file. 
      && Here you need to do something with lcMessage
endcase
Then,
local oTimer

oTimer = createobject('MyTimerClass')
oTimer.interval = 1000 && 1 second
oTimer.enabled = .T.
Eric Kleeman - EDS Consulting Services
MCP Visual FoxPro
MCSD C#.NET
Hua Hin Thailand
Los Angeles California
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform