--【KAREL 内置函数的介绍】
-- SET_POS_REG Built-In Procedure
-- Purpose: Stores an XYZWPR value in the specified position register
-- Syntax : SET_POS_REG(register_no, posn, status, group_no>)
-- Input/Output Parameters :
-- [in] register_no : INTEGER
-- [in] posn : XYZWPR
-- [out] status : INTEGER
-- [in] group_no : INTEGER
-- %ENVIRONMENT Group :REGOPE
-- Details:
-- • register_no specifies the position register in which to store the value.
-- • The position data is set in XYZWPR representation with no conversion.
-- • status explains the status of the attempted operation. If not equal to 0, then an error occurred.
-- • If group_no is omitted, the default group for the program is assumed. Data for other groups
-- is not changed.
-- • If group_no is specified, it must be in the range of 1 to the total number of groups defined on
-- the controller.
--【KAREL 内置函数的示例】
PROGRAM reg_ex
----------------------------------------------------
-- Creation date: 2023.08.12
-- Created by: Ming.Li
----------------------------------------------------
-- Version: 0.0.0.0 - 00
----------------------------------------------------
-- Function: 【寄存器写入数据】
----------------------------------------------------
%COMMENT = 'REGISTER_EX1'
%ALPHABETIZE
%INCLUDE KLEVKEYS
%INCLUDE KLEVKMSK
%INCLUDE KLEVCCDF
%INCLUDE KLIOUOP
%INCLUDE KLIOTYPS
CONST
cc_success = 0 -- Success status
cc_xyzwpr = 2 -- Position Register has an XYZWPR
cc_jntpos = 9 -- Position Register has a JOINTPOS
VAR
xyz :XYZWPR
jpos :JOINTPOS
r_val :REAL
prg_indx,
i_val,
pos_type,
num_axes,
status :INTEGER
r_flg :BOOLEAN
----------------------------------------------------
-- BEGIN REGISTER
----------------------------------------------------
BEGIN
-- Clear the TP USER menu screen
write(chr(137),chr(128));
-- Force the TP USER menu to be visible
FORCE_SPMENU(TP_PANEL,SPI_TPUSER,1)
WRITE('Getting Current Position',cr)
-- Get the current position
xyz = CURPOS(0,0)
WRITE('Storing Current position to PR[1]',cr)
-- Store the position in PR[1]
SET_POS_REG(1,xyz, status)
-- -- verify SET_POS_REG is successful
IF (status = cc_success) THEN
WRITE('Executing "PROG_VAL.TP"',cr)
ENDIF
-- --Execute ’PROG_VAL.TP’ starting at line 2. Do not pause on entry of PROG_VAL.
-- -- CALL_PROGLIN('PROG_VAL',2,prg_indx, FALSE)
END reg_ex