Difference between revisions of "MC-Basic:WITHGLOBAL"

From SoftMC-Wiki
Jump to: navigation, search
m
Line 7: Line 7:
  
 
|AVAILABILITY=
 
|AVAILABILITY=
4.19
+
4.17.6
  
 
|DESCRIPTION=
 
|DESCRIPTION=
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. The default motion element exists only after a WithGlobal statement, which is terminated by the End Withglobal keywords, '''or''' by a new WithGlobal statement.
+
This command sets a default motion element (axis or group) that replace previous [[MC-Basic:WITH|WITH]] statement, that sets on the CONFIG.PRG file. Like the "WITH" statement, the motion element will operated on without having to explicitly indicate the motion element name. <br>
 +
The default motion element exists only after a '''WithGlobal''' statement, which is terminated by a new WithGlobal statement, or by "reset all" command applied within the Terminal.
 +
 
 +
 
 +
{{Note|Unlike using local [[MC-Basic:WITH|WITH]], that required "With..... → End With" statements when operated from the Terminal, when using the "WithGlobal" statement, there's '''NO''' need to declare "End WithGlobal".}}
  
 
|TYPE=
 
|TYPE=
Line 27: Line 31:
 
Configuration, Task or Terminal
 
Configuration, Task or Terminal
  
* In the Configuration scope, the specified motion element becomes the default motion element for the system unless there is another WithGlobal command inside other scopes (last WithGlobal statement "win").
+
* In the Terminal scope, the specified motion element becomes the default motion element for the system, that replace ALL previous WITH/WITHGLOBAL statement, from all scopes.
  
* A WithGlobal statement used inside the terminal scope will '''replace''' any previous Withglobal statement.
+
* The way to "kill" a ''WithGlobal'' statement that declared in Config.prg, is to use '''reset all''' command, and change the Config.prg file as you wish.<br> '''Notice - ''' this is NOT a replacement method.  
* In Config.prg or the terminal, the '''End WithGlobal''' keywords are not required. In the task scope, the '''End WithGlobal''' keywords are required.
 
  
The only way to "kill" a ''WithGlobal'' statement that declared in Config.prg, is to use '''reset all''' command, and change the Config.prg file. '''Notice - ''' this is noe a replacement method.
+
|LIMITATIONS=
  
|LIMITATIONS=
 
 
* The ''WithGlobal'' command cannot be set in run time.
 
* The ''WithGlobal'' command cannot be set in run time.
 
* ''WithGlobal'' commands can't be nested.
 
* ''WithGlobal'' commands can't be nested.
 
* Each ''WithGlobal'' block must be explicitly created, '''BUT''' there is no need to explicitly terminated it before executing another ''WithGlobal'' statement.
 
* Each ''WithGlobal'' block must be explicitly created, '''BUT''' there is no need to explicitly terminated it before executing another ''WithGlobal'' statement.
* A subroutine called from within a ''WithGlobal'' block does not inherit the default motion element, so the element is not defined within the subroutine, and an error is flagged. A GOTO command is not allowed inside a ''WithGlobal'' block; an error is flagged.
+
* A subroutine called from within a ''WithGlobal'' block does not inherit the default motion element, so the element is not defined within the subroutine, and an error is flagged.
 +
* A GOTO command is not allowed inside a ''WithGlobal'' block; an error is flagged.
  
 
|EXAMPLE=
 
|EXAMPLE=
 +
 
<syntaxhighlight lang="VB" line='line'>
 
<syntaxhighlight lang="VB" line='line'>
 +
 
A1.VMax=5000
 
A1.VMax=5000
  

Revision as of 14:56, 16 August 2017

Language: [[::MC-Basic:WITHGLOBAL|English]]  • [[::MC-Basic:WITHGLOBAL/zh-hans|中文(简体)‎]]

This command sets a default motion element (axis or group) that replace previous WITH statement, that sets on the CONFIG.PRG file. Like the "WITH" statement, the motion element will operated on without having to explicitly indicate the motion element name.
The default motion element exists only after a WithGlobal statement, which is terminated by a new WithGlobal statement, or by "reset all" command applied within the Terminal.


NOTE-Info.svgNOTE
Unlike using local WITH, that required "With..... → End With" statements when operated from the Terminal, when using the "WithGlobal" statement, there's NO need to declare "End WithGlobal".

Syntax

WithGlobal <element name>

Availability

4.17.6

Scope

Configuration, Task or Terminal

  • In the Terminal scope, the specified motion element becomes the default motion element for the system, that replace ALL previous WITH/WITHGLOBAL statement, from all scopes.
  • The way to "kill" a WithGlobal statement that declared in Config.prg, is to use reset all command, and change the Config.prg file as you wish.
    Notice - this is NOT a replacement method.

Limitations

  • The WithGlobal command cannot be set in run time.
  • WithGlobal commands can't be nested.
  • Each WithGlobal block must be explicitly created, BUT there is no need to explicitly terminated it before executing another WithGlobal statement.
  • A subroutine called from within a WithGlobal block does not inherit the default motion element, so the element is not defined within the subroutine, and an error is flagged.
  • A GOTO command is not allowed inside a WithGlobal block; an error is flagged.

Examples

 1 A1.VMax=5000
 2 
 3 A1.Vord=5000
 4 
 5 A1.VCruise=3000
 6 
 7 A1.PEMax=10
 8 
 9 A1.PESettle=0.01
10 
11 Move A1 100
12 
13 A2.VMax=5000
14 
15 A2.Vord=5000
16 
17 A2.VCruise=3000
18 
19 A2.PEMax=10
20 
21 A2.PESettle=0.01
22 
23 Move A2 100


Can be simplified using:


 1 WithGlobal A1
 2        VMax=5000
 3        Vord=5000
 4        VCruise=3000
 5        PEMax=10
 6        PESettle=0.01
 7        Move 100
 8 
 9 Withglobal A2
10        VMax=5000
11        Vord=5000
12        VCruise=3000
13        PEMax=10
14        PESettle=0.01
15        Move 100