[Gambas-user] Writing (or Printing) data to a process
Werner
wdahn at ...1000...
Tue May 1 04:28:03 CEST 2007
easuter wrote:
> Hi there!
>
> I'm a relatively novice gambas user, but I'm learning fast ;)
> I'm running Gambas2 1.9.47
>
> My problem is a s follows: I need to be able to send a string to a virtual
> terminal created by the following EXEC:
>
> DIM hProc AS Process
>
> EXEC [ "command", "-args"] FOR INPUT OUTPUT AS "hProc"
>
> PRINT #hProc, TextBox1.Text
>
> However, when I run my app the IDE spits out this error:
>
> Null Object
>
> and then jumps onto the PRINT line.
>
> What am I missing here?
> I can't find examples of writing data to a process in the gambas docs, only
> reading from a process is there.
>
> Thanks in advance!
>
> Eugéne
>
I have done something similar recently to control the Videolan video
player/transcoder/streamer. Here is a code snippet:
'----------------------------------------------
PRIVATE $vlc AS Process 'note: this is a global variable
PUBLIC SUB Form_Open()
...
$vlc = EXEC ["vlc", "-I", "rc", "--video-x=0", "--video-y=0"] FOR INPUT
OUTPUT AS "$vlc"
...
END
PUBLIC SUB $vlc_Read() 'reading from the $vlc process
DIM s AS String
DIM sa AS String[]
WHILE Lof($vlc) > 0
READ #$vlc, s, Lof($vlc)
s = Replace$(s, "\r", "") 'kick out carriage returns
sa = Split(s, "\n")
FOR EACH s IN sa
PRINT s
NEXT
WEND
END
'-------------------------------------
Example: if I want to send a command to the application I just do
PRINT #$vlc,"playlist"
and $vlc_Read will receive the playlist.
Regards
Werner
More information about the User
mailing list