MC-Basic:COMMON or DIM SHARED or DIM ... AS CONST LONG or DOUBLE or STRING or STRING OF UTF8 or JOINT OF or LOCATION OF

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

These commands are used to define user constants in various scopes.

System constants are defined through the Common Shared command in configuration file (before program block), user tasks (before program block) and terminal.

Task constants are defined through Dim Shared in user tasks (before program block).

Local constants are defined through Dim command in user tasks within program, subroutine and function blocks.

Unlike point variables, point constants are not linked to specific robot types, since they are actually vectors, defined only by the number of coordinates.

Syntax

Common Shared | Dim Shared | Dim <const_name>As Const Long | Double | String | String of UTF8 |  Joint | Location = <const_value>

Availability

All versions.
Declaration of UTF-8 strings is available since Version 4.5.10.

Type

Long, Double, String, Joint or Location

Units

Joint and Location constants: user defined position units.

Scope

Configuration, Task or Terminal

Since Version 4.5.17 the global (common shared) declaration is also possible from the Library context.

Limitations

  • Arrays and subroutine or function definitions (parameters and return values) are not supported.
  • User constants must be given a value during declaration.
  • User constants are writable only during declaration statement. Afterwards, they become read only.
  • User constants cannot be passed “by-reference” to subroutines and functions. They must always be passed “by value”.

Examples

‘SCARA robot Declaration :

common shared scara as group axnm=a1 axnm=a2 axnm=a3 axnm=a4  model = 4    

Common Shared LConst as Const Long = 100

Dim Shared SConst as Const String  = “Task1.Prg”

Program

Dim  JConst as Const Joint of XYZR    = {0.0, 0.0, 0.0}

Dim  LocConst as Const Location of XYZR     = #{0.0, 0.0, 0.0}

<code>

End Program

See Also