print() issues

Hi,

I was wondering why on some IDE print() function is working and some other does not (output to terminal window). Of course errors and other Simulator messages are shown just fine in output window, this is only about print() method.

Corona Simulator via 3rd party tools"
CPM - works fine
IDEA IDE with Lua plugin - does not
Sumblime Text 2 - does not
Eclipse with Koneki plugin - does not

Standalone Corona Simulator:
Windows terminal - works fine
Mac - no terminal at all so does not work

What can be changed to setup print() method ? Or maybe why Windows terminal + CPM works fine.

Regards,
Tom [import]uid: 111283 topic_id: 21859 reply_id: 321859[/import]

You can launch corona via the terminal on a mac…

Applications > Corona SDK > Corona Terminal [import]uid: 84637 topic_id: 21859 reply_id: 86922[/import]

in IDEA IDE i setup Corona Terminal as a Lua interpreter. When Corona terminal is run separately (directly from Finder) all prints are going out. When Corona Terminal is run via IDE (IDEA) then no prints are in the output.

Does Corona terminal have any parameter to turn on / off this “debug” mode (standard print() function)?

Regards
Tom [import]uid: 111283 topic_id: 21859 reply_id: 86926[/import]

I would imagine this is missing hooks or whatever from the IDES/Editors > Terminal.

CPM I’m sure hooks to the terminal to show the print statements.

Your only course of action would be to contact the developers of the IDES/editors in question and ask them to support it, or if there open source, add the functionality yourself [import]uid: 84637 topic_id: 21859 reply_id: 86929[/import]

Put in main.lua.

[lua]function print (…)
local prnt = “”
for i = 1,#arg do
if arg[i] == nil then arg[i] = “not defined” end --difference between “nil” (string) and nil (undeclared).
prnt = prnt … tostring(arg[i]) … “\t”
end
return io.stdout:write ( string.format (prnt…"\n" ))
end[/lua] [import]uid: 79135 topic_id: 21859 reply_id: 86933[/import]

Just check at sublime / IDEA
also when using this method under different name like print10
same result, no print output to console, only pure Terminal and CPM does it.

Regards
Tom [import]uid: 111283 topic_id: 21859 reply_id: 86934[/import]

I’m able to get Corona to output to Sublime Text’s console no problem. These are the steps I used…

  1. Copy/paste this line of code into your main.lua:
    [lua]io.output():setvbuf(“no”)[/lua]

  2. Within Sublime…
    Choose Tools > Build System > New Build System
    Copy/paste this snippet into the blank text file that opens:
    [lua]{
    “cmd”: ["/Applications/CoronaSDK/simulator", “main.lua”]
    }[/lua]
    Save file w/ memorable name
    Choose Tools > Build System > then click on the newly saved file (a check mark should appear next to the name)

  3. Close any instances of Corona (if running)

  4. Open main.lua in Sublime & press command + B. This launches corona simulator and pipes the output to the console.
    Notes:
    There are a few bugs I’ve encountered, e.g. running a find and replace will kill the console & the underlying hook from Corona. I simply kill Corona, and run the build again from Sublime… takes a split second with keyboard shortcuts… stupid workaround, but the editor is still in beta.

I’m on a mac using Corona SDK 2011.704 (2011.12.8) & Sublime Text 2 (build 2181).

Hope this helps you out. [import]uid: 2108 topic_id: 21859 reply_id: 91185[/import]

@GP - I want to say thank you very much for such nice explanation!

Btw I was looking for exactly this to work on Sublime Editor some few days ago and I did not find it and now you came and post it here! :slight_smile:
Cheers,
Rodrigo. [import]uid: 89165 topic_id: 21859 reply_id: 91205[/import]

@GM Are you using Mac or Win version of Sublime?

I am not able to manage any output to sublime console neither to Corona shell.

(you can launch Corona shell by adding “shell”:true to a build file) [import]uid: 101952 topic_id: 21859 reply_id: 99520[/import]

When working with Eclipse(with or without Koneki) the steps are as Follows:

  1. in main.lua, near the top, put this line
io.stdout:setvbuf("line")

NOTE: This line fixes buffering issues for external IDEs. If you find you don’t get console output to your IDE until either A) closing the App, or B) sending a large amount of content to print, then this line is a very likely fix to get immediate output to console.

To Enable Running from Eclipse
2)Go to Run-> External Tools ->External Tools Configuration

3)Create a new Configuration with these settings:
Location: /Applications/CoronaSDK/Corona Simulator.app/Contents/MacOS/Corona Simulator (Or the location of your Corona Simulator)
Working Directory:${workspace_loc:/[Name of Workspace]} (Click Browse Workspace and select the location of your main.lua)
Arguments: main.lua

4)(optional) Map “run last configuration” to a good key (cmd R was my choice), otherwise click the Play button with the suitcase to run the app.

To Enable Debugging from Eclipse follow the instructions here(You will need Koneki): http://wiki.eclipse.org/Koneki/LDT/User_Guide#Remote_Debug [import]uid: 134101 topic_id: 21859 reply_id: 99535[/import]

On the Mac Simulator if you did not start Corona from the terminal, you can see the print output in the Console app. You can search for “Corona” within the Console app and you should see what is normally sent to the terminal.

The Console app is also useful for viewing output from the Xcode iOS simulator too. Just search for the name of your app and the information will show up. [import]uid: 7559 topic_id: 21859 reply_id: 99542[/import]

Note that there are a couple pitfalls when debugging Corona apps with Koneki, in particular you need to launch the application via the Corona debugger (vs. just the Simulator) if you want to get all the features…

I made a quick screencast to explain how to setup Koneki for debugging: http://www.youtube.com/watch?v=cZdn1yDrH8Y [import]uid: 116813 topic_id: 21859 reply_id: 102923[/import]