[Gambas-user] Control GUI (Qt5) Gambas program via Standard Input

Brian G brian at westwoodsvcs.com
Mon Feb 13 02:33:02 CET 2023


> Can you, or someone please show me an example of HOW to declare a "Static
> Function" in Gambas.
> 
> Thank you,
> J. Jordan

I am not sure I completely understand what your doing but if you are starting a stand alone app running in the
app tray etc and you what to send it messages via stdin and std out. Ussually it is a pipe of some kind often beloning to
the task that started the app. Hope this helps.

>echo "hello" > /proc/$(pgrep -f std-in-test)/fd/0
>
> because it is echoed in the IDE console or Teminal but I cannot
> figure out how to intercept and process it.
>
> Here is the code for std-in-test.gambas FMain
>
> Public Sub _New() Label1.Text = Application.Id End
>
> Public Sub Application_Read() Debug "App_Read" End
>

You may want to use names pipes for a know endpoint

when you launch an app from the command line 

echo "hello" |  myapp
or
echo "hello" > 

the shell takes care of the creation of the pipes used to map the input and outputs to the stdin and stdout of the
the starting task my own the pipe.

Rather named pipes:
examples:
the recieving task
Static myinput As File

Public Sub Form_Open()

    Dim buffer As String

    myinput = Open Pipe "/tmp/mydesk" For Read Watch
    TextBox1.text = Application.id & " " & Application.name
    Print "pipe is open"; myinput

End

Public Sub file_read()

    Dim value As String

    Print "got message"

    While Lof(Last)
        value = Read #Last, Lof(Last)
        FMain.textbox2.text = value
    Wend

End


Public Sub Form_Close()

    Print "close the input file"
    Close #myinput

End

the sending task:
Public Sub Main()

    Dim sendto As String = "/tmp/mydesk"
    Dim myoutput As File
    Dim counter As Integer = 0

    myoutput = Open Pipe "/tmp/mydesk" For Write

    While True
        Write #myoutput, "please pay attention - " & counter
        Print " Sent message"
        Wait 2
        If counter = 100 Then
            Break
        Endif
        Inc counter
    Wend

    Close myoutput

End



"Failure is the key to success; 
 each mistake teaches us something"  .. Morihei Ueshiba
Brian G

----- On Feb 12, 2023, at 12:43 AM,  james at lixce.com wrote:


> Thank you, I saw in the Gambas Help that is must be declared as "static method"
> but perhaps that is my problem, I cannot figure out how to declare a static
> function.  I have tried:
> 
> Static Public Function Application_Read(stIn As String) As String
> Static Private Function Application_Read(stIn As String) As String
> Static Public Function Application_Read()  As String
> Static Private Function Application_Read() As String
> Static Function Application_Read() As String
> Static Public Function Appication_Read()
> Static Private Function Application_Read()
> Static Function Application_Read()
> 
> Along with "Sub" variations of all of those declarations with and without return
> values but nothing works.
> 
> I have looked through the source code of the IDE and do not see anything special
> in the Static Sub declarations.
> 
> I have searched the internet for how to declare a static function in Gambas to
> no avail and even read through Static declarations in C, C++ and Java.
> 
> Can you, or someone please show me an example of HOW to declare a "Static
> Function" in Gambas.
> 
> Thank you,
> J. Jordan
> 
> 
> 
> 
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----


More information about the User mailing list