System console output

Discuss GUI programming with the MUI Royale plugin here
Post Reply
User avatar
r-tea
Posts: 80
Joined: Wed Feb 17, 2016 12:48 am
Location: Zdzieszowice, Poland
Contact:

System console output

Post by r-tea » Mon Jul 31, 2017 8:46 pm

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: 156
Joined: Sat Mar 26, 2016 11:44 am
Location: RNO
Contact:

Re: System console output

Post by jPV » Mon Jul 31, 2017 9:42 pm

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: 80
Joined: Wed Feb 17, 2016 12:48 am
Location: Zdzieszowice, Poland
Contact:

Re: System console output

Post by r-tea » Mon Jul 31, 2017 10:20 pm

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: 156
Joined: Sat Mar 26, 2016 11:44 am
Location: RNO
Contact:

Re: System console output

Post by jPV » Tue Feb 13, 2018 4:57 pm

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: 2573
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany
Contact:

Re: System console output

Post by airsoftsoftwair » Tue Feb 13, 2018 6:43 pm

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: 89
Joined: Tue Nov 02, 2010 12:56 am

Re: System console output

Post by p-OS » Thu Feb 15, 2018 4:18 am

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: 156
Joined: Sat Mar 26, 2016 11:44 am
Location: RNO
Contact:

Re: System console output

Post by jPV » Thu Feb 15, 2018 8:12 am

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: 2573
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany
Contact:

Re: System console output

Post by airsoftsoftwair » Sat Feb 17, 2018 12:11 am

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 » Thu Mar 15, 2018 9:54 pm

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: 2573
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany
Contact:

Re: System console output

Post by airsoftsoftwair » Sat Mar 17, 2018 12:41 am

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

Post Reply