[Gambas-user] Send data to the process
Brian G
brian at westwoodsvcs.com
Sun Apr 25 04:23:29 CEST 2021
Here is a short set that will return what you wrote
background process:
' Gambas module file
Public AllDone As Boolean = False
Public Sub Main()
While Not AllDone
Wait 0.01
Wend
Quit 0
Catch
Quit 0
End
Public Sub Application_read()
Dim readline As String = ""
While Lof(Last)
readline &= Read #Last, -254
Wend
If readline == "quit" Then
AllDone = True
Else
Print Eval(readline)
Flush
Endif
Catch
Print Error.Text
Flush
End
*******************************************************
The forground process:
Public MyApp As Process
Public Sub Main()
Dim readline As String
MyApp = Exec [User.Home &/ "bin/AppSendRecvBG.gambas"] For Input Output As "BgApp"
While MyApp.state = Process.Running
Line Input readline
Print "Read :";; readline
Print #MyApp, readline
Flush #MyApp
Wait 0.01
Wend
Quit 0
End
Public Sub BgApp_read()
Dim readline As String
readline = ""
While Lof(Last)
readline &= Read #Last, -254
Wend
Print readline
End
*********************************************************
Hope this helps
"Failure is the key to success;
each mistake teaches us something" .. Morihei Ueshiba
Brian G
----- On Apr 24, 2021, at 5:42 PM, Dimitris Anogiatis <dosida at gmail.com> wrote:
> You could just try this:
> Dim app2Result as String
> SHELL "app2 2 multiply 2" to app2Result
> Just make sure that app2 can parse the arguments passed to it, perform the
> multiplication and then use PRINT to output the results. That's what will go
> into app2Result
> Hope this helps
> On Sat, Apr 24, 2021 at 11:29 AM Ivan Kern < [ mailto:ivan-kern at freenet.de |
> ivan-kern at freenet.de ] > wrote:
>> Hello.
>> I would like some help.
>> I have two gambas apps, for example,
>> app1.gambas and app2.gambas. I start app2 from app1 as a process.
>> myApp2Process = SHELL app2.gambas as "myApp2Process".
>> app2 runs in the background.
>> After that I can receive the feedback with:
>> Public Sub myApp2Process_Read()
>> .....
>> End
>> But what I need is also send the commands to app2 and get appropriate
>> feedback. For example.
>> app2 "multiply 2x2" and get 4 as feedback. Can anyone give me a hint on
>> how to do this in app2. A small example would be nice.
>> Regards
>> Ivan
>> ----[ [ http://gambaswiki.org/wiki/doc/netiquette |
>> http://gambaswiki.org/wiki/doc/netiquette ] ]----
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20210424/f0d13dec/attachment-0001.htm>
More information about the User
mailing list