System console output

Discuss GUI programming with the MUI Royale plugin here
User avatar
r-tea
Posts: 133
Joined: Tue Feb 16, 2016 11:48 pm
Location: Zdzieszowice, Poland
Contact:

System console output

Post by r-tea »

How to make my MUI program outputs messages to the system console/Shell widnow? Print() seems to output the Hollywood display which I don't need and have it hidden.
User avatar
jPV
Posts: 603
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: System console output

Post by jPV »

I use DebugPrint... If you're using, for example, Cubic IDE then it outputs to its debug window, but when running a compiled program, it outputs to console window.
User avatar
r-tea
Posts: 133
Joined: Tue Feb 16, 2016 11:48 pm
Location: Zdzieszowice, Poland
Contact:

Re: System console output

Post by r-tea »

Thank You! It works. I wouldn't ever think to have a look at DebugPrint() since it's looksto be intended for debug purposes only.
Yes, I use CubicIDE.
User avatar
jPV
Posts: 603
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: System console output

Post by jPV »

Although now when the debug output is disabled by default for compiled programs (since 7.1, and with some good reasons), I'm also wondering what command should I use to print text to the console :) I have commandline support for almost all of my programs, and I've just been using DebugPrint to display some info and list the available commands etc. Any ideas? Of course I could enable the debug output manually, but it would be cleaner to have it disabled as suggested. Maybe some new shell/console support commands Andreas?
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: System console output

Post by airsoftsoftwair »

Yes, it would make sense to add some specific console functions now because currently you can't have DebugPrint() enabled without also enabling DebugOutput() which could expose algorithms in your script.
p-OS
Posts: 167
Joined: Mon Nov 01, 2010 11:56 pm

Re: System console output

Post by p-OS »

I'm also not glad about the fact, that explicit debug messages now can only be output if implicit are also allowed.

First of all: Though DebugPrint will not output to Shell window any more it is still possible to print to Cubic Output section even without enabling DebugOutput() !

For printing to the shell window your program was started from or to open a Console Window when started from Desktop, you could simply use this code:

Code: Select all

Output=Function(string)   StringToFile(string,"CONSOLE:")  EndFunction        
OutputN=Function(string) Output(string .. "\n")  EndFunction
BTW, instead of "CONSOLE:" you could also simply use "*"

If you don't want to adapt your program to much, you could add these line of code:

Code: Select all

OrigDebugPrint=DebugPrint ; for the case we want still to do real debug output ,e.g. in Cubic Output section
DebugPrint=OutputN
If your script does not use ISO 8859-1 encoding but UTF8 try this:

Code: Select all

Output=Function(string)
  Local fh=OpenFile(Nil,"*",#MODE_WRITE)
  WriteString(fh,ConvertStr(string,#ENCODING_UTF8,#ENCODING_AMIGA))  
  CloseFile(fh)
EndFunction      
Hope this helps...
User avatar
jPV
Posts: 603
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: System console output

Post by jPV »

Thanks! That was a good tip.

Another option is to print like this:

Code: Select all

Echo=Function(string) Execute("echo \""..ReplaceStr(string,"\n","*N").."\"")  EndFunction 
But the problem with these workarounds is that they aren't universal and will fail on other platforms.

I've just loved the way that DebugPrint did print in Cubic's output window when coding, and then to console when running a compiled binary. It's been very handy and hopefully we get some similar option again. Pure console output functions would be nice, but this kind of combined usage would be even nicer.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: System console output

Post by airsoftsoftwair »

I've just loved the way that DebugPrint did print in Cubic's output window when coding, and then to console when running a compiled binary. It's been very handy and hopefully we get some similar option again. Pure console output functions would be nice, but this kind of combined usage would be even nicer.
Well, to all who want the old behaviour back: All you have to do is to set "EnableDebug" to TRUE in @OPTIONS and everything will be exactly as before. So no big deal, actually.

That being said, I agree that disabling all debug functions globally by default when compiling probably wasn't the best idea. I think it would have been better to just disable DebugOutput() and its console counterpart by default when compiling and keep all other functions working. Maybe I'll do it like that in the next version. Having DebugPrint() and the likes enabled by default doesn't pose any security risk anyway so the only thing that should really be disabled by default is DebugOutput().
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: System console output

Post by djrikki »

WTF happened to debugprint?

I have tried debugoutput(true) and that doesn't work either!

Cannot live without a debugger :S

Edit: I see that @OPTIONS works, but setting DebugOutput does not.
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: System console output

Post by airsoftsoftwair »

If you set "EnableDebug" to TRUE in @OPTIONS, everything should be as before.
Post Reply