Page 1 of 2

System console output

Posted: Mon Jul 31, 2017 8:46 pm
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.

Re: System console output

Posted: Mon Jul 31, 2017 9:42 pm
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.

Re: System console output

Posted: Mon Jul 31, 2017 10:20 pm
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.

Re: System console output

Posted: Tue Feb 13, 2018 3:57 pm
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?

Re: System console output

Posted: Tue Feb 13, 2018 5:43 pm
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.

Re: System console output

Posted: Thu Feb 15, 2018 3:18 am
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...

Re: System console output

Posted: Thu Feb 15, 2018 7:12 am
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.

Re: System console output

Posted: Fri Feb 16, 2018 11:11 pm
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().

Re: System console output

Posted: Thu Mar 15, 2018 8:54 pm
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.

Re: System console output

Posted: Fri Mar 16, 2018 11:41 pm
by airsoftsoftwair
If you set "EnableDebug" to TRUE in @OPTIONS, everything should be as before.