AppleScript issue

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

mcelvain
Posts: 58
Joined: Sat Apr 29, 2023 10:13 pm

AppleScript issue

Post by mcelvain » Fri May 19, 2023 9:01 pm

Re: AppleScript, where “tScript” is my script:

Does SuperCard

get script(do,tScript,AppleScript)

=

LiveCard:

do tScript as “AppleScript”

??

{ doesn’t seem to, but neither platform returns errors}

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: AppleScript issue

Post by dunbarx » Fri May 19, 2023 10:01 pm

It has been a very long time, HC ages ago, that I executed as script as AppleScript.

I tried the LC dictionary example:

Code: Select all

do "result = 1 + 1" as "vbscript"
answer the result
and got at execution error. A simple line of LC code run "as AppleScript" gave the same error.

I am not much help.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10045
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: AppleScript issue

Post by FourthWorld » Fri May 19, 2023 10:06 pm

@mcelvain: Yes, those two examples should be roughly equivalent. Did the LC script not work?

@dunbarx: Do you have VB Script installed on your machine? Does the same script work outside of LC?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

mcelvain
Posts: 58
Joined: Sat Apr 29, 2023 10:13 pm

Re: AppleScript issue

Post by mcelvain » Fri May 19, 2023 10:08 pm

Thank-you, Craig.

Is it possible for LC to pass Terminal commands ?

Emily-Elizabeth
Posts: 101
Joined: Mon Jan 03, 2022 7:10 pm

Re: AppleScript issue

Post by Emily-Elizabeth » Fri May 19, 2023 11:24 pm

Look up "shell" in the dictionary, that will allow you to run terminal commands

mcelvain
Posts: 58
Joined: Sat Apr 29, 2023 10:13 pm

Re: AppleScript issue

Post by mcelvain » Sun May 21, 2023 6:39 am

no VB Script on this machine, which is a Mac.

Thank-you for recommending beginning with the dictionary "shell" definition/explanation.

One additional question which I should probably post as a new query: How do I enlarge the script editor text which loads in the variable window upon clicking a specific variable ?

This window is a terrific tool, which also stays open through multiple handler calls.

I cannot find a solution for resizing this text in preferences.

Thank-you !

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: AppleScript issue

Post by dunbarx » Mon May 22, 2023 3:51 am

Hi.

The preferences pane offers the textSize right near the top. You will find it.

Interestingly, this did not work:

Code: Select all

set  the textsize of fld 1  of stack "revNewScriptEditor" to 18
and I have hacked this stack now and then,
Field 1 is the default field if only one object's script is being examined. If you add others, they are field 2, 3, etc.

I have colored groups of lines in the SE, treating it just like any ordinary stack, which it pretty much is. I do this all the time so I can scroll through an entire script and find my way back to certain regions quickly. I am not sure why the above code does not work. I will check when I get to my office tomorrow, and see why I can change the backColor of, say, line 200 - 300, but not chase the text size here on my laptop.

Craig

SparkOut
Posts: 2944
Joined: Sun Sep 23, 2007 4:58 pm

Re: AppleScript issue

Post by SparkOut » Mon May 22, 2023 6:34 pm

stack "revNewScriptEditor" is probably the template stack, from which each instance of the SE is generated.
It probably needs to be referred to as "revNewScriptEditor 1" (or subsequent index number if you have opened more than one SE instance).

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: AppleScript issue

Post by dunbarx » Mon May 22, 2023 9:50 pm

Sparkout.

I am sure you are correct, as I have always used "revnewScriptEditor 1".

But I got an error trying it, so I lost the "1".

I wonder if I typed "revnewScriptEditor1". I would not put that past me.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10045
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: AppleScript issue

Post by FourthWorld » Tue May 23, 2023 3:38 am

The script editor may have multiple windows. You could use "the windows" function to find the topmost one beginning with "revScriptEditor", but perhaps easier is a plugin script that triggers on launch to set the values right in the master Script Editor.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10094
Joined: Fri Feb 19, 2010 10:17 am

Re: AppleScript issue

Post by richmond62 » Tue May 23, 2023 9:04 am

