PRIVATE myProcess AS Process PUBLIC SUB _new() ME.Title = "Working with EXEC" ComboBox1.add("gambas") ComboBox1.add("ls") ComboBox1.add("/usr/bin/X11/xcalc") ComboBox1.add("gimp") ' the programs must be installed! END PUBLIC SUB btnFire_Click() IF Trim(ComboBox1.Text) <> "" THEN 'Trim strips the whitespaces from a string TextArea1.Text = "" TextArea2.Text = Trim(ComboBox1.Text) ' call it EXEC [ComboBox1.Text] FOR READ WRITE AS myProcess ELSE TextArea1.Text = "please choose or enter a program to execute" ENDIF END PUBLIC SUB btnClose_Click() ME.Close() END PUBLIC SUB Process_Write(sData AS String) ' if something is coming back ' the event 'Process.Write' of the class process calls this function TextArea2.Text = " Process '" & myProcess.command & "' " & sData END PUBLIC SUB Process_Error(sData AS String) ' if an error occurred ' the event 'Process.Error' of the class process calls this function TextArea1.Text = " Process '" & myProcess.command & "' " & sData END PUBLIC SUB Process_Kill() ' if the process is killed ' the event 'Process.Kill' of the class process calls this function myProcess = NULL END
-- JochenGeorges - 28 Dec 2004