To declare an array or a constant array in a data list with simultaneous initialization:
Declaration and initialization on one line is not allowed. However, initialization must be done directly on the line with the declaration. No lines in between are allowed, nor are empty lines.
If you want to initialize multiple elements of an array, you must specify the elements in ascending array subscript order, starting with the array subscript on the right.
If all array elements of a CHAR type array hold the same string, you do not have to initialize each array element individually. The right-hand side of the array subscript is ignored. (For a one-dimensional array subscript, the subscript is not written.)
Declare the array in the data list and initialize it at the same time:
name[1 <, 1, 1> ] = value 1
...
Name[Dimension1 <, Dimension2, Dimension3> ] = Value N
Declare a constant array in a data list and initialize it at the same time:
DECL
name[1 <, 1, 1> ] = value 1
...
Name[Dimension1 <, Dimension2, Dimension3> ] = Value N
element | illustrate |
DECL | When the data type is a predefined data type, DECL can be omitted. When the data type is a user-defined data type, DECL is required. |
GLOBAL | (>>> 11.4.4 "Scope of Application" Page 326) |
CONST | The keyword CONST is only allowed in data lists. |
Data Types | Description of the required data type |
name | The name of the declared object (variable, array, or constant) |
Dimensionality |
Type: INT
Dimension determines the number of array elements for the corresponding dimension. An array must have at least 1 and at most 3 dimensions. |
value | The data type of the value must be compatible with the data type, but it does not need to be the same. When the data types are compatible, the system automatically adjusts the types. |
Example 1: Declaration with predefined data types. The keyword DECL can also be omitted.
DECL INT X DECL INT X1, X2 DECL REAL ARRAY_A[7], ARRAY_B[5], A |
Example 2
Declare an array with simultaneous initialization (only possible in data lists).
INT A[7] A[1]=27 |
A[2]=313 A[6]=11 CHAR XT1[80] TEXT1[]="message" CHAR TEXT2[2,80] TEXT2[1,]="fit message" TEXT2[2,]="second message" |
Naming conventions
The maximum length allowed for names in the KRL is 24 characters.
Names in the KRL are allowed to contain letters (A - Z), numbers (0 - 9), and the special characters "_" and "$".
Names in the KRL are not allowed to start with a number.
Names in KRL are not allowed to be keywords.
Upper and lower case does not matter.
Double declaration of variables
Double declarations always occur when the same variable name (string) is used.
If the same name is used in different *.SRC or *.DAT files, it is not a double declaration.
Double declaration in the same *.SRC and *.DAT file is not allowed and will generate an error message.
Dual declaration in *.SRC or *.DAT file and $CONFIG.DAT is allowed in the following cases:
When the program in which the variable is declared ends, only the value on the local machine is changed, not the value in $CONFIG.DAT.
When a "foreign" program ends, it has access only to the values in $CONFIG.DAT and can only change those values.
Data types in KRL
Predefined standard data types
BOOL: Classic "yes"/"no" result
REAL: Real number, calculation result to avoid rounding errors
INT: Integer, classic counting variable for counting loops or piece counters
CHAR: Only one character
Review editor: Liu Qing
Previous article:DesignCon Interpretation I The robot dog "Benben" in "The Wandering Earth 2" has become a reality
Next article:How to use the docking quick-change coupling of DOCK Profinet
- Popular Resources
- Popular amplifiers
- Using IMU to enhance robot positioning: a fundamental technology for accurate navigation
- Researchers develop self-learning robot that can clean washbasins like humans
- Universal Robots launches UR AI Accelerator to inject new AI power into collaborative robots
- The first batch of national standards for embodied intelligence of humanoid robots were released: divided into 4 levels according to limb movement, upper limb operation, etc.
- New chapter in payload: Universal Robots’ new generation UR20 and UR30 have upgraded performance
- Humanoid robots drive the demand for frameless torque motors, and manufacturers are actively deploying
- MiR Launches New Fleet Management Software MiR Fleet Enterprise, Setting New Standards in Scalability and Cybersecurity for Autonomous Mobile Robots
- Nidec Drive Technology produces harmonic reducers for the first time in China, growing together with the Chinese robotics industry
- DC motor driver chip, low voltage, high current, single full-bridge driver - Ruimeng MS31211
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Does ramfifo ip TD5.5.1-64bit not support asynchronous clock?
- EEWORLD University Hall----Live Replay: Application of TI mmWave Sensors in Smart Home
- MicroPython Hands-on (04) - Basic Examples of Learning MicroPython from Scratch
- What is 802.11ah or HaLow?
- Recruiting senior RF engineers
- [Summary] STM32F107 board data and μC/OS routine software
- [Silicon Labs development kit review] + FreeRTOS + wonderful basic peripherals
- Tesla Robot Optimus Prime Conference Uncut 4K HD Episode 4
- Ultra-low power Bluetooth controlled, cost-effective, dimmable smart lighting solution
- Open source popsicle macro key macropopsicle