[Gambas-user] Standard Input & Exec

John Rose john.aaron.rose at ...626...
Thu Feb 26 11:25:07 CET 2015


I asked Tobi by direct email about my problem. He gave me the solution
in his reply (shown below) and I coded it as:

aExecParameters = ["/opt/Enigma/enigma_app", 3, sReflector, sLeftRotor,
sMiddleRotor, sRightRotor, sSteckers, sRings, sGrund]
penigma_app = Exec aExecParameters For Read Write As "EnigmaResultsDetail"
Print #penigma_app, sPlain
Do
  Wait 0.1
Loop Until penigma_app.State <> Process.Running

Thus, I had to remove the Wait keyword in the Exec command and simulate
it manually.

Interestingly, even though the Gambas documentation stated that I would
have to run the app outside the IDE (i.e. by launching the executable
from the CLI), it still worked OK when I used the Debug command within
the IDE.

John


-------- Forwarded Message --------
Subject: 	Re: [Gambas-user] Standard Input & Exec
Date: 	Thu, 26 Feb 2015 00:43:46 +0100
From: 	Tobias Boege <taboege at ...626...>
Reply-To: 	mailing list for gambas users
<gambas-user at lists.sourceforge.net>
To: 	mailing list for gambas users <gambas-user at lists.sourceforge.net>



On Wed, 25 Feb 2015, John Rose wrote:
> I want an Exec command to take input from Standard Input. I've looked at
> the Gambas documentation and it states:
> "If WRITE is specified, data can be sent to the command standard input
> by using the Process object with common output instructions: PRINT,
> WRITE, ... Note that a reference to the Process object is required.".
> 
> I don't understand the above. It seems to imply that I should code
> penigma_app.Print sPlain (with Dim sPlain As String and sPlain =
> "QWERTYU")  where my Exec statement is:
> penigma_app = Exec aExecParameters Wait For Read Write As
> "EnigmaResultsDetail"
> and I have "Dim penigma_app as Process". However, the IDE does not show
> Print after coding penigma_app. and the compiler objects.
> 

The documentation correctly says PRINT, WRITE, ... *instructions*. These are
keywords of the Gambas language, not methods of a class:

  Dim hProc As Process

  hProc = Exec ["prog", "arg"] For Read Write
  Print #hProc, "input"

> What do I need to do. Also, the Gambas documentation states:
> "If you plan to control an application by sending commands to standard
> input then testing should be performed outside of the IDE (i.e. make an
> executable and launch it from the command line) as the console within
> the development environment is not a true virtual terminal and will
> cause unexpected results.".
> So presumably, I would need to test the app after creating an
> executable. So if the executable was named EnigmaWehrmacht.gambas what
> would I need to enter on the command line to test this app?
> 

If your project directory is at /path/to/project, you do:

 $ cd /path/to/project
 $ gbc3 -ga  # Re-compile the project
 $ gbx3      # Execute the compiled files

This way does not require an executable .gambas archive. But you can also
try it with such an archive[*]:

 $ cd /path/to/project
 $ gba3                 # Create project.gambas
 $ gbr3 project.gambas  # Run it

[*] And sometimes you want to test your project with an executable archive,
    too, because certain ways of accessing project data files or something
    may work when you run the project under the IDE and via the first way,
    but not if you run from an executable archive. But this is entirely
    different story.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Gambas-user mailing list
Gambas-user at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user






More information about the User mailing list