0

I am starting to learn AppleScript. I am running into a couple issues that I could not find document for.

script gt
  to sms to someone about m
    "sms to " & someone & " about " & m
  end

  to move pix to pos
    "moving " & pix & " to " & pos
  end

  to resize in pix to size
    "resize " & pix & " to " & size
  end
end
  1. for the to sms handler, I have to add the "to" after the sms. but I did not see any document mention the to as part of the directParamName
  2. for the to move handler, it does not seem like the directParameter need either of, in or even "to"
  3. for the to resize handler, I have to add either "in" or "of", or it won't work. if I add "to", it will complain "to" is used twice.

my question is why the "to sms" handler can have the "to", "to resize" handler must have either "in or of" while the "to move" handler needs none of these?

Thanks!

Here is the document I read a couple times but could not find any reference to any of this

1 Answer 1

1

Basically labeled parameters must contain a preposition and an argument.

Direct parameters are indicated by keyword of or in. In this case at least one parameter must follow. The documentation says

directParamName

An identifier for the direct parameter variable. If it is included,

directParamName must be listed immediately after the command name. The word of or in before directParamName is required in user-defined handlers, but is optional in terminology-defined handlers (for example, those defined by applications).

If a user-defined handler includes a direct parameter, the handler must also include at least one variable parameter.

Regarding your notes:

  1. The preposition to as a labeled parameter is not documented but seems to work.

  2. move is a reserved word of the Standard Suite and expects itself particular parameters. Do not use move as a handler name.

  3. follows the rule about direct parameter. size could be also a reserved word depending on the installed Scripting Additions.

Actually Script Editor shows by syntax coloring the kind of a word. Green words can be safely used as variable names.

Sign up to request clarification or add additional context in comments.

1 Comment

I just tried "on" preposition and it seems to work ok too.: "to resize on pix ...".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.