メインコンテンツまでスキップ
バージョン:25.2

run

  • command
    • Syntax: +

       run scriptName {,} {parameters}
      run scriptName 's handlerName {parameters}
    • Calls the scriptName script, or the handlerName handler of that script, as a command. HandlerName is usually just the simple name of a handler without quotes, but may also be given as a quoted literal, or as an expression in parentheses to construct the handler name at run time.

The run command is rarely needed. It is usually simpler (and more readable) to just use the script name directly as a common. But the run command may be required when a full pathname to the script is needed or the script's name contains spaces or other special characters, or when the name of the script to be run is in a variable.

  • Examples:
    • The following command will run the script’s initial handler:

run "/tmp/testScript.st"

Parameters may be passed:

run "common/startup" 1200,true,"salvador"

A specific handler other than the script’s initial handler may be called, using 's:

run "common/finance" 's amortize 143000,6.75,360

The run command may be used with any object, not just a script file:

run account's accrueInterest 30, 4.125

The preceding example is equivalent to:

Tell accrueInterest 30, 4.125 to account

  • function
    • Syntax: +

       object.run(parameters)
      {the} run of object {with parameters}
    • Calls the initial handler of a script or other object explicitly as a function. This also allows calling a script whose name is generated dynamically at runtime. The run function needs to be called in a way that sends the run message to the target object, such as using dot notation.

    • Examples:

      • set doubler to (script:"return 2*param(1)")

put doubler.run(12) —> 24