Ha! Should have tried that right off!.  Thanks.

On Tuesday, January 2, 2024 at 8:16:51 PM UTC-5 Félix wrote:

> Hi Thomas! :)
>
> I gather that by an 'Output window' you mean the LeoJS Log Window? (The 
> equivalent of Leo's Log Window)
> [image: log_pane.png]
>
> Using *console.log (*which is indeed the equivalent of python's *print 
> *function, 
> which prints in the terminal instead of Leo's Log Window), will itself 
> indeed print in the developer's-tools-terminal. (not recommended)
>
> What I recommend in contrast, is the *g.es <http://g.es> *function (and 
> other 'g' methods like es_print, etc.) which does print in the Log Window. 
>
> See (and study) this example script that gives a few pointers on how to do 
> various useful stuff :
>
> @language javascript
> const vscode = g.app.vscode;
> g.es("hahahaha");
> // 'await' for doCommandByName required only if other code in script is 
> 'awaited'.
> await c.doCommandByName('insert-headline-time');
>
> const userInput = await vscode.window.showInputBox({
>     placeHolder: 'Enter something', // Placeholder text in the input box
>     prompt: 'Please enter some text:', // Prompt message above the input 
> box
> });
> if (userInput === undefined) {
>     g.es('User canceled the input.');
> } else {
>     g.es('User input:', userInput);
> }
> try {
>     const apiUrl = 'https://jsonplaceholder.typicode.com/users';
>     const response = await fetch(apiUrl);
>     g.es("about to call");
>     if (!response.ok) {
>         throw new Error('Network response was not ok');
>     }
>     const data = await response.json();
>     g.es("got it!!", JSON.stringify(data));
> } catch (error) {
>     g.es("oh no!");
>     console.error('Fetch error:', error);
> }
>
>
> It will insert the current time on the selected node, then pop an input 
> box and print it back out in the log window, along with the result of an 
> HTTP fetch call to some test API. Here is a screenshot of the result of 
> running this script online in vscode on the web :
> [image: screen_script_web.png]
>
> Hope this helps! 
>
> Félix
>
> On Tuesday, January 2, 2024 at 12:43:46 PM UTC-5 tbp1...@gmail.com wrote:
>
>> This script apparently runs without error but nothing shows in the Output 
>> window:
>>
>> @language javascript
>> console.log('this is another test');
>>
>> Using print() doesn't work, of course, because there isn't a print() 
>> function.  How can we get a visible output?
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/aad78de7-378b-45eb-9e88-4422c436ebban%40googlegroups.com.

Reply via email to