FANUC Robotics SYSTEM R-30iA and R-30iB Controller. KAREL Reference Manual - page 11

 

  Index      Manuals     FANUC Robotics SYSTEM R-30iA and R-30iB Controller. KAREL Reference Manual (MARRC75KR07091E Rev D)

 

Search            copyright infringement  

 

   

 

   

 

Content      ..     9      10      11      12     ..

 

 

 

FANUC Robotics SYSTEM R-30iA and R-30iB Controller. KAREL Reference Manual - page 11

 

 

MARRC75KR07091E Rev D
15. MULTI-TASKING
Server Task
--KAREL
POST_SEMA (4)
WHILE TRUE DO
PEND_SEMA(5,max_time,time_out)
IF rqst_param=10 THEN
do_something
ENDIF
POST_SEMA(4)
POST_SEMA(6)
ENDWHILE
Example: The program example in Semaphore and Task Synchronization Program Example - MAIN
TASK thru Semaphore and Task Synchronization Program Example - TASK B shows how semaphores
and tasks can be used together for synchronization. MAIN_TASK.KL is used to initialize the semaphore
(MOTION_CTRL) and then runs both TASK_A.KL and TASK_B.KL. MAIN_TASK.KL then waits for
TASK_A and TASK_B to abort before completing. TASK_A waits until you press F1 and then moves the
robot to the HOME position. TASK_B waits until you press F2 and then moves the robot along a path.
Semaphore and Task Synchronization Program Example - MAIN TASK
PROGRAM main_task
%nolockgroup
VAR
motion_ctrl: INTEGER
tsk_a_done : BOOLEAN
tsk_b_done : BOOLEAN
tmr
: INTEGER
status
: INTEGER
------------------------------------------------
--
--
-- INIT_LOCK: Initialize the semaphore
--
--
to make sure its count is at
--
--
zero before using it. Then
--
--
post this semaphore which will--
--
allow the first pend to the
--
--
semaphore to continue
--
--
execution.
--
------------------------------------------------
ROUTINE init_lock
BEGIN
CLEAR_SEMA (motion_ctrl)
-- makes sure semaphore is zero before using
it.
POST_SEMA
(motion_ctrl)
-- makes motion_ctrl available immediately
END init_lock
------------------------------------------------
15-11
15. MULTI-TASKING
MARRC75KR07091E Rev D
--
--
-- IS_TSK_DONE : Find out if the specified
--
--
task is running or not.
--
--
If the task is aborted then --
--
return TRUE otherwise FALSE.--
------------------------------------------------
ROUTINE is_tsk_done (task_name:STRING): BOOLEAN
VAR
status
: INTEGER
-- The status of the operation of GET_TSK_INFO
task_no : INTEGER
-- Receives the current task number for task_name
attr_out: INTEGER
-- Receives the TSK_STATUS output
dummy
: STRING[2]
-- Does not receive any information
BEGIN
GET_TSK_INFO (task_name, task_no, TSK_STATUS, attr_out, dummy, status)
IF (attr_out = PG_ABORTED) THEN
RETURN (TRUE)
-- If task is aborted then return TRUE
ENDIF
RETURN(FALSE)
-- otherwise task is not aborted and return
FALSE
END is_tsk_done
BEGIN
motion_ctrl = 1
-- Semaphore to allow motion control
init_lock
-- Make sure this is done just once
FORCE_SPMENU ( tp_panel, spi_tpuser, 1)
-- Force the Teach Pendant
-- user screen to be seen
RUN_TASK(’task_a’, 1, FALSE, FALSE, 1, status)
-- Run task_a
RUN_TASK(’task_b’, 1, FALSE, FALSE, 1, status)
-- Run task_b
REPEAT
tsk_a_done = is_tsk_done (’task_a’)
tsk_b_done = is_tsk_done (’task_b’)
delay (100)
UNTIL (tsk_a_done and tsk_b_done)
-- Repeat until both task_a
END main_task
-- and task_b are aborted
Semaphore and Task Synchronization Program Example - TASK A
PROGRAM task_a
%nolockgroup
VAR
motion_ctrl FROM main_task: INTEGER
home_pos
: XYZWPR
status
: INTEGER
------------------------------------------------
--
--
-- RUN_HOME
: Lock the robot motion
--
--
control. This task is
--
15-12
MARRC75KR07091E Rev D
15. MULTI-TASKING
--
moving the robot and must
--
--
have control.
--
--
--
------------------------------------------------
ROUTINE run_home
VAR
time_out: BOOLEAN
BEGIN
PEND_SEMA(motion_ctrl,-1,time_out)-- lock motion_ctrl from other tasks
-- keep other tasks from moving robot
LOCK_GROUP (1, status)
SET_POS_REG(1, home_pos, status)
do_move
-- call TP program to move to the home position
UNLOCK_GROUP (1, status)
POST_SEMA(motion_ctrl)
-- unlock motion_ctrl
-- allow other task to move robot
END run_home
BEGIN
set_cursor (tpfunc, 1, 4, status)
write tpfunc (’HOME’,CR)
wait for TPIN[129]+
-- wait for F1 to be pressed
run_home
END task_a
Semaphore and Task Synchronization Program Example - TASK B
PROGRAM task_b
%nolockgroup
VAR
motion_ctrl FROM main_task : INTEGER
work_path
: PATH
move_pos
: XYZWPR
status
: INTEGER
------------------------------------------------
--
--
-- do_work
: Lock the robot from other
--
--
tasks and do work. This
--
--
task is doing motion and
--
--
must lock motion control so --
--
that another task does not
--
--
try to do motion at the
--
--
same time.
--
------------------------------------------------
ROUTINE do_work
VAR
time_out: BOOLEAN
15-13
15. MULTI-TASKING
MARRC75KR07091E Rev D
BEGIN
PEND_SEMA (motion_ctrl,-1,time_out) -- lock motion_ctrl from other
-- tasks keep other tasks from
-- moving robot
LOCK_GROUP (1, status)
FOR i=1 to PATH_LEN(work_path) DO
move_pos = work_path[i]
SET_POS_REG(1, move_pos, status)
do_move
-- call TP program to move to path node
ENDFOR
UNLOCK_GROUP (1, status)
POST_SEMA(motion_ctrl)
-- unlock motion_ctrl allow
-- other task to move robot
END do_work
BEGIN
set_cursor(tpfunc, 1, 10, status)
write tpfunc(’WORK’,CR)
wait for TPIN[131]+
-- wait until F2 is pressed
do_work
END task_b
15.8
USING QUEUES FOR TASK COMMUNICATIONS
Queues are supported only in KAREL. A queue is a first-in/first-out list of integers. They are
used to pass information to another task sequentially. A queue consists of a user variable of type
QUEUE_TYPE and an ARRAY OF INTEGER. The maximum number of entries in the queue is
determined by the size of the array.
The following operations are supported on queues:
INIT_QUEUE initializes a queue and sets it to empty.
APPEND_QUEUE adds an integer to the list of entries in the queue.
GET_QUEUE: reads the oldest (top) entry from the queue and deletes it.
These, and other built-ins related to queues ( DELETE_QUEUE, INSERT_QUEUE, COPY_QUEUE)
are described in Appendix A .
A QUEUE_TYPE Data Type has one user accessible element, n_entries . This is the number of
entries that have been added to the queue and not read out. The array of integer used with a queue, is
used by the queue built-ins and should not be referenced by the KAREL program.
Example: The following example illustrates a more powerful request server, in which more than one
task is posting requests and the requester does not wait for completion of the request.
15-14
MARRC75KR07091E Rev D
15. MULTI-TASKING
The requester would contain the following code:
Requester
--declarations
VAR
rqst_queue FROM server: QUEUE_TYPE
rqst_data FROM server: ARRAY[100] OF INTEGER
status: INTEGER
seq_no: INTEGER
-- posting to the queue --
APPEND_QUEUE (req_code, rqst_queue, rqst_data, seq_no, status)
The server task would contain the following code:
Server
PROGRAM server
VAR
rqst_queue: QUEUE_TYPE
rqst_data : ARRAY[100] OF INTEGER
status
: INTEGER
seq_no
: INTEGER
rqst_code : INTEGER
BEGIN
INIT_QUEUE(rqst_queue)
--initialization
WHILE TRUE DO
--serving loop
WAIT FOR rqst_code.n_entries > 0
GET_QUEUE (rqst_queue, rqst_data, rqst_code, seq_no, status)
SELECT rqst_code OF
CASE (1): do_something
ENDSELECT
ENDWHILE
END server
15-15
Appendix A
KAREL LANGUAGE ALPHABETICAL
DESCRIPTION
Contents
Appendix A
KAREL LANGUAGE ALPHABETICAL DESCRIPTION
A-1
A.1
OVERVIEW
A-9
A.2
- A - KAREL LANGUAGE DESCRIPTION
A-18
A.2.1
ABORT Action
A-18
A.2.2
ABORT Condition
A-18
A.2.3
ABORT Statement
A-19
A.2.4
ABORT_TASK Built-In Procedure
A-19
A.2.5
ABS Built-In Function
A-20
A.2.6
ACOS Built-In Function
A-20
A.2.7
ACT_SCREEN Built-In Procedure
A-21
A.2.8
ACT_TBL Built-In Procedure
A-22
A.2.9
ADD_BYNAMEPC Built-In Procedure
A-24
A.2.10
ADD_DICT Built-In Procedure
A-25
A.2.11
ADD_INTPC Built-In Procedure
A-26
A.2.12
ADD_REALPC Built-In Procedure
A-27
A.2.13
ADD_STRINGPC Built-In Procedure
A-29
A.2.14
%ALPHABETIZE Translator Directive
A-30
A.2.15
APPEND_NODE Built-In Procedure
A-30
A.2.16
APPEND_QUEUE Built-In Procedure
A-31
A.2.17
APPROACH Built-In Function
A-32
A.2.18
ARRAY Data Type
A-33
A.2.19
ARRAY_LEN Built-In Function
A-34
A.2.20
ASIN Built-In Function
A-34
A.2.21
Assignment Action
A-35
A.2.22
Assignment Statement
A-36
A.2.23
ATAN2 Built-In Function
A-38
A.2.24
ATTACH Statement
A-39
A.2.25
ATT_WINDOW_D Built-In Procedure
A-39
A-1
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
A.2.26
ATT_WINDOW_S Built-In Procedure
A-40
A.2.27
AVL_POS_NUM Built-In Procedure
A-41
A.3
- B - KAREL LANGUAGE DESCRIPTION
A-42
A.3.1
BOOLEAN Data Type
A-42
A.3.2
BYNAME Built-In Function
A-43
A.3.3
BYTE Data Type
A-44
A.3.4
BYTES_AHEAD Built-In Procedure
A-45
A.3.5
BYTES_LEFT Built-In Function
A-46
A.4
- C - KAREL LANGUAGE DESCRIPTION
A-47
A.4.1
CALL_PROG Built-In Procedure
A-47
A.4.2
CALL_PROGLIN Built-In Procedure
A-48
A.4.3
CANCEL Action
A-49
A.4.4
CANCEL Statement
A-49
A.4.5
CANCEL FILE Statement
A-50
A.4.6
CHECK_DICT Built-In Procedure
A-51
A.4.7
CHECK_EPOS Built-In Procedure
A-52
A.4.8
CHECK_NAME Built-In Procedure
A-53
A.4.9
CHR Built-In Function
A-53
A.4.10
CLEAR Built-In Procedure
A-54
A.4.11
CLEAR_SEMA Built-In Procedure
A-55
A.4.12
CLOSE FILE Statement
A-55
A.4.13
CLOSE HAND Statement
A-56
A.4.14
CLOSE_TPE Built-In Procedure
A-56
A.4.15
CLR_IO_STAT Built-In Procedure
A-57
A.4.16
CLR_PORT_SIM Built-In Procedure
A-57
A.4.17
CLR_POS_REG Built-In Procedure
A-58
A.4.18
%CMOSVARS Translator Directive
A-59
A.4.19
%CMOS2SHADOW Translator Directive
A-59
A.4.20
CNC_DYN_DISB Built-In Procedure
A-59
A.4.21
CNC_DYN_DISE Built-In Procedure
A-60
A.4.22
CNC_DYN_DISI Built-In Procedure
A-61
A.4.23
CNC_DYN_DISP Built-In Procedure
A-62
A.4.24
CNC_DYN_DISR Built-In Procedure
A-62
A.4.25
CNC_DYN_DISS Built-In Procedure
A-63
A.4.26
CNCL_STP_MTN Built-In Procedure
A-64
A.4.27
CNV_CNF_STRG Built-In Procedure
A-64
A.4.28
CNV_CONF_STR Built-In Procedure
A-65
A.4.29
CNV_INT_STR Built-In Procedure
A-66
A.4.30
CNV_JPOS_REL Built-In Procedure
A-67
A.4.31
CNV_REAL_STR Built-In Procedure
A-67
A.4.32
CNV_REL_JPOS Built-In Procedure
A-68
A.4.33
CNV_STR_CONF Built-In Procedure
A-69
A.4.34
CNV_STR_INT Built-In Procedure
A-70
A.4.35
CNV_STR_REAL Built-In Procedure
A-71
A.4.36
CNV_STR_TIME Built-In Procedure
A-71
A.4.37
CNV_TIME_STR Built-In Procedure
A-72
A.4.38
%COMMENT Translator Directive
A-73
A.4.39
COMPARE_FILE Built-in Procedure
A-73
A.4.40
CONDITION...ENDCONDITION Statement
A-75
A.4.41
CONFIG Data Type
A-77
A.4.42
CONNECT TIMER Statement
A-78
A.4.43
CONTINUE Action
A-79
A.4.44
CONTINUE Condition
A-79
A.4.45
CONT_TASK Built-In Procedure
A-80
A.4.46
COPY_FILE Built-In Procedure
A-81
A-2
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
A.4.47
COPY_PATH Built-In Procedure
A-82
A.4.48
COPY_QUEUE Built-In Procedure
A-83
A.4.49
COPY_TPE Built-In Procedure
A-85
A.4.50
COS Built-In Function
A-86
A.4.51
CR Input/Output Item
A-86
A.4.52
CREATE_TPE Built-In Procedure
A-87
A.4.53
CREATE_VAR Built-In Procedure
A-88
A.4.54
%CRTDEVICE
A-90
A.4.55
CURJPOS Built-In Function
A-91
A.4.56
CURPOS Built-In Function
A-92
A.4.57
CURR_PROG Built-In Function
A-93
A.5
- D - KAREL LANGUAGE DESCRIPTION
A-93
A.5.1
DAQ_CHECKP Built-In Procedure
A-93
A.5.2
DAQ_REGPIPE Built-In Procedure
A-94
A.5.3
DAQ_START Built-In Procedure
A-96
A.5.4
DAQ_STOP Built-In Procedure
A-98
A.5.5
DAQ_UNREG Built-In Procedure
A-99
A.5.6
DAQ_WRITE Built-In Procedure
A-100
A.5.7
%DEFGROUP Translator Directive
A-102
A.5.8
DEF_SCREEN Built-In Procedure
A-102
A.5.9
DEF_WINDOW Built-In Procedure
A-103
A.5.10
%DELAY Translator Directive
A-104
A.5.11
DELAY Statement
A-105
A.5.12
DELETE_FILE Built-In Procedure
A-106
A.5.13
DELETE_NODE Built-In Procedure
A-107
A.5.14
DELETE_QUEUE Built-In Procedure
A-107
A.5.15
DEL_INST_TPE Built-In Procedure
A-108
A.5.16
DET_WINDOW Built-In Procedure
A-109
A.5.17
DISABLE CONDITION Action
A-109
A.5.18
DISABLE CONDITION Statement
A-110
A.5.19
DISCONNECT TIMER Statement
A-111
A.5.20
DISCTRL_ALPH Built_In Procedure
A-112
A.5.21
DISCTRL_FORM Built_In Procedure
A-114
A.5.22
DISCTRL_LIST Built-In Procedure
A-116
A.5.23
DISCTRL_PLMN Built-In Procedure
A-117
A.5.24
DISCTRL_SBMN Built-In Procedure
A-119
A.5.25
DISCTRL_TBL Built-In Procedure
A-122
A.5.26
DISMOUNT_DEV Built-In Procedure
A-125
A.5.27
DISP_DAT_T Data Type
A-125
A.5.28
DOSFILE_INF Built-In Procedure
A-127
A.6
- E - KAREL LANGUAGE DESCRIPTION
A-128
A.6.1
ENABLE CONDITION Action
A-128
A.6.2
ENABLE CONDITION Statement
A-129
A.6.3
%ENVIRONMENT Translator Directive
A-129
A.6.4
ERR_DATA Built-In Procedure
A-131
A.6.5
ERROR Condition
A-132
A.6.6
EVAL Clause
A-133
A.6.7
EVENT Condition
A-134
A.6.8
EXP Built-In Function
A-134
A.7
- F - KAREL LANGUAGE DESCRIPTION
A-135
A.7.1
FILE Data Type
A-135
A.7.2
FILE_LIST Built-In Procedure
A-135
A.7.3
FOR...ENDFOR Statement
A-137
A.7.4
FORCE_SPMENU Built-In Procedure
A-138
A-3
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
A.7.5
FORMAT_DEV Built-In Procedure
A-141
A.7.6
FRAME Built-In Function
A-142
A.7.7
FROM Clause
A-144
A.8
- G - KAREL LANGUAGE DESCRIPTION
A-145
A.8.1
GET_ATTR_PRG Built-In Procedure
A-145
A.8.2
GET_FILE_POS Built-In Function
A-147
A.8.3
GET_JPOS_REG Built-In Function
A-148
A.8.4
GET_JPOS_TPE Built-In Function
A-148
A.8.5
GET_PORT_ASG Built-in Procedure
A-149
A.8.6
GET_PORT_ATR Built-In Function
A-151
A.8.7
GET_PORT_CMT Built-In Procedure
A-153
A.8.8
GET_PORT_MOD Built-In Procedure
A-154
A.8.9
GET_PORT_SIM Built-In Procedure
A-155
A.8.10
GET_PORT_VAL Built-In Procedure
A-156
A.8.11
GET_POS_FRM Built-In Procedure
A-157
A.8.12
GET_POS_REG Built-In Function
A-158
A.8.13
GET_POS_TPE Built-In Function
A-158
A.8.14
GET_POS_TYP Built-In Procedure
A-159
A.8.15
GET_PREG_CMT Built-In-Procedure
A-160
A.8.16
GET_QUEUE Built-In Procedure
A-161
A.8.17
GET_REG Built-In Procedure
A-162
A.8.18
GET_REG_CMT
A-163
A.8.19
GET_SREG_CMT Builtin Procedure
A-163
A.8.20
GET_STR_REG Built-In Procedure
A-164
A.8.21
GET_TIME Built-In Procedure
A-164
A.8.22
GET_TPE_CMT Built-in Procedure
A-165
A.8.23
GET_TPE_PRM Built-in Procedure
A-166
A.8.24
GET_TSK_INFO Built-In Procedure
A-168
A.8.25
GET_USEC_SUB Built-In Procedure
A-170
A.8.26
GET_USEC_TIM Built-In Function
A-171
A.8.27
GET_VAR Built-In Procedure
A-171
A.8.28
GO TO Statement
A-175
A.9
- H - KAREL LANGUAGE DESCRIPTION
A-176
A.9.1
HOLD Action
A-176
A.9.2
HOLD Statement
A-177
A.10
- I - KAREL LANGUAGE DESCRIPTION
A-178
A.10.1
IF ... ENDIF Statement
A-178
A.10.2
IN Clause
A-179
A.10.3
%INCLUDE Translator Directive
A-180
A.10.4
INDEX Built-In Function
A-181
A.10.5
INI_DYN_DISB Built-In Procedure
A-181
A.10.6
INI_DYN_DISE Built-In Procedure
A-183
A.10.7
INI_DYN_DISI Built-In Procedure
A-184
A.10.8
INI_DYN_DISP Built-In Procedure
A-186
A.10.9
INI_DYN_DISR Built-In Procedure
A-187
A.10.10
INI_DYN_DISS Built-In Procedure
A-188
A.10.11
INIT_QUEUE Built-In Procedure
A-189
A.10.12
INIT_TBL Built-In Procedure
A-190
A.10.13
IN_RANGE Built-In Function
A-201
A.10.14
INSERT_NODE Built-In Procedure
A-202
A.10.15
INSERT_QUEUE Built-In Procedure
A-203
A.10.16
INTEGER Data Type
A-204
A.10.17
INV Built-In Function
A-205
A.10.18
IO_MOD_TYPE Built-In Procedure
A-206
A-4
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
A.10.19
IO_STATUS Built-In Function
A-207
A.11
- J - KAREL LANGUAGE DESCRIPTION
A-208
A.11.1
J_IN_RANGE Built-In Function
A-208
A.11.2
JOINTPOS Data Type
A-209
A.11.3
JOINT2POS Built-In Function
A-209
A.12
- K - KAREL LANGUAGE DESCRIPTION
A-211
A.12.1
KCL Built-In Procedure
A-211
A.12.2
KCL_NO_WAIT Built-In Procedure
A-212
A.12.3
KCL_STATUS Built-In Procedure
A-213
A.13
- L - KAREL LANGUAGE DESCRIPTION
A-213
A.13.1
LN Built-In Function
A-213
A.13.2
LOAD Built-In Procedure
A-214
A.13.3
LOAD_STATUS Built-In Procedure
A-215
A.13.4
LOCK_GROUP Built-In Procedure
A-216
A.13.5
%LOCKGROUP Translator Directive
A-217
A.14
- M - KAREL LANGUAGE DESCRIPTION
A-218
A.14.1
MIRROR Built-In Function
A-218
A.14.2
MODIFY_QUEUE Built-In Procedure
A-219
A.14.3
MOTION_CTL Built-In Function
A-221
A.14.4
MOUNT_DEV Built-In Procedure
A-221
A.14.5
MOVE_FILE Built-In Procedure
A-222
A.14.6
MSG_CONNECT Built-In Procedure
A-223
A.14.7
MSG_DISCO Built-In Procedure
A-225
A.14.8
MSG_PING
A-225
A.15
- N - KAREL LANGUAGE DESCRIPTION
A-226
A.15.1
NOABORT Action
A-226
A.15.2
%NOABORT Translator Directive
A-227
A.15.3
%NOBUSYLAMP Translator Directive
A-227
A.15.4
NODE_SIZE Built-In Function
A-227
A.15.5
%NOLOCKGROUP Translator Directive
A-229
A.15.6
NOMESSAGE Action
A-230
A.15.7
NOPAUSE Action
A-230
A.15.8
%NOPAUSE Translator Directive
A-231
A.15.9
%NOPAUSESHFT Translator Directive
A-231
A.16
- O - KAREL LANGUAGE DESCRIPTION
A-232
A.16.1
OPEN FILE Statement
A-232
A.16.2
OPEN HAND Statement
A-233
A.16.3
OPEN_TPE Built-In Procedure
A-233
A.16.4
ORD Built-In Function
A-234
A.16.5
ORIENT Built-In Function
A-235
A.17
- P - KAREL LANGUAGE DESCRIPTION
A-236
A.17.1
PATH Data Type
A-236
A.17.2
PATH_LEN Built-In Function
A-238
A.17.3
PAUSE Action
A-238
A.17.4
PAUSE Condition
A-239
A.17.5
PAUSE Statement
A-240
A.17.6
PAUSE_TASK Built-In Procedure
A-241
A.17.7
PEND_SEMA Built-In Procedure
A-242
A.17.8
PIPE_CONFIG Built-In Procedure
A-242
A.17.9
POP_KEY_RD Built-In Procedure
A-243
A.17.10
Port_Id Action
A-244
A.17.11
Port_Id Condition
A-245
A.17.12
POS Built-In Function
A-246
A-5
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
A.17.13
POS2JOINT Built-In Function
A-246
A.17.14
POS_REG_TYPE Built-In Procedure
A-248
A.17.15
POSITION Data Type
A-249
A.17.16
POST_ERR Built-In Procedure
A-250
A.17.17
POST_ERR_L Built-In Procedure
A-251
A.17.18
POST_SEMA Built-In Procedure
A-253
A.17.19
PRINT_FILE Built-In Procedure
A-253
A.17.20
%PRIORITY Translator Directive
A-254
A.17.21
PROG_BACKUP Built-In Procedure
A-255
A.17.22
PROG_CLEAR Built-In Procedure
A-258
A.17.23
PROG_RESTORE Built-In Procedure
A-260
A.17.24
PROG_LIST Built-In Procedure
A-262
A.17.25
PROGRAM Statement
A-263
A.17.26
PULSE Action
A-264
A.17.27
PULSE Statement
A-265
A.17.28
PURGE CONDITION Statement
A-266
A.17.29
PURGE_DEV Built-In Procedure
A-267
A.17.30
PUSH_KEY_RD Built-In Procedure
A-268
A.18
- Q - KAREL LANGUAGE DESCRIPTION
A-269
A.18.1
QUEUE_TYPE Data Type
A-269
A.19
- R - KAREL LANGUAGE DESCRIPTION
A-269
A.19.1
READ Statement
A-269
A.19.2
READ_DICT Built-In Procedure
A-271
A.19.3
READ_DICT_V Built-In-Procedure
A-272
A.19.4
READ_KB Built-In Procedure
A-273
A.19.5
REAL Data Type
A-277
A.19.6
Relational Condition
A-279
A.19.7
RELAX HAND Statement
A-280
A.19.8
RELEASE Statement
A-281
A.19.9
REMOVE_DICT Built-In Procedure
A-281
A.19.10
RENAME_FILE Built-In Procedure
A-282
A.19.11
RENAME_VAR Built-In Procedure
A-283
A.19.12
RENAME_VARS Built-In Procedure
A-283
A.19.13
REPEAT ... UNTIL Statement
A-284
A.19.14
RESET Built-In Procedure
A-285
A.19.15
RESUME Action
A-286
A.19.16
RESUME Statement
A-286
A.19.17
RETURN Statement
A-287
A.19.18
ROUND Built-In Function
A-288
A.19.19
ROUTINE Statement
A-289
A.19.20
RUN_TASK Built-In Procedure
A-290
A.20
- S - KAREL LANGUAGE DESCRIPTION
A-291
A.20.1
SAVE Built-In Procedure
A-291
A.20.2
SAVE_DRAM Built-In Procedure
A-292
A.20.3
SELECT ... ENDSELECT Statement
A-293
A.20.4
SELECT_TPE Built-In Procedure
A-294
A.20.5
SEMA_COUNT Built-In Function
A-294
A.20.6
SEMAPHORE Condition
A-295
A.20.7
SEND_DATAPC Built-In Procedure
A-295
A.20.8
SEND_EVENTPC Built-In Procedure
A-296
A.20.9
SET_ATTR_PRG Built-In Procedure
A-297
A.20.10
SET_CURSOR Built-In Procedure
A-299
A.20.11
SET_EPOS_REG Built-In Procedure
A-300
A.20.12
SET_EPOS_TPE Built-In Procedure
A-301
A-6
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
A.20.13
SET_FILE_ATR Built-In Procedure
A-302
A.20.14
SET_FILE_POS Built-In Procedure
A-303
A.20.15
SET_INT_REG Built-In Procedure
A-304
A.20.16
SET_JPOS_REG Built-In Procedure
A-304
A.20.17
SET_JPOS_TPE Built-In Procedure
A-305
A.20.18
SET_LANG Built-In Procedure
A-306
A.20.19
SET_PERCH Built-In Procedure
A-307
A.20.20
SET_PORT_ASG Built-In Procedure
A-308
A.20.21
SET_PORT_ATR Built-In Function
A-309
A.20.22
SET_PORT_CMT Built-In Procedure
A-311
A.20.23
SET_PORT_MOD Built-In Procedure
A-312
A.20.24
SET_PORT_SIM Built-In Procedure
A-313
A.20.25
SET_PORT_VAL Built-In Procedure
A-314
A.20.26
SET_POS_REG Built-In Procedure
A-315
A.20.27
SET_POS_TPE Built-In Procedure
A-316
A.20.28
SET_PREG_CMT Built-In-Procedure
A-317
A.20.29
SET_REAL_REG Built-In Procedure
A-317
A.20.30
SET_REG_CMT Built-In-Procedure
A-317
A.20.31
SET_SREG_CMT Built-in Procedure
A-318
A.20.32
SET_STR_REG Built-in Procedure
A-319
A.20.33
SET_TIME Built-In Procedure
A-319
A.20.34
SET_TPE_CMT Built-In Procedure
A-321
A.20.35
SET_TRNS_TPE Built-In Procedure
A-321
A.20.36
SET_TSK_ATTR Built-In Procedure
A-322
A.20.37
SET_TSK_NAME Built-In Procedure
A-323
A.20.38
SET_VAR Built-In Procedure
A-324
A.20.39
%SHADOWVARS Translator Directive
A-327
A.20.40
SHORT Data Type
A-327
A.20.41
SIGNAL EVENT Action
A-328
A.20.42
SIGNAL EVENT Statement
A-328
A.20.43
SIGNAL SEMAPHORE Action
A-329
A.20.44
SIN Built-In Function
A-329
A.20.45
SQRT Built-In Function
A-330
A.20.46
%STACKSIZE Translator Directive
A-330
A.20.47
STD_PTH_NODE Data Type
A-331
A.20.48
STOP Action
A-331
A.20.49
STOP Statement
A-332
A.20.50
STRING Data Type
A-333
A.20.51
STR_LEN Built-In Function
A-334
A.20.52
STRUCTURE Data Type
A-334
A.20.53
SUB_STR Built-In Function
A-335
A.21
- T - KAREL LANGUAGE DESCRIPTION
A-336
A.21.1
TAN Built-In Function
A-336
A.21.2
%TIMESLICE Translator Directive
A-337
A.21.3
%TPMOTION Translator Directive
A-337
A.21.4
TRANSLATE Built-In Procedure
A-337
A.21.5
TRUNC Built-In Function
A-339
A.22
- U - KAREL LANGUAGE DESCRIPTION
A-340
A.22.1
UNHOLD Action
A-340
A.22.2
UNHOLD Statement
A-340
A.22.3
UNINIT Built-In Function
A-341
A.22.4
%UNINITVARS Translator Directive
A-341
A.22.5
UNLOCK_GROUP Built-In Procedure
A-342
A.22.6
UNPAUSE Action
A-343
A.22.7
UNPOS Built-In Procedure
A-344
A-7
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
A.22.8
USING ... ENDUSING Statement
A-344
A.23
- V - KAREL LANGUAGE DESCRIPTION
A-345
A.23.1
V_CAM_CALIB iRVision Built-In Procedure
A-345
A.23.2
V_GET_OFFSET iRVision Built-In Procedure
A-347
A.23.3
V_GET_PASSFL iRVision Built-In Procedure
A-348
A.23.4
V_GET_QUEUE iRVision Built-in Procedure
A-350
A.23.5
V_INIT_QUEUE iRVision Built-in Procedure
A-350
A.23.6
V_RALC_QUEUE iRVision Built-in Procedure
A-351
A.23.7
V_RUN_FIND iRVision Built-In Procedure
A-351
A.23.8
V_SET_REF iRVision Built-In Procedure
A-353
A.23.9
V_START_VTRK iRVision Built-in Procedure
A-354
A.23.10
V_STOP_VTRK iRVision Built-in Procedure
A-354
A.23.11
VAR_INFO Built-In Procedure
A-355
A.23.12
VAR_LIST Built-In Procedure
A-357
A.23.13
VECTOR Data Type
A-360
A.23.14
VOL_SPACE Built-In Procedure
A-361
A.23.15
VREG_FND_POS iRVision Built-in Procedure
A-362
A.23.16
VREG_OFFSET iRVision Built-in Procedure
A-363
A.24
- W - KAREL LANGUAGE DESCRIPTION
A-364
A.24.1
WAIT FOR Statement
A-364
A.24.2
WHEN Clause
A-364
A.24.3
WHILE...ENDWHILE Statement
A-365
A.24.4
WITH Clause
A-365
A.24.5
WRITE Statement
A-366
A.24.6
WRITE_DICT Built-In Procedure
A-367
A.24.7
WRITE_DICT_V Built-In Procedure
A-368
A.25
- X - KAREL LANGUAGE DESCRIPTION
A-369
A.25.1
XML_ADDTAG Built-In Procedure
A-369
A.25.2
XML_GETDATA Built-In Procedure
A-370
A.25.3
XML_REMTAG Built-In Procedure
A-371
A.25.4
XML_SCAN Built-In Procedure
A-371
A.25.5
XML_SETVAR Built-In Procedure
A-373
A.25.6
XYZWPR Data Type
A-374
A.25.7
XYZWPREXT Data Type
A-375
A.26
- Y - KAREL LANGUAGE DESCRIPTION
A-375
A.27
- Z - KAREL LANGUAGE DESCRIPTION
A-375
A-8
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
A.1
OVERVIEW
This appendix describes, in alphabetical order, each standard KAREL language element, including:
Data types
Executable statements and clauses
Condition handler conditions and actions
Built-in routines
Translator directives
A brief example of a typical use of each element is included in each description.
Note If, during program execution, any uninitialized variables are encountered as arguments for
built-in routines, the program pauses and an error is displayed. Either initialize the variable, KCL>
SET VARIABLE command, or abort the program, using the KCL> ABORT command.
Conventions
This section describes each standard element of the KAREL language in alphabetical order. Each
description includes the following information:
Purpose: Indicates the specific purpose the element serves in the language
Syntax: Describes the proper syntax needed to access the element in KAREL. Table A-1
describes the syntax notation that is used.
Table
A-1.
Syntax Notation
Syntax
Meaning
Example
Result
<>
Enclosed words are
AAA <BBB>
AAA
optional
AAA BBB
{}
Enclosed words are
AAA {BBB}
AAA
optional and can be
AAA BBB
repeated
AAA BBB BBB
AAA BBB BBB BBB
|
Separates alternatives
AAA | BBB
AAA
BBB
<|>
Separates an alternative
AAA <BBB | CCC>
AAA
if only one or none can be
AAA BBB
used
AAA CCC
||
Exactly one alternative
AAA || BBB | CCC ||
AAA BBB
must be used
AAA CCC
A-9
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
Table
A-1.
Syntax Notation (Cont’d)
Syntax
Meaning
Example
Result
{|}
Any combination of
AAA {BBB | CCC}
AAA
alternatives can be used
AAA BBB
AAA CCC
AAA BBB CCC
AAA CCC BBB
AAA BBB CCC BBB BBB
<<|>>
Nesting of symbols is
AAA <BBB <CCC |
AAA
allowed. Look at the
DDD>
AAA BBB
innermost notation first
AAA BBB CCC
to see what it describes,
AAA BBB DDD
then look at the next
innermost layer to see
what it describes, and so
forth.
If the built-in is a function, the following notation is used to identify the data type of the value
returned by the function:
Function Return Type: data_typ
Input and output parameter data types for functions and procedures are identified as:
[in] param_name: data_type
[out] param_name: data_type
where :
[in] specifies the data type of parameters which are passed into the routine
[out] specifies the data type of parameters which are passed back into the program from the routine
%ENVIRONMENT Group specifies the %ENVIRONMENT group for built-in functions and
procedures, which is used by the off-line translator. Valid values are: BYNAM, CTDEF, ERRS,
FDEV, FLBT, IOSETUP, KCL, MEMO, MIR, MOTN, MULTI, PATHOP, PBQMGR, REGOPE,
STRNG, SYSDEF, TIM, TPE, TRANS, UIF, VECTR. The SYSTEM group is automatically used by
the off-line translator.
Details: Lists specific rules that apply to the language element. An italics-type font is used to
denote keywords input by the user within the syntax of the element.
See Also: Refers the reader to places in the document where more information can be found.
A-10
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
Example: Displays a brief example and explanation of the element. Table A-2 through Table
A-8 list the KAREL language elements, described in this appendix, by the type of element. Table
A-9 lists these elements in alphabetical order.
Table A-2. Actions
ABORT Action
Assignment Action
CANCEL Action
CONTINUE Action
DISABLE CONDITION Action
ENABLE CONDITION Action
HOLD Action
NOABORT Action
NOMESSAGE Action
NOPAUSE Action
PAUSE Action
Port_Id Action
PULSE Action
RESUME Action
SIGNAL EVENT Action
SIGNAL SEMAPHORE Action
STOP Action
UNHOLD Action
UNPAUSE Action
Table A-3. Clauses
EVAL Clause
FROM Clause
IN Clause
WHEN Clause
WITH Clause
A-11
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
Table A-4. Conditions
ABORT Condition
CONTINUE Condition
ERROR Condition
EVENT Condition
PAUSE Condition
Port_Id Condition
Relational Condition
SEMAPHORE Condition
Table A-5. Data Types
ARRAY Data Type
BOOLEAN Data Type
BYTE Data Type
CONFIG Data Type
DISP_DAT_T Data Type
FILE Data Type
INTEGER Data Type
JOINTPOS Data Type
PATH Data Type
POSITION Data Type
QUEUE_TYPE Data Type
REAL Data Type
SHORT Data Type
STD_PTH_NODE Data Type
STRING Data Type
STRUCTURE Data Type
VECTOR Data Type
XYZWPR Data Type
XYZWPREXT Data Type
A-12
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
Table A-6. Directives
%ALPHABETIZE
%CMOSVARS
%CMOS2SHADOW
%COMMENT
%CRTDEVICE
%DEFGROUP
%DELAY
%ENVIRONMENT
%INCLUDE
%LOCKGROUP
%NOABORT
%NOBUSYLAMP
%NOLOCKGROUP
%NOPAUSE
%NOPAUSESHFT
%PRIORITY
%SHADOWVARS
%STACKSIZE
%TIMESLICE
%TPMOTION
%UNINITVARS
Table A-7. KAREL Built—In Routine Summary
Category
Identifier
Byname
CALL_PROG
CURR_PROG
PROG_LIST
CALL_PROGLIN
FILE_LIST
VAR_INFO
VAR_LIST
Data Acquisition
DAQ_CHECKP
DAQ_START
DAQ_UNREG
DAQ_REGPIPE
DAQ_STOP
DAQ_WRITE
Error Code Handling
ERR_DATA
POST_ERR
POST_ERR_L
File and Device Operation
CHECK_NAME
MOUNT_DEV
XML_ADDTAG
COMPARE_FILE
MOVE_FILE
XML_GETDATA
COPY_FILE
PRINT_FILE
XML_REMTAG
DELETE_FILE
PURGE_DEV
XML_SCAN
DISMOUNT_DEV
RENAME_FILE
XML_SETVAR
DOSFILE_INF
FORMAT_DEV
A-13
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
Table A-7. KAREL Built—In Routine Summary (Cont’d)
Category
Identifier
Serial I/O, File Usage
BYTES_AHEAD
IO_STATUS
SET_FILE_ATR
BYTES_LEFT
MSG_CONNECT
SET_FILE_POS
CLR_IO_STAT
MSG_DISCO
SET_PORT_ATR
GET_FILE_POS
MSG_PING
VOL_SPACE
GET_PORT_ATR
PIPE_CONFIG
Process I/O Setup
CLR_PORT_SIM
GET_PORT_SIM
SET_PORT_CMT
GET_PORT_ASG
GET_PORT_VAL
SET_PORT_MOD
GET_PORT_CMT
IO_MOD_TYPE
SET_PORT_SIM
GET_PORT_MOD
SET_PORT_ASG
SET_PORT_VAL
KCL Operation
KCL
KCL_NO_WAIT
KCL_STATUS
Memory Operation
CLEAR
PROG_BACKUP
RENAME_VARS
CREATE_VAR
PROG_CLEAR
SAVE
LOAD
PROG_RESTORE
SAVE_DRAM
LOAD_STATUS
RENAME_VAR
Mirror
MIRROR
Motion and Program
CNCL_STP_MTN
MOTION_CTL
RESET
Control
Multi-programming
ABORT_TASK
PAUSE_TASK
SEMA_COUNT
CLEAR_SEMA
PEND_SEMA
SET_TSK_ATTR
CONT_TASK
POST_SEMA
SET_TSK_NAME
GET_TSK_INFO
RUN_TASK
UNLOCK_GROUP
LOCK_GROUP
Path Operation
APPEND_NODE
DELETE_NODE
NODE_SIZE
COPY_PATH
INSERT_NODE
PATH_LEN
Personal Computer
ADD_BYNAMEPC
ADD_REALPC
SEND_DATAPC
Communications
ADD_INTPC
ADD_STRINGPC
SEND_EVENTPC
Position
CHECK_EPOS
FRAME
POS
CNV_JPOS_REL
IN_RANGE
POS2JOINT
CNV_REL_JPOS
J_IN_RANGE
SET_PERCH
CURPOS
JOINT2POS
UNPOS
CURJPOS
Queue Manager
APPEND_QUEUE
GET_QUEUE
INSERT_QUEUE
COPY_QUEUE
INIT_QUEUE
DELETE_QUEUE
MODIFY_QUEUE
A-14
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
Table A-7. KAREL Built—In Routine Summary (Cont’d)
Category
Identifier
Register Operation
CLR_POS_REG
GET_SREG_CMT
SET_POS_REG
GET_JPOS_REG
GET_STR_REG
SET_PREG_CMT
GET_POS_REG
POS_REG_TYPE
SET_REAL_REG
GET_PREG_CMT
SET_EPOS_REG
SET_REG_CMT
GET_REG
SET_INT_REG
SET_SREG_CMT
GET_REG_CMT
SET_JPOS_REG
SET_STR_REG
String Operation
CNV_CNF_STRG
CNV_STR_CONF
STR_LEN
CNV_CONF_STR
CNV_STR_INT
SUB_STR
CNV_INT_STR
CNV_STR_REAL
CNV_REAL_STR
System
ABS
COS
ROUND
ACOS
EXP
SET_VAR
ARRAY_LEN
GET_VAR
SIN
ASIN
INDEX
SQRT
ATAN2
INV
TAN
BYNAME
LN
TRUNC
CHR
ORD
UNINIT
Time-of-Day Operation
CNV_STR_TIME
GET_TIME
GET_USEC_TIM
CNV_TIME_STR
GET_USEC_SUB
SET_TIME
TPE Program
AVL_POS_NUM
GET_POS_FRM
SET_ATTR_PRG
CLOSE_TPE
GET_POS_TPE
SET_EPOS_TPE
COPY_TPE
GET_POS_TYP
SET_JPOS_TPE
CREATE_TPE
GET_TPE_CMT
SET_POS_TPE
DEL_INST_TPE
GET_TPE_PRM
SET_TPE_CMT
GET_ATTR_PRG
OPEN_TPE
SET_TRNS_TPE
GET_JPOS_TPE
SELECT_TPE
Translate
TRANSLATE
User Interface
ACT_SCREEN
DET_WINDOW
INI_DYN_DISS
ADD_DICT
DISCTRL_ALPH
INIT_TBL
ATT_WINDOW_D
DISCTRL_FORM
POP_KEY_RD
ATT_WINDOW_S
DISCTRL_LIST
PUSH_KEY_RD
CHECK_DICT
DISCTRL_PLMN
READ_DICT
CNC_DYN_DISB
DISCTRL_SBMN
READ_DICT_V
CNC_DYN_DISE
DISCTRL_TBL
READ_KB
CNC_DYN_DISI
FORCE_SPMENU
REMOVE_DICT
CNC_DYN_DISP
INI_DYN_DISB
SET_CURSOR
CNC_DYN_DISR
INI_DYN_DISE
SET_LANG
CNC_DYN_DISS
INI_DYN_DISI
WRITE_DICT
DEF_SCREEN
INI_DYN_DISP
WRITE_DICT_V
DEF_WINDOW
INI_DYN_DISR
A-15
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
Table A-7. KAREL Built—In Routine Summary (Cont’d)
Category
Identifier
Vector
APPROACH
ORIENT
Vision Operation
V_CAM_CALIB
V_INIT_QUEUE
V_START_VTRK
V_GET_OFFSET
V_RALC_QUEUE
V_STOP_VTRK
V_GET_PASSFL
V_RUN_FIND
VREG_FND_POS
V_GET_QUEUE
V_SET_REF
VREG_OFFSET
Table A-8. Items
CR Input/Output Item
A-16
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
Table A-9. Statements
ABORT Statement
Assignment Statement
ATTACH Statement
CANCEL Statement
CANCEL FILE Statement
CLOSE FILE Statement
CLOSE HAND Statement
CONDITION..ENDCONDITION Statement
CONNECT TIMER Statement
DELAY Statement
DISABLE CONDITION Statement
DISCONNECT TIMER Statement
ENABLE CONDITION Statement
FOR..ENDFOR Statement
GO TO Statement
HOLD Statement
IF..ENDIF Statement
OPEN FILE Statement
OPEN HAND Statement
PAUSE Statement
PROGRAM Statement
PULSE Statement
PURGE CONDITION Statement
READ Statement
RELAX HAND Statement
RELEASE Statement
REPEAT...UNTIL Statement
RESUME Statement
RETURN Statement
ROUTINE Statement
SELECT..ENDSELECT Statement
SIGNAL EVENT Statement
STOP Statement
UNHOLD Statement
USING..ENDUSING Statement
WAIT FOR Statement
WHILE..ENDWHILE Statement
WRITE Statement
A-17
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
A.2
- A - KAREL LANGUAGE DESCRIPTION
A.2.1
ABORT Action
Purpose: Aborts execution of a running or paused task
Syntax : ABORT <PROGRAM[n]>
Details:
If task execution is running or paused, the ABORT action will abort task execution.
The ABORT action can be followed by the clause PROGRAM[n], where n is the task number
to be aborted. Use GET_TASK_INFO to get a task number.
If PROGRAM[n] is not specified, the current task execution is aborted.
See Also: GET_TSK_INFO Built-in
Chapter 6 CONDITION HANDLERS
Example: Refer to Section B.6 , "Path Variables and Condition Handlers Program
(PTH_MOVE.KL)," for a detailed program example.
A.2.2
ABORT Condition
Purpose: Monitors the aborting of task execution
Syntax : ABORT <PROGRAM[n]>
The ABORT condition is satisfied when the task is aborted. The actions specified by the condition
handler will be performed.
If PROGRAM [n] is not specified, the current task number is used.
Actions that are routine calls will not be executed if task execution is aborted.
The ABORT condition can be followed by the clause PROGRAM[n], where n is the task number
to be monitored. Use GET_TSK_INFO to get a task number.
See Also: CONDITION ... ENDCONDITION Statement, GET_TSK_INFO Built-in, Chapter 6
CONDITION HANDLERS , Appendix E , “Syntax Diagrams,” for additional syntax information
Example: Refer to the following sections for detailed program examples:
Section B.6 , "Path Variables and Condition Handlers Program" (PTH_MOVE.KL)
A-18
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
Section B.10 , "Using Dynamic Display Built-ins" (DYN_DISP.KL)
A.2.3
ABORT Statement
Purpose: Terminates task execution and cancels any motion in progress (or pending)
Syntax : ABORT <PROGRAM[n]>
After an ABORT, the program cannot be resumed. It must be restarted.
The statement can be followed by the clause PROGRAM[n], where n is the task number to
be aborted.
See Also: , “Syntax Diagrams,” for additional syntax information
Example: Refer to the following sections for detailed program examples:
Section B.2 , "Copying Path Variables" (CPY_PTH.KL)
Section B.6 , "Path Variables and Condition Handlers Program" (PTH_MOVE.KL)
Section B.12 , "Displaying a List From a Dictionary File" (DCLST_EX.KL)
Section B.1 , "Setting Up Digital Output Ports for Monitoring" (DOUT_EX.KL)
A.2.4
ABORT_TASK Built-In Procedure
Purpose: Aborts the specified running or paused task
Syntax : ABORT_TASK(task_name, force_sw, cancel_mtn_sw, status)
Input/Output Parameters:
[in] task_name :STRING
[in] force_sw :BOOLEAN
[in] cancel_mtn_sw :BOOLEAN
[out] status :INTEGER
%ENVIRONMENT Group :MULTI
Details:
A-19
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
task_name is the name of the task to be aborted. If task name is ’*ALL*’, all executing or paused
tasks are aborted except the tasks that have the ‘‘ignore abort request’’ attribute set.
force_sw , if true, specifies to abort a task even if the task has the ‘‘ignore abort request’’ set.
force_sw is ignored if task_name is ’*ALL*’.
cancel_mtn_sw specifies whether motion is canceled for all groups belonging to the specified task.
status explains the status of the attempted operation. If not equal to 0, then an error occurred.
See Also: CONT_TASK, RUN_TASK, PAUSE_TASK Built-In Procedures, NO_ABORT Action,
%NO_ABORT Translator Directive, Chapter 15 MULTI-TASKING
Example: Refer to Section B.10 , "Using Dynamic Display Built-ins" (DYN_DISP.KL), for
a detailedprogram example.
A.2.5
ABS Built-In Function
Purpose: Returns the absolute value of the argument x, which can be an INTEGER or REAL
expression
Syntax : ABS(x)
Function Return Type :INTEGER or REAL
Input/Output Parameters :
[in] x :INTEGER or REAL expression
%ENVIRONMENT Group :SYSTEM
Details:
Returns the absolute value of x, with the same data type as x.
Example: Refer to Section B.7 , "Listing Files and Programs and Manipulating Strings
(LIST_EX.KL)," for a detailed program example.
A.2.6
ACOS Built-In Function
Purpose: Returns the arc cosine (cos-1) in degrees of the specified argument
Syntax : ACOS(x)
Function Return Type :REAL
A-20
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
Input/Output Parameters :
[in] x :REAL
%ENVIRONMENT Group :SYSTEM
Details:
x must be between -1.0 and 1.0; otherwise the program will abort with an error.
Returns the arccosine of x.
Example: The following example sets ans_r to the arccosine of -1 and writes this value to the screen.
The output for the following example is 180 degrees.
ACOS Built-In Function
routine take_acos
var
ans_r: real
begin
ans_r = acos (-1)
WRITE (’acos -1 ’, ans_r, CR)
END take_acos
The second example causes the program to abort since the input value is less than -1 and not within
the valid range.
ACOS Built-In Function
routine take_acos
var
ans_r: real
begin
ans_r = acos (-1.5) -- causes program to abort
WRITE (’acos -1.5 ’, ans_r, CR)
END take_acos
A.2.7
ACT_SCREEN Built-In Procedure
Purpose: Activates a screen
Syntax : ACT_SCREEN
Input/Output Parameters :
[in] screen_name :STRING
A-21
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
[out] old_screen_n :STRING
[out] status :INTEGER
%ENVIRONMENT Group :PBCORE
Details:
Causes the display device associated with the screen to be cleared and all windows attached to
the screen to be displayed.
screen_name must be a string containing the name of a previously defined screen, see
DEF_SCREEN Built-in.
The name of the screen that this replaces is returned in old_screen_n .
Requires the USER or USER2 menu to be selected before activating the new screen, otherwise
the status will be set to 9093.
— To force the selection of the teach pendant user menu before activating the screen, use
FORCE_SPMENU (tp_panel, SPI_TPUSER, 1).
— To force the selection of the CRT/KB user menu before activating the screen, use
FORCE_SPMENU (crt_panel, SPI_TPUSER, 1).
If the USER menu is exited and re-entered, your screen will be reactivated as long as the KAREL
task which called ACT_SCREEN continues to run. When the KAREL task is aborted, the system’s
user screen will be re-activated. Refer to Section 7.10 for details on the system’s user screen.
status explains the status of the attempted operation. If not equal to 0, then an error occurred.
See Also: DEF_SCREEN Built-In Procedure
Example: Refer to the following sections for detailed program examples:
Section B.12 , "Displaying a List From a Dictionary File" (DCLST_EX.KL)
A.2.8 ACT_TBL Built-In Procedure
Purpose: Acts on a key while displaying a table on the teach pendant
Syntax : ACT_TBL(action, def_item, table_data, term_char, attach_wind, status)
Input/Output Parameters :
[in,out] action :INTEGER
[in,out] def_item :INTEGER
[in,out] table_data :XWORK_T
A-22
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
[out] term_char :INTEGER
[out] attach_wind :BOOLEAN
[out] status :INTEGER
%ENVIRONMENT Group :UIF
Details:
The INIT_TBL and ACT_TBL built-in routines should only be used instead of DISCTRL_TBL
if special processing needs to be done with each keystroke or if function key processing needs to
be done without exiting the table menu.
The built-in INIT_TBL must be called before using this built-in. Do not continue if an error
occurs in INIT_TBL.
action must be one of the constants defined in the include file KLEVKEYS.KL. ACT_TBL will
act on the key and return. The following keys have special meanings:
— ky_disp_updt (Initial Display) - Table title is displayed, function key labels are displayed.
Default item is displayed and highlighted in first line. Remaining lines are displayed.
Dynamic display is initiated for all values. This should be the first key passed into ACT_TBL.
— ky_reissue (Read Key) - ACT_TBL reads a key, acts on it, and returns it in action.
— ky_cancel (Cancel Table) - All dynamic display is cancelled. This should be the last key
passed into ACT_TBL if term_char does not equal ky_new_menu. If a new menu was
selected, ACT_TBL will have already cancelled the dynamic display and you should not
use ky_cancel.
def_item is the row containing the item you want to be highlighted when the table is entered.
On return, def_item is the row containing the item that was currently highlighted when the
termination character was pressed.
table_data is used to display and control the table. Do not change this data; it is used internally.
term_char receives a code indicating the character or other condition that terminated the table.
The codes for key terminating conditions are defined in the include file KLEVKEYS.KL. Keys
normally returned are pre-defined constants as follows:
— ky_undef - No termination character was pressed
— ky_select - A selectable item was selected
— key_new_menu - A new menu was selected
— ky_f1 through ky_f10 - A function key was selected
attach_wind should be set TRUE if the table manager needs to be attached to the display devices
when action is ky_disp_updt and detached from the display devices when action is ky_cancel. If it
is already attached, this parameter can be set to FALSE. Typically this should be TRUE.
status explains the status of the attempted operation. If not equal to 0, then an error occurred.
A-23
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
Example: Refer to the example for the INIT_TBL built-in, Section A.10.12 .
A.2.9
ADD_BYNAMEPC Built-In Procedure
Purpose: To add an integer, real, or string value into a KAREL byte given a data buffer.
Syntax : ADD_BYNAMEPC(dat_buffer, dat_index, prog_name, var_name, status)
Input/Output Parameters :
[in] dat_buffer :ARRAY OF BYTE
[in,out] dat_index :INTEGER
[in] prog_name :STRING
[in] var_name :STRING
[out] status :INTEGER
%ENVIRONMENT Group :PC
Details:
dat_buffer - an array of up to 244 bytes.
dat_index - the starting byte number to place the string value.
prog_name - specifies the name of the program that contains the specified variable.
var_name - refers to a static program variable. This is only supported by an integer, real, or string
variable (arrays and structures are not supported).
status - the status of the attempted operation. If not 0, then an error occurred and data was
not placed into the buffer.
The ADD_BYNAMEPC built-in adds integer, real, and string values to the data buffer in the same
manner as the KAREL built-ins ADD_INTPC, ADD_REALPC, and ADD_STRINGPC.
See Also: ADD_BYNAMEPC, ADD_INTPC, ADD_REALPC, ADD_STRINGPC
Example: See the following for an example of the ADD_BYNAMEPC built-in.
ADD_BYNAMEPC Built-In Procedure
PROGRAM TESTBYNM
%ENVIRONMENT PC
CONST
er_abort = 2
VAR
A-24
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
dat_buffer: ARRAY[100] OF BYTE
index:
INTEGER
status:
INTEGER
BEGIN
index = 1
ADD_BYNAMEPC(dat_buffer,index, ’TESTDATA’,’INDEX’,status)
IF status<>0 THEN
POST_ERR(status,’’,0,er_abort)
ENDIF
END testbynm
A.2.10
ADD_DICT Built-In Procedure
Purpose: Adds the specified dictionary to the specified language.
Syntax : ADD_DICT(file_name, dict_name, lang_name, add_option, status)
Input/Output Parameters :
[in] file_name :STRING
[in] dict_name :STRING
[in] lang_name :STRING
[in] add_option :INTEGER
[out] status :INTEGER
%ENVIRONMENT Group :PBCORE
Details:
file_name specifies the device, path, and file name of the dictionary file to add. The file type
is assumed to be ’.TX’ (text file).
dict_name specifies the name of the dictionary to use when reading and writing dictionary
elements. Only 4 characters are used.
lang_name specifies to which language the dictionary will be added. One of the following
pre-defined constants should be used:
dp_default
dp_english
A-25

 

 

 

 

 

 

 

Content      ..     9      10      11      12     ..