The script editor may have multiple windows.
Indeed it may . . .
-
SShot 2023-05-23 at 11.02.14.jpg
-
BUT, I think that this . . .
-
doubleTrouble.jpg
-
Where the scriptEditor allows 2 views of the same script would be fantastic.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Re: AppleScript issue

Post by bn » Tue May 23, 2023 10:24 am

mcelvain wrote:
Sun May 21, 2023 6:39 am
One additional question which I should probably post as a new query: How do I enlarge the script editor text which loads in the variable window upon clicking a specific variable ?
This window is a terrific tool, which also stays open through multiple handler calls.
I cannot find a solution for resizing this text in preferences.
If you mean the the window that pops up when in the Debugger you click on a variable then that window is a stack called "revVariableVisualizer 1" with an increasing numbering when invoked repeatedly.

That stack is created on the fly by stack "revSEVariablesPaneBehavior" in handler "private on nodeCreateVisualizationObject" beginning at line 298 in LC 9.6.9.

To change the textSize of the field "Value" of said stack you could add a line (marked --< added)

Code: Select all

private on nodeCreateVisualizationObject pPathToNode
   add 1 to sVisualizationObjectCount
   
   local tOldLock
   put the lockMessages into tOldLock
   lock messages
   
   local tStack
   reset the templateStack
   set the _ideoverride of the templateStack to true
   set the width of templateStack to 270
   set the height of templateStack to 250
   
   create invisible stack "revVariableVisualizer " & sVisualizationObjectCount
   put the long id of it into tStack
   set the behavior of tStack to the long id of stack revIDEScriptEditorBehavior("variable visualizer")
   set the cMutable of tStack to true
   set the destroyStack of tStack to true
   set the destroyWindow of tStack to true
   set the title of tStack to "Value : " & friendlyNodeReference(pPathToNode)
   revMetadataSet the name of stack tStack, "general", "visualizer", true
   
   -- generate variable visualizer UI
   local tOldDefaultStack
   put the defaultStack into tOldDefaultStack
   set the defaultStack to the short name of tStack
   reset the templateButton
   set the height of the templateButton to 23
   create button "Apply"
   reset the templateField
   set the vScrollbar of the templateField to true
   set the textSize of the templateField to 16 --< added
   create field "Value"
    -- more code
That will set the textSize of field "Value" to 16

As far as I know there is no way to set a preference for this.

To make it easy I append a stack that patches stack "revSEVariablesPaneBehavior" with the modification.
That patch stack is tested using LC 9.6.9 and it works. Since very little has changed in the debugging part of LC recently it should work at least with the LC 9.x.x series (not tested).

The changes the patch applies are temporary and are gone when you quit LC. You would have to run it again when starting LC.

Kind regards
Bernd

Click on the button e.g. after starting LC
Attachments
Increase textSize of VariableWatcher.livecode.zip
(2.51 KiB) Downloaded 149 times

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Re: AppleScript issue

Post by bn » Tue May 23, 2023 2:05 pm

bn wrote:
Tue May 23, 2023 10:24 am
To make it easy I append a stack that patches stack "revSEVariablesPaneBehavior" with the modification.
That patch stack is tested using LC 9.6.9 and it works. Since very little has changed in the debugging part of LC recently it should work at least with the LC 9.x.x series (not tested).
If you want to use above stack in versions of LC <= 9.6.5 you have to open the Script Editor once before applying the patch. Tested as far back as 9.0.0.
Starting LC 9.6.6 you do not have to start the Script Editor first. Tested including LC 10.0.0 DP5.

Kind regards
Bernd

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10045
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: AppleScript issue

Post by FourthWorld » Tue May 23, 2023 3:14 pm

Historically, having an easy way to render all script-related text consistently is what the scriptTextFont and scriptTextSize were for, from HyperCard though SuperCard and MetaCard.

https://quality.livecode.com/show_bug.cgi?id=11596
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10094
Joined: Fri Feb 19, 2010 10:17 am

Re: AppleScript issue

Post by richmond62 » Tue May 23, 2023 5:49 pm

"LiveCode QCC 2013-12-16 12:30:00 EST

Hi Richard,

thank you for logging this report, we are currently reviewing it.

We will update you when the status changes or information in the report is updated.

Kind Regards,"


my emphasis.

About 11 and a half years ago

Post Reply