Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5762 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

Hi,

I'm a newbie to Java and Groovy...

I'm trying to setup FM to interact with a Java application through its API which is supplied with the app.

I have made some functions/classes in the Eclipse IDE which work well, I get back the expected return in its console.

What I don't understand is, when I run the code in FM, I expected to get a return just like in the Eclipse console, but the result_text in FM stays empty (no errors).

Is there a difference in type of output?

Most of the code, gives a 'System.out.println' which gives no result in FM.

All help is welcome,

thanks,

Ruben

Posted

Ruben,

The output from System.out.println goes to the output stream for the java app. On OS X, you can view this in the /Applications/Utilities/Console.app application.

If you're running some command and truly need to capture the output of all calls to System.out.println you can replace the static "out" field in the System class with your own PrintStream, and get the contents of the stream when you're done:


ByteArrayOutputStream baos = new ByteArrayOutputStream();

System.out = new PrintStream(baos);

System.out.println("Hi there");

System.out.println("End of line");

System.out.flush();

return baos.toString();

This is a pretty bad hack, however, and should be avoided if possible. The utility you're using should return the result as a string or accept an OutputStream to write to, instead of sending important information to System.out. What kind of app are you interfacing with?

  • Newbies
Posted

Thanks shmert,

I'm trying to connect to the TWS application of Interactive Brokers with its API(9.62). Connecting to TWS from ScriptMaster works.

From within FM I wan't to retreive data and send orders automaticly based on some calculations in FM.

I'm not sure if I'm in the right direction, I tried to get some return, but the api's voids methods won't let me. It looks like I have to change the API itself (which I don't wan't to if not neccessery). Is there some workaround ?

If interested here is some more info about IB's TWS:

IB website: http://www.interactivebrokers.com

TWS application (individual demo): http://individuals.interactivebrokers.com/en/p.php?f=tws&p=d&ib_entity=llc

TWS API: http://www.interactivebrokers.com/en/p.php?f=programInterface&ib_entity=llc

thanks,

Ruben

This topic is 5762 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.