android
  #1  
Old 01-31-2011, 01:42 PM
Nohajc's Avatar
Nohajc Nohajc is offline
Junior Member
 
Join Date: Mar 2010
Location: Czech Republic
Posts: 68
Default Debug function print() on ZEN directly

Is it possible to redirect print output somewhere else than the SIM console so I could collect debugging info directly on ZEN? Into some log.txt file or something...

My app is entirely dependant on the accelerometer, so most of the functions have to be tested on the player anyway. And when you have an unexpected crash, it's annoying you cannot read any useful info.
__________________
There was a little man...
Reply With Quote

Advertisement [Remove Advertisement]

  #2  
Old 01-31-2011, 02:59 PM
Habhome's Avatar
Habhome Habhome is offline
Moderator
 
Join Date: Jan 2010
Location: Sweden
Posts: 1,079
Default

Well, not entirely as you want it. But you can write to a log file. Just make sure to open and close the session with every entry so you always have a closed file if something has gone through. You need to use the file-writer functions though and not the print().
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine
Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it!
Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it.
Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^
Reply With Quote

  #3  
Old 01-31-2011, 03:40 PM
Nohajc's Avatar
Nohajc Nohajc is offline
Junior Member
 
Join Date: Mar 2010
Location: Czech Republic
Posts: 68
Default

Yeah, I knew I can write to a log file. Just like any other file output. What I need is to get the same runtime error messages like the ones from the simulator.

Not possible, you say?
__________________
There was a little man...
Reply With Quote

  #4  
Old 01-31-2011, 03:55 PM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 554
Default

It is infact possible:

you need to use the pcall(some_function_name)

ie:;

Code:
function foo()
   some code
   if unexpected_condition then error() end
  some code
print (a[i]) -- potential error: 'a' may not be a table\
somecode
end

and to call the function do
if pcall(foo) then
 --no errors while running foo
regular code
else
-- foo raised an error: take appropiate actions
error handling code
end
pcall function calls its first argument in protected mode, so that it catches any errors while running the function it is on.


I will respond later with a better exlplanion about that function

------------------

you might also want to try

print(debug.traceback()) -- or write to a file with debug.traceback()

doing this is print the current execuation of the code
Reply With Quote

  #5  
Old 02-01-2011, 09:43 AM
Nohajc's Avatar
Nohajc Nohajc is offline
Junior Member
 
Join Date: Mar 2010
Location: Czech Republic
Posts: 68
Default

Thanks. I'm not sure I understand this process perfectly but I'll experiment with it.
__________________
There was a little man...
Reply With Quote

  #6  
Old 02-04-2011, 04:55 AM
Nohajc's Avatar
Nohajc Nohajc is offline
Junior Member
 
Join Date: Mar 2010
Location: Czech Republic
Posts: 68
Default

OK, thanks for the advice, now I know how to use pcall and it really works.
__________________
There was a little man...
Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 01:27 PM.