Page 1 of 1

stdout on macOS 11.0.1 - working??

Posted: Tue Jan 19, 2021 11:37 pm
by aetaylorBUSBnWt

Code: Select all

command debug tMessage
        write "AETDebug:" & tMessage & return to stdout
        write "AETDebug:" & tMessage & the long time & return to stdout

        put "file:" & specialfolderpath("desktop") & ":" & "AETdebug.txt" into theFile;
        put the long time & ": " & tMessage & return after URL theFile;
end debug
I have the above code to output messages.
The Livecode documentation seems to say that writing to stdout sends the message to the console.
Console on Big Sur is radically different from what I remember seeing in past version of macOs - not really sure when it changed.

Anyway the above code has no problem writing to the text file, but nothing shows up in the console.
Does it work for anybody?
Is there something special that I have to turn on?
Apple seems to have made Console quite complicated from what I remember.
Thanks,
Andrew

Re: stdout on macOS 11.0.1 - working??

Posted: Thu Jan 21, 2021 2:43 pm
by aetaylorBUSBnWt
Wow, I did not realize this was such an uninteresting question - lots of view, but no responses.

Re: stdout on macOS 11.0.1 - working??

Posted: Thu Jan 21, 2021 4:39 pm
by bogs
I'm not sure I'd agree it is uninteresting, I couldn't answer for sure for a couple reasons, not the least being that I don't have access to 'big sur' :D

Another reason would be I've never attempted what your asking about :|

However, while I'm not sure this would help you, I thought parts of it might pertain to your question.

For instance, this from M.W. -
Mark Wieder wrote: Works here, on linux at least.
Launch LC from a commandline, then from the messagebox type
write "hello, world" to stdout
I didn’t know you needed to launch it from
the command line.

Thanks,
JB
Without that, I don’t think that livecode could be associated with any
particular terminal.

In fact, I suspect that OSX would block any attempt from any non-descendent
application trying to write to a terminal (or at least hope so . . .)
This was from 2 years ago, though, but I'd still suggest perusing the thread to see if any of it will help you out ;)

Re: stdout on macOS 11.0.1 - working??

Posted: Thu Jan 21, 2021 7:08 pm
by jacque
If you're doing this in a standalone, "put" sends output to Console by default:

Code: Select all

put tMessage
In the IDE it goes to the message box instead.

Re: stdout on macOS 11.0.1 - working??

Posted: Thu Jan 21, 2021 7:24 pm
by dunbarx
Jacque.

I always wondered where a naked "put" command would go in a standalone. I did not think msg would magically appear.

But isnt "console" strictly a Windows thing? Or is there a Mac equivalent?

Craig

Re: stdout on macOS 11.0.1 - working??

Posted: Thu Jan 21, 2021 8:09 pm
by bogs
dunbarx wrote:
Thu Jan 21, 2021 7:24 pm
But isnt "console" strictly a Windows thing? Or is there a Mac equivalent?
Console.app on OSX last I knew.

Re: stdout on macOS 11.0.1 - working??

Posted: Sat Jan 23, 2021 12:02 am
by aetaylorBUSBnWt
macOSX is descended from UNIX, so has a console application, Terminal and other UNIX utilities.

I had created a stack with a single card and a button and a text field.

I was running inside LiveCode (I have never produced an application that runs by itself).

I wanted to have the ability to send logging messages out to the console because that is typically available on Mac, Windows and Unix.
In addition, if enabled, echo those same messages to a file.
So I was planning to implement a "logMessage" handler since LiveCode's "log" command calls that if it exists.

The LiveCode Dictionary states that on OS X, the standard output is the Console window.
Apparently the Dictionary entry needs some enhancement to specify what else you need to do so that:

Code: Select all

write "this is some text I want to see" & return to stdout
does send the text to the Console.

There is no mention of what it does on a Windows system.

Re: stdout on macOS 11.0.1 - working??

Posted: Sat Jan 23, 2021 2:33 pm
by bogs
https://livecode.fandom.com/wiki/Write_to_file

In the comments below the entry for 'write' in Max's wiki, this is shown -
comments wrote: MaxV2 ·3/1/2018
benr_mc@cogapp.com:

Note that, while as mentioned above on Unix systems (including Mac OS X) standard output is always open, on Windows it is not. Normally on Windows the result of a write ... to stdout will be an error "error writing file" unless the standard output was opened. AFAICT, the only way to open it is to launch the Rev app from the command line with the output being piped to another command or directed to a file For example, if you launch your app like this

myapp.exe > output.txt

then a file 'output.txt' will be created (or deleted and recreated), and anything that the app writes to stdout will go to this file. (Using ">>" instead of ">" will append to output.txt rather than overwriting it.) Similarly "2>" directs the stderr to a file, so you could use this to capture both:

myapp.exe > output.txt 2> error.txt
I made note of a couple things, one being that for the bare

Code: Select all

write x to stdout
to work from the IDE on either 'nix or win, I first had to launch the IDE from the CLI interface for that OS.

From reading in the help all the way back to Mc, I gather there is a way to do this from a standalone by opening the CLI as a process, but I was unable to verify that within the IDE itself, so I am still missing something in the secret sauce to help you out.
aPic_mcStdOut.png
If I add a pinch of this, and a smidge of that....