> I have searched around with Google but still can not find an other problem > like mine. > My code below base on the Console example project of Gambas. > I want run a process like this: > > PUBLIC $mainProcess AS Process > > PUBLIC SUB Form_Open() > > $mainProcess = SHELL "7z x /demo/file.7z -o/tmp" FOR READ WRITE ' > Extract /demo/file.7z to /tmp folder, same problem with EXEC > > END > > Note that I have extracted this file to /tmp before, so 7z will ask > overwrite or not. And I want take control and answer from Gambas: > > PUBLIC SUB Process_Read() > > DIM sLine AS String > > LINE INPUT #$mainProcess, sLine ' I used READ #$mainProcess, sLine, -256 > too, but it break some line, and read multiple line in same moment > txtLog.Text &= sLine & gb.newline > IF InStr(sLine, "(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all > / (Q)uit?") > 0 THEN > ' A message.question here, then print an answer like this > PRINT #$mainProcess, "Q" ' Quit the process > ENDIF > > END > > Also I created a button to manually response to process: > > PRIVATE SUB Button1_Click() > > PRINT #$mainProcess, "Q" > > END > > Finally, to detect program working: > > PUBLIC SUB Process_Kill() > > Message.Info("Process terminated") > > END > > My problem is, if I use FOR READ WRITE, I can't get the process output > until process terminates (SUB Process_Read() seems not work - txtLog is > blank). When I click the Button1, the process terminates immediately, and > now the output appears in txtLog text box. > If I use FOR INPUT OUTPUT, I can get the output like I want - the output > appears in txtLog text box, (SUB Process_Read() work => PRINT "Quit" > message to process) but process not terminates, even when I click Button1. >
You must not use 'LINE INPUT #Process, Var' to read a process output in Process_Read. You must use 'READ #Process, Var, -MaxLength', add 'Var' to a 'Buffer', and extract lines from that 'Buffer'. Without a full project to test, I cannot say more at the moment. Note that Gambas 3 is more clever than Gambas 2 for that kind of situation. > An other small problem is from Gambas IDE. I use shortcut keys (Ctrl+C, > Ctrl+X) to copy, cut text from Gambas Editor (when cut, the selected text > disappears), but I can not paste anywhere, even back to Gambas editor. But > I use the context menu, it works fine. CTRL+V works perfectly there. Do you have more details? -- Benoît Minisini ------------------------------------------------------------------------------ This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user