Terminal Windows in Main-Form

Post your Gambas programming questions here.
Post Reply
User avatar
Gamba_Dance
Posts: 11
Joined: Wednesday 30th September 2020 8:43am

Terminal Windows in Main-Form

Post by Gamba_Dance »

Hallo,

because I need a terminal window for running a command, I would like to ask,
how can I integrate this into a form-tool f.e. like text.aera? Appreciate to hear
from you!


Gamba_Dance
If even one line of "Hello World" program code requires an intelligent :idea: riginator, how can anyone claim that the human genome with 3,300,000,000 lines :o f intelligent code could have been created by chance :?:
User avatar
BruceSteers
Posts: 1505
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Terminal Windows in Main-Form

Post by BruceSteers »

TerminalView is the best component to have an interactive terminal.

Shell output from the Shell or Exec command can be directed to a text area like...

Shell 'ls/home' To TextArea1.Text

Also you can
Shell 'command" For Input Output

And set up a Process_Read() event handler.
Info on how to do this is on the gambas wiki shell help.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1505
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Terminal Windows in Main-Form

Post by BruceSteers »

Sorry my last reply was brief as i was at work.

So...
If all you want is to see the output of a shell command and not type anything then it's very simple.

There are 2 ways.
Simply use the Shell or Exec command using the "To" keyword to direct the output straight to the TextArea object like this...

Shell "ls /home" To TextArea1.text
Or...
Exec ["ls", "/home"] To TextArea1.text
Another way is to set up a Read event handler that monitors for read events.
using the As keyword to assign events to a name. (in this case the name "Process")
Like this...
Public Sub Process_Read()
  Dim sLine As String
  Read #Last, sLine, -256
  TextArea1.Text &= sLine
  TextArea1.Pos = Len(TextArea1.Text)
  TextArea1.EnsureVisible
End

Public Sub RunCommand()
Shell "ls /home" For Input Output As "Process"
End
Or do you need something more advanced?
If at first you don't succeed , try doing something differently.
BruceS
User avatar
cogier
Site Admin
Posts: 1117
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Terminal Windows in Main-Form

Post by cogier »

Hi Gamba_Dance and welcome to the forum.

BruceSteers is right in what he says but if you do need an example I wrote a program with a Terminal in 7 lines of code that is on the Gambas Farm or available here. There are other examples on the Farm as well.

If you give us a bit more detail of what you are trying to do we could offer better advice.
User avatar
Gamba_Dance
Posts: 11
Joined: Wednesday 30th September 2020 8:43am

Re: Terminal Windows in Main-Form

Post by Gamba_Dance »

Hallo together and thank you very much, for your quick an friendly help.
I think your solutions will fetch my problem. Because I didn't find any
chat-code for Gambas, I wanna integrate a terminal-window with a chat-function,
for using in LAN intranet.

Gamba_Dance
If even one line of "Hello World" program code requires an intelligent :idea: riginator, how can anyone claim that the human genome with 3,300,000,000 lines :o f intelligent code could have been created by chance :?:
Post Reply