stdout on macOS 11.0.1 - working??

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
aetaylorBUSBnWt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Sep 20, 2012 5:11 pm

stdout on macOS 11.0.1 - working??

Post by aetaylorBUSBnWt » Tue Jan 19, 2021 11:37 pm

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

aetaylorBUSBnWt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Sep 20, 2012 5:11 pm

Re: stdout on macOS 11.0.1 - working??

Post by aetaylorBUSBnWt » Thu Jan 21, 2021 2:43 pm

Wow, I did not realize this was such an uninteresting question - lots of view, but no responses.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: stdout on macOS 11.0.1 - working??

Post by bogs » Thu Jan 21, 2021 4:39 pm

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 ;)
Image

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: stdout on macOS 11.0.1 - working??

Post by jacque » Thu Jan 21, 2021 7:08 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: stdout on macOS 11.0.1 - working??

Post by dunbarx » Thu Jan 21, 2021 7:24 pm

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

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: stdout on macOS 11.0.1 - working??

Post by bogs » Thu Jan 21, 2021 8:09 pm

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.
Image

aetaylorBUSBnWt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Sep 20, 2012 5:11 pm

Re: stdout on macOS 11.0.1 - working??

Post by aetaylorBUSBnWt » Sat Jan 23, 2021 12:02 am

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.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: stdout on macOS 11.0.1 - working??

Post by bogs » Sat Jan 23, 2021 2:33 pm

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....
Image

Post Reply

Return to “Mac OS”