MC-Basic:WITH

From SoftMC-Wiki
Jump to: navigation, search
Language: English  • 中文(简体)‎

This command sets a Default Motion Element (axis or group). Thereafter, the motion element is operated on without having to explicitly indicate the motion element name.

There are 4 ways to use the With statement:


  1. With - Config.prg - The element who set as Default Motion Element (DME) at the Config.prg file, function as DME for whole system. Therefore the only way to change/stop the DME is to "kill" the Config.prg task, and manually change the defaults.
    In case of using Local With statement - The DME will be the one declared on the local statement, and change back to the "Config.prg With" after the task finished.
  2. Local With - Set up a DME for local task. Unlike the "Config With" - using a local With statement require to use With <element>..........End With method.
    This way of use replace the current DME (that declare on the Config.prg or in the Terminal) with a new one, until the task complete.
  3. Terminal With - This way of use designated for run-time changes. After declaring a DME on the terminal, the chosen element will function as DME as long as the user didn't send an "End With" command via terminal. A With command used inside the terminal scope does not affect any programs or vice-versa.
  4. WithGlobal - The DME which create with the "WithGlobal" command replaced the With - Config.prg without shut down the system, or create a new DME in case that there is no such a thing. For more information - WITHGLOBAL

Syntax

With <element name>

Availability

All versions

Scope

Configuration, Task or Terminal

Limitations

  • With commands cannot be nested.
  • A subroutine called from within a WITH block does not inherit the default motion element, so the element is not defined within the subroutine, and an error is flagged (Local With).
  • A GOTO command is not allowed inside a WITH block; an error is flagged (Local With).

Examples

A1.VMax=5000

A1.Vord=5000

A1.VCruise=3000

A1.PEMax=10

A1.PESettle=0.01

Move A1 100

Can be simplified using:
With A1
       VMax=5000
       Vord=5000
       VCruise=3000
       PEMax=10
       PESettle=0.01
       Move 100

End With