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

 

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

 

Search            copyright infringement  

 

   

 

   

 

Content      ..     21      22      23      24     ..

 

 

 

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

 

 

MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
The reserved word CR, which can be used as a data item, specifies that the next data item to be
written to the file_var will start on the next line.
Use the IO_STATUS Built-In to determine if the write operation was successful.
See Also: PATH Data Type, for more information on writing PATH variables, Chapter 7 FILE
INPUT/OUTPUT OPERATIONS , for more information on format specifiers and file_vars. Appendix
E , ‘‘Syntax Diagrams,’’ for more syntax information
Example: Refer to Appendix B , "KAREL Example Programs" for more detailed program examples.
A.24.6
WRITE_DICT Built-In Procedure
Purpose: Writes information from a dictionary
Syntax : WRITE_DICT(file_var, dict_name, element_no, status)
Input/Output Parameters:
[in] file_var :FILE
[in] dict_name :STRING
[in] element_no :INTEGER
[out] status :INTEGER
%ENVIRONMENT Group :PBCORE
Details:
file_var must be opened to the window where the dictionary text is to appear.
dict_name specifies the name of the dictionary from which to write.
element_no specifies the element number to write. This number is designated with a ‘‘$’’ in the
dictionary file.
status explains the status of the attempted operation. If not equal to 0, then an error occurred
writing the element from the dictionary file.
See Also: READ_DICT, REMOVE_DICT Built-In Procedures, Chapter 10 DICTIONARIES AND
FORMS
Example: Refer to Section B.12 , "Displaying a List From a Dictionary File" (DCLST_EX.KL), for a
detailed program example.
A-367
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
A.24.7
WRITE_DICT_V Built-In Procedure
Purpose: Writes information from a dictionary with formatted variables
Syntax : WRITE_DICT_V(file_var, dict_name, element_no, value_array, status)
Input/Output Parameters:
[in] file_var :FILE
[in] dict_name :STRING
[in] element_no :INTEGER
[in] value_array :ARRAY OF STRING
[out] status :INTEGER
%ENVIRONMENT Group :UIF
Details:
file_var must be opened to the window where the dictionary text is to appear.
dict_name specifies the name of the dictionary from which to write.
element_no specifies the element number to write. This number is designated with a $ in the
dictionary file.
value_array is an array of variable names that corresponds to each formatted data item in the
dictionary text. Each variable name may be specified as ’[prog_name]var_name’.
[prog_name] specifies the name of the program that contains the specified variable. If not
specified, then the current program being executed is used.
var_name must refer to a static, global program variable.
var_name may contain node numbers, field names, and/or subscripts.
status explains the status of the attempted operation. If not equal to 0, then an error occurred
writing the element from the dictionary file.
See Also: READ_DICT_V Built-In Procedure, Chapter 10 DICTIONARIES AND FORMS
Example: In the following example, TPTASKEG.TX contains dictionary text information which will
display a system variable. This information is the first element in the dictionary and element numbers
start at 0. util_prog uses WRITE_DICT_V to display the text on the teach pendant.
WRITE_DICT_V Built-In Procedure
----------------------------------------------
TPTASKEG.TX
A-368
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
----------------------------------------------
$ "Maximum number of tasks = %d"
----------------------------------------------
UTILITY PROGRAM:
----------------------------------------------
PROGRAM util_prog
%ENVIRONMENT uif
VAR
status: INTEGER
value_array: ARRAY[1] OF STRING[30]
BEGIN
value_array[1] = ’[*system*].$scr.$maxnumtask’
ADD_DICT(’TPTASKEG’, ’TASK’, dp_default, dp_open, status)
WRITE_DICT_V(TPDISPLAY, ’TASK’, 0, value_array, status)
END util_prog
A.25
- X - KAREL LANGUAGE DESCRIPTION
A.25.1
XML_ADDTAG Built-In Procedure
Purpose: Associates the tag “tag_name” with the “xml_file”.
Syntax : XML_ADDTAG(xml_file, tag_name, numchar, caseflag, tag_ident, status)
Input/Output Parameters:
[in] xml_file :FILE
[in] tag_name:STRING
[in] numchar:INTEGER
[in] caseflag:boolean
[in] tag_ident:INTEGER
[out] status :INTEGER
%ENVIRONMENT Group :PBCORE
Details:
xml_file specifies an open KAREL file with AR_XML attribute set
tag_name Name of the tag you want to know about
A-369
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
numchar specifies the number of characters to use when looking for the tag
caseflag If TRUE, specifies whether the tag_name is case sensitive
tag_ident Application identifier that user associates with tag There are some system tag idents
that the user cannot use. This is used to allow you to switch on his tags and the user return codes.
When the scanning encounters the registered tag it will return with the tag_ident. The file MUST
be open before you can register a tag. tag_ident should be a unique number within the application.
This allows the application to do a select based on the return identifier. NOTE: The system
reserves some identifiers for error and scan limit status returns. This allows the application to
easily include these constants in the select statement.
status explains the status of the attempted operation. If not equal to 0, then an error occurred
writing the element from the dictionary file. The return status will be bad if the user has not
opened the file and set the XML attribute.
Example: Refer to Section 9.5 .
A.25.2
XML_GETDATA Built-In Procedure
Purpose: Returns the attribute names and values associated with the tag causing the return.
Syntax : xml_getdata(xml_file, numattr, attrnames, attrvalues, text, textdone)
Input/Output Parameters:
[in] xml_file :FILE
[out] numattr: INTEGER
[out] attrnames: ARRAY OF STRING
[out] attrvalues: ARRAY OF STRING
[out] textdata: STRING
[out] textdone: BOOLEAN
[out] status: INTEGER
Details:
xml_file An open KAREL file with AR_XML attribute set
numattr indicates the number of attributes
attrnames indicates attribute names
attrvalues indicates attribute values
A-370
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
textdata indicates the text that follows the tag
textdone If this is FALSE, more text is to be read
status indicates the result of the operation
A.25.3 XML_REMTAG Built-In Procedure
Purpose: Removes the tag name from the list.
Syntax: xml_remtag(xml_file, tag_name, tag_ident, status)
Input/Output Parameters:
[in] xml_file :FILE
[in] tag_name: STRING
[OUT] status: INTEGER
Details:
xml_file Open KAREL file with AR_XML attribute set
tag_name Indicates the name of the tag to remove
status Indicates the result of the operation
A.25.4 XML_SCAN Built-In Procedure
Purpose: Scan through a previously opened XML file
Syntax : XML_SCAN(xml_file, tag_name, func_code, status)
Input/Output Parameters:
[in] xml_file :FILE
[out] tag_name:STRING
[out] tag_ident:INTEGER
[out] func_code::INTEGER
[out] status :INTEGER
A-371
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
Details:
xml_file Open KAREL file with AR_XML attribute set
tag_name Name of the tag system found
tag_ident Tag user associated in addtag call
func_code Function code, start etc
status Result of operation
When a registered tag is found
— Func_code = XML_START or XML_END or XML_STEND
— Tag_ident = The value associated with the tag when it was registered
When a text buffer is full
— Func_code = XML_TXCONT
— Tag_ident = The value associated with the tag when it was registered
After 50 lines are scanned
— Status = XML_SCANLIM, just recall the built-in when the is encountered
— Tag_ident = XML_SCANLIM
— This is not an error and indicates that there is more to come
If it encounters a parsing error
— Status = Some error
— Tag_ident = XML_ERROR
At the end of file, Status = SUCCESS
Valid Parse Errors are:
— XML_TAG_SIZE Too many characters in tag
— XML_ATTR_SIZE Too many characters in attribute
— XML_NOSLASH Invalid use of / character
— XML_INVTAG Invalid character in tag
— XML_UNMATCHATTR No value for attribute
— XML_UNMATCHTAG End tag with no matching start
— XML_INVATTR Invalid character in attribute
— XML_NOFILE Cannot find file
— XML_TAGNEST Tag nesting level too deep
— XML_COMMENT Error in comment
A-372
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
The system will provide a separate return for the start of the tag and the end of the tag if the tag
does not contain both starting and ending information. The attribute data is NOT valid when
the call is made for the END tag.
The tag_ident will be the tag_ident that the user registered for the registered tag return. If the
system returns for other reasons then the tag_ident may contain system tag data.
A.25.5
XML_SETVAR Built-In Procedure
Purpose: Sets the variable [prog_name]var_name according to the attributes that were associated
with the tag causing the return.
Syntax : xml_setvar(xml_file, prog_name, var_name, status)
Input/Output Parameters:
[in] xml_file :FILE
[in] prog_name:STRING
[in] var_name:STRING
[out] status:INTEGER
Details:
In this case the text for the attribute will be matched with the text field name of the KAREL
variable. So a variable of this type:
xmlstrct_t = STRUCTURE
first: integer
second: real
third: BOOLEAN
fourth: string[20]
ENDSTRUCTURE
Can be set via the XML:
<xmlstrct_t first="123456" second="7.8910" third="1" fourth="A string"\>
The XML tag name does not need to match the TYPE name. The association of the field names
and attribute names is based on the [program]variable in the call to xml_setvar.
A-373
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
A.25.6
XYZWPR Data Type
Purpose: Defines a variable, function return type, or routine parameter as XYZWPR data type
Syntax : XYZWPR <IN GROUP [n]>
Details:
An XYZWPR consists of three REAL components specifying a Cartesian location (x,y,z), three
REAL components specifying an orientation (w,p,r), and a component specifying a CONFIG
Data Type, 32 bytes total.
The configuration string indicates the joint placements and multiple turns that describe the
configuration of the robot when it is at a particular position.
A position is always referenced with respect to a specific coordinate frame.
Components of XYZWPR variables can be accessed or set as if they were defined as follows:
XYZWPR Data Type
XYZWPR = STRUCTURE
X: REAL
Y: REAL
Z: REAL
W: REAL
P: REAL
R: REAL
CONFIG_DATA: CONFIG
ENDSTRUCTURE
Note: All fields are read-write access.
Example: Refer to the following sections for detailed program examples:
Section B.2 , "Copying Path Variables" (CPY_PTH.KL)
Section B.5 ,"Using Register Built-ins" (REG_EX.KL)
Section B.6 , "Path Variables and Condition Handlers Program" (PTH_MOVE.KL)
Section B.8 , "Generating and Moving Along a Hexagon Path" (GEN_HEX.KL)
Section B.1 , "Setting Up Digital Output Ports for Monitoring" (DOUT_EX.KL)
A-374
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
A.25.7
XYZWPREXT Data Type
Purpose: Defines a variable, function return type, or routine parameter as an XYZWPREXT
Syntax : XYZWPREXT <IN GROUP [n]>
Details:
An XYZWPREXT consists of three REAL components specifying a Cartesian location (x,y,z),
three REAL components specifying an orientation (w,p,r), and a component specifying a
configuration string. It also includes three extended axes, 44 bytes total.
The configuration string indicates the joint placements and multiple turns that describe the
configuration of the robot when it is at a particular position.
A position is always referenced with respect to a specific coordinate frame.
Components of XYZWPREXT variables can be accessed or set as if they were defined as follows:
XYZWPREXT Data Type
XYZWPRext = STRUCTURE
X: REAL
Y: REAL
Z: REAL
W: REAL
P: REAL
R: REAL
CONFIG_DATA: CONFIG
EXT1: REAL
EXT2: REAL
EXT3: REAL
ENDSTRUCTURE
--Note: All fields are read-write access.
A.26
- Y - KAREL LANGUAGE DESCRIPTION
There are no KAREL descriptions beginning with "Y".
A.27
- Z - KAREL LANGUAGE DESCRIPTION
There are no KAREL descriptions beginning with "Z".
A-375
Appendix B
KAREL EXAMPLE PROGRAMS
Contents
Appendix B KAREL EXAMPLE PROGRAMS
B-1
B.1
SETTING UP DIGITAL OUTPUT PORTS FOR PROCESS MONITORING
B-6
B.2
COPYING PATH VARIABLES
B-18
B.3
SAVING DATA TO THE DEFAULT DEVICE
B-28
B.4
STANDARD ROUTINES
B-31
B.5
USING REGISTER BUILT-INS
B-33
B.6
PATH VARIABLES AND CONDITION HANDLERS PROGRAM
B-38
B.7
LISTING FILES AND PROGRAMS AND MANIPULATING STRINGS
B-44
B.8
GENERATING AND MOVING ALONG A HEXAGON PATH
B-49
B.9
USING THE FILE AND DEVICE BUILT-INS
B-54
B.10
USING DYNAMIC DISPLAY BUILT-INS
B-58
B.11
MANIPULATING VALUES OF DYNAMICALLY DISPLAYED VARIABLES
B-68
B.12
DISPLAYING A LIST FROM A DICTIONARY FILE
B-70
B.12.1
Dictionary Files
B-80
B.13
USING THE DISCTRL_ALPHA BUILT-IN
B-81
B.13.1
Dictionary Files
B-85
B.14
APPLYING OFFSETS TO A COPIED TEACH PENDANT PROGRAM
B-85
B-1
B. KAREL EXAMPLE PROGRAMS
MARRC75KR07091E Rev D
This appendix contains some KAREL program examples. These programs are meant to show you
how to use the KAREL built-ins and commands described in Appendix A , "KAREL Language
Alphabetical Description."
This section includes examples of how to use the KAREL built-ins and commands in a program.
Refer to Appendix A , for more detailed information on each of the KAREL built-ins and commands.
Table B-1 lists the programs in this section, their main function, the built-ins used in each program,
and the section to refer to for the program listing.
Conventions
Each program in this appendix is divided into five sections.
Section 0 - Lists each element of the KAREL language that is used in the example program.
Section 1 - Contains the program and environment declarations.
Section 2 - Contains the constant, variable, and type declarations.
Section 3 - Contains the routine declarations.
Section 4 - Contains the main body of the program.
Table B-1. KAREL Example Programs
Program Name
Program Function
Built-ins Used
Section to Refer
CPY_PTH.KL
Copies path
APPEND_NODE
Section B.2
variables.
BY_NAME
CALL_PROG
CNV_INT_STR
COPY_PATH
CREATE_VAR
CURPOS
DELETE_NODE
LOAD
PATH_LEN
PROG_LIST
READ_KB
SET_CURSOR
SET_FILE_ATR
SET_VAR
SUB_STR
VAR_LIST
SAVE_VRS.KL
Saves data to the
DELETE_FILE
Section B.3
default device.
SAVE
B-2
MARRC75KR07091E Rev D
B. KAREL EXAMPLE PROGRAMS
Table B-1. KAREL Example Programs (Cont’d)
Program Name
Program Function
Built-ins Used
Section to Refer
ROUT_EX.KL
Contains standard
CHR
Section B.4
routines that are
FORCE_SPMENU
used throughout the
program examples.
REG_EX.KL
Uses Register
CALL_PROGLIN
Section B.5
built-ins.
CHR
CURPOS
GET_JPOS_REG
GET_POS_REG
GET_REG
POS_REG_TYP
SET_INT_REG
SET_JPOS_REG
SET_POS_REG
FORCE_SPMENU
PTH_MOVE.KL
Teaches and moves
CHR
Section B.6
along a path. Also
CNV_REL_JPOS
uses condition
PATH_LEN
handlers.
SET_CURSOR
LIST_EX.KL
Lists files and
ABS
Section B.7
programs, and
ARRAY_LEN
manipulate strings.
CNV_INT_STR
FILE_LIST
LOAD
LOAD_STATUS
PROG_LIST
ROUND
SUB_STR
GEN_HEX.KL
Generates a
CNV_REL_JPOS
Section B.8
hexagon, and moves
COS
along the path.
CURPOS
SIN
FILE_EX.KL
Uses the File and
CNV_TIME_STR
Section B.9
Device built-ins.
COPY_FILE
DISMOUNT_DEV
FORMAT_DEV
GET_TIME
MOUNT_DEV
SUB_STR
B-3
B. KAREL EXAMPLE PROGRAMS
MARRC75KR07091E Rev D
Table B-1. KAREL Example Programs (Cont’d)
Program Name
Program Function
Built-ins Used
Section to Refer
DYN_DISP.KL
Uses Dynamic
ABORT_TASK
Section B.10
Display built-ins.
CNC_DYN_DISB
CNC_DYN_DISE
CNC_DYN_DISP
CNC_DYN_DISS
CNC_DYN_DISI
CNC_DYN_DISR
INI_DYN_DISB
INI_DYN_DISE
INI_DYN_DISP
INI_DYN_DISS
INI_DYN_DISI
INI_DYN_DISR
LOAD
LOAD_STATUS
RUN_TASK
CHG_DATA.KL
Processes and
Section B.11
changes values
of dynamically
displayed variables.
DCLST_EX.KL
Displays a list from a
ADD_DICT
Section B.12.1
dictionary file.
ACT_SCREEN
ATT_WINDOW_S
CHECK_DICT
CLR_IO_STAT
CNV_STR_INT
DEF_SCREEN
DISCTRL_LIST
FORCE_SPENU
IO_STATUS
ORD
READ_DICT
REMOVE_DICT
SET_FILE_ATR
SET_WINDOW
STR_LEN
UNINIT
WRITE_DICT
DCLISTEG.UTX
Dictionary file.
N/A
Section B.12
B-4
MARRC75KR07091E Rev D
B. KAREL EXAMPLE PROGRAMS
Table B-1. KAREL Example Programs (Cont’d)
Program Name
Program Function
Built-ins Used
Section to Refer
DCALP_EX.KL
Uses the
ADD_DICT
Section B.13
DISCTRL_ALPHA
CHR
Built-in.
DISCTRL_ALPH
FORCE_SPEMU
POST_ERR
SET_CURSOR
SET_LANG
DCALPHEG.UTX
Dictionary file.
N/A
Section B.13.1
CPY_TP.KL
Applies offsets to
AVL_POS_NUM
Section B.14
copied teach pendant
CHR
pro grams.
CLOSE_TPE
CNV_JPOS_REL
CNV_REL_JPOS
COPY_TPE
GET_JPOS_TYP
GET_POS_TPE
GET_POS_TYP
OPEN TPE
PROG_LIST
SELECT_TPE
SET_JPOS_TPE
SET_POS_TPE
B-5
B. KAREL EXAMPLE PROGRAMS
MARRC75KR07091E Rev D
Table B-1. KAREL Example Programs (Cont’d)
Program Name
Program Function
Built-ins Used
Section to Refer
DOUT_EX.KL
Sets up digital output
CHRPATH_LEN
Section B.1
ports for process
CURPOS
monitoring. The
DELAY
DOUTs are used to
FORCE_SPMENU
monitor the status
RESET
of the external
SET_PORT_ASG
equipment and to
SET_PORT_CMT
show the current
SET_PORT_MOD
status of the process.
SET_PORT_SIM
The equipment
status DOUTs are
simulated, but in
practice they are
looked up to the
actual external
equipment as a
feedback response.
The robot is moved
along a path until the
external equipment
needs servicing,
which is triggered by
the DOUT values.
B.1
SETTING UP DIGITAL OUTPUT PORTS FOR PROCESS
MONITORING
This program sets up digital output ports for process monitoring. The DOUT are to monitor the
external equipment status and show the current status of the process. The equipment status DOUT’s
are simulated, but in practice are hooked up to the actual external equipments as a feedback response.
The robot is moved along a path until external equipment needs to be serviced, which is triggered
by the DOUT values.
Setting Up Digital Output Ports for Process Monitoring - Overview
--------------------------------------------------------------------------
----
DOUT_EX.Kl
--------------------------------------------------------------------------
--------------------------------------------------------------------------
----
Section 0: Detail about DOUT_EX.kl
--------------------------------------------------------------------------
---- Elements of KAREL Language Covered:
B-6
MARRC75KR07091E Rev D
B. KAREL EXAMPLE PROGRAMS
----
Action:
----
CONTINUE
Sec
4-A
----
ENABLE CONDITION
Sec
3-B; 4-C
----
NOMESSAGE
Sec
4-A
----
RESUME
Sec
4-C
----
ROUTINE CALL
Sec
4-A,C
----
SIGNAL EVENT
Sec
4-C
----
STOP
Sec
4-C
----
UNPAUSE
Sec
4-A
----
Clauses:
----
FROM
Sec
3-A
----
WHEN
Sec
4-A,C
----
Conditions:
----
ERROR[xxx]
Sec
4-A
----
EVENT
Sec
4-C
----
RELATIONAL condition
Sec
4-A
----
Data types:
----
BOOLEAN
Sec
2
----
INTEGER
Sec
2
----
PATH
Sec
2
----
XYZWPREXT
Sec
2
----
STRING
Sec
2
----
XYZWPR
Sec
2
Setting Up Digital Output Ports for Monitoring Teach Pendant Program - Overview Continued
----
Directives:
----
ALPHABETIZE
Sec 1
----
COMMENT
Sec 1
----
CMOSVARS
Sec 1
----
INCLUDE
Sec 1
----
Built-in Functions & Procedures:
----
CHR
Sec 3-E; 4-D
----
CURPOS
Sec 3-E
----
DELAY
Sec 3-B,E
----
FORCE_SPMENU
Sec 3-E; 4-D
----
PATH_LEN
Sec 4-B; 4-D
----
RESET
Sec 3-B
----
SET_PORT_ASG
Sec 3-D
----
SET_PORT_CMT
Sec 3-D
----
SET_PORT_MOD
Sec 3-C
----
SET_PORT_SIM
Sec 4-D
----
SET_POS_REG
Sec 3-E, 4-D
----
SET_EPOS_REG
Sec 3-E
----
Statements:
----
ABORT
Sec 3-D; 4-B,D
B-7
B. KAREL EXAMPLE PROGRAMS
MARRC75KR07091E Rev D
----
ATTACH
Sec 4-B
----
CONNECT TIMER
Sec 4-A
----
CONDITION...ENDCONDITON
Sec 4-A,C
----
ENABLE CONDITION
Sec 3-B,E; 4-A,C
----
FOR...ENDFOR
Sec 3-D
----
IF...THEN...ENDIF
Sec 3-B,C,D; 4-B,C,D
----
RELEASE
Sec 4-B
----
ROUTINE
Sec 3-A,B,C,D,E,F
----
WAIT FOR
Sec 3-E
----
WHILE...ENDWHILE
Sec 4-B
----
WRITE
Sec 3-B,D,E; 4-B,D
----
Reserve Words:
----
BEGIN
Sec 3-B,C,D,E; 4
----
CONST
Sec 2
----
CR
Sec 3-B,D,E; 4-B,D
----
END
Sec 3-B,C,D,E, 4-D
----
NOT
Sec 3-B; 4-C
----
PROGRAM
Sec 1
----
VAR
Sec 2
----
Predefined FILE names:
----
TPFUNC
Sec 4-D
Setting Up Digital Output Ports for Process Monitoring - Declaration Section
----------------------------------------------------------------------------
----
Section 1: Program and Environment Declaration
----------------------------------------------------------------------------
PROGRAM DOUT_EX
-- Define the program name
%ALPHABETIZE
-- CReate the variables in alphabetical order
%NOPAUSE
= TPENABLE
-- Do not pause the program if TP is ENABLED.
-- during execution.
%COMMENT
= ’PORT/CH DOUT_EX’
%CMOSVARS
-- Make sure variables are stored in CMOS
%INCLUDE KLIOTYPS
----------------------------------------------------------------------------
----
Section 2: Constant and Variable Declarations
----------------------------------------------------------------------------
CONST
-- Condition Handler Numbers
CONT_CH
= 2
-- Continue execution condition
EQIP_FAIL
= 3
-- Equipment Failure Condition
RESTART
= 6
-- Restart condition Handler
SERV_DONE
= 4
-- Servicing Done condition
UNINIT_CH
= 10
-- Monitor for uninit error
WARMED_UP
= 5
-- Event to notify eqip is ready
-- Process DOUT numbers ( 1 thru 6 are complementary DOUT )
B-8
MARRC75KR07091E Rev D
B. KAREL EXAMPLE PROGRAMS
--
( 3 and 4 are
simulated DOUT )
EQIP_READY = 1
--
Equipment Ready
EQIP_NOT_RD= 2
--
Equipment Not Ready
EQIP_ERROR = 3
--
Equipment Failed during process
EQIP_FIXED = 4
--
Equipment Fixed after failure
EQIP_ON
= 5
--
Turn Eqip-1 ON DOUT
EQIP_OFF
= 6
--
Turn Eqip-1 OFF DOUT
NODE_PULSE = 7
--
Node Pulsing DOUT
FINISH
= 8
--
Path Finishing signal DOUT
-- Process Constants
SUCCESS
= 0
--
Successful Operation Status
UNASIGNED
= 13007
--
Unassigned Port Deletion Error
VAR
cont_timer,
last_node, node_ind,
status
:INTEGER
--
Status from builtin calls
prg_abrt
:BOOLEAN
--
Set when the program is aborted
pth1
:PATH
--
Process Path
stop_pos
:XYZWPREXT
--
Process Stop Position
perch_pos
:XYZWPR
--
Perch Position
tmp_xyz
:XYZWPR
--
XYZWPR variable for temporary use
indx
:INTEGER
--
Used a FOR loop counter
ports_ready
:BOOLEAN
--
Check if ports assigned
cmt_str
:STRING[10]
--
Comment String
Setting Up Digital Output Ports for Process Monitoring - Declare Routines
---------------------------------------------------------------------------
----
Section 3: Routine Declaration
---------------------------------------------------------------------------
---------------------------------------------------------------------------
----
Section 3-A: TP_CLS Declaration
----
This routine is from ROUT_EX.kl and will
----
clear the TP USER menu screen and force
----
it to be visible.
---------------------------------------------------------------------------
ROUTINE tp_cls FROM rout_ex
-- ROUT_EX must also be loaded.
---------------------------------------------------------------------------
----
Section 3-B: port_init Declaration
----
This routine assigns a value to ports_ready, which
----
allows the ports to be initialized. It resets the
----
controller so that program execution may be continued
----
automatically though the CONT_CH condition handler.
---------------------------------------------------------------------------
ROUTINE init_port
VAR
B-9
B. KAREL EXAMPLE PROGRAMS
MARRC75KR07091E Rev D
reset_ok: BOOLEAN
BEGIN
ports_ready = FALSE
-- Set false so ports will be initialized
DELAY 500;
RESET(reset_ok)
-- Reset the controller
IF (NOT reset_ok) THEN
WRITE(’Reset Failed’, CR)
ENDIF
cont_timer = 0
-- Set a timer to continue the process
ENABLE CONDITION[CONT_CH]
-- Enabled the CONT_CH which continues
-- program execution
END init_port
Setting Up Digital Output Ports for Process Monitoring - Declare Routines
-----------------------------------------------------------------------------
----
Section 3-C: SET_MODE Declaration
----
Sets up the mode of IO’s. Depending on the passed
----
parameter the IO ports will be set to REVERSE
----
and/or COMPLEMENTARY mode. When the ports are set
----
to REVERSE mode, the TRUE condition is represented by
----
a FALSE signal. When COMPLEMENTARY mode is selected
----
for a port (odd number port), the port n and n+1 are
----
complementary signal of each other.
-----------------------------------------------------------------------------
ROUTINE set_mode(port_type:
INTEGER;
port_no:
INTEGER;
reverse:
BOOLEAN;
complmnt:
BOOLEAN)
VAR
mode:
INTEGER
BEGIN
-- set_mode
IF reverse THEN
mode = 1
-- Set the reverse mode
ELSE
mode = 0
ENDIF
IF complmnt THEN
mode = mode OR 2
-- Set complementary mode
ENDIF
SET_PORT_MOD(port_type, port_no, mode, status)
END set_mode
Setting Up Digital Output Ports for Process Monitoring - Declare Routines
B-10
MARRC75KR07091E Rev D
B. KAREL EXAMPLE PROGRAMS
---------------------------------------------------------------------------
----
Section 3-D: SETUP_PORTS Declaration
----
This section assumes that you do not have an AB or GENIUS I/O
----
or any other external I/O board. Therefore, any previous port
----
assignments are no longer needed for this application, and
----
can be deleted.
---------------------------------------------------------------------------
ROUTINE setup_ports
VAR
port_n
: INTEGER
BEGIN
-- Delete DIGITAL OUTPUT PORTS 1 thru 48
FOR port_n = 0 to 5 DO
-- Indexing of 0 to 5 may not be obvious, But look into the DIGITAL
-- OUT Configuration screen in TP, you will see the 8 DIGITAL OUTPUT
-- ports are grouped together in configuration.
SET_PORT_ASG(IO_DOUT, port_n*8+1, 0, 0, 0, 0, 0, status)
IF (status <> SUCCESS) AND (status <> UNASIGNED) THEN
-- Verify that deletion by SET_PORT_ASG was successful
WRITE (’SET_PORT_ASG built-in for DOUT (deletion) failed’,CR)
WRITE (’Status = ’,status,CR)
ENDIF
ENDFOR
-- Assign the DIGITAL PORTS 1 THRU 48 as memory images.
FOR port_n = 0 TO 5 DO
SET_PORT_ASG(IO_DOUT, port_n*8+1, 0, 0, io_mem_boo, port_n*8+1, 8, status)
IF (status <> 0 ) THEN
-- Verify that SET_PORT_ASG was successful
WRITE (’SET_PORT_ASG built-in for DOUT (assignment) failed’,CR)
WRITE (’Status = ’,status,CR)
ENDIF
ENDFOR
-- Suppose equipment-1 is turned ON by the DOUT[1] = TRUE signal and
-- turned OFF by the DOUT[2] = TRUE signal. To avoid both signals being
-- TRUE or FALSE at the same time, set DOUT[1] to be a complement.
-- Once the DOUT[1] is set in complementary mode, the DOUT[1] and
-- DOUT[2] will always show the opposite signal of each other.
-- Thus avoiding the confusion of turning the equipment OFF and ON
-- at the same time.
-- Set port-1, port-3 and port-5 to COMPLEMENTARY mode.
FOR port_n = 1 to 6 DO
SET_MODE(io_dout, port_n, TRUE, TRUE)
IF (status <> SUCCESS) THEN
WRITE (’SET_PORT_MODE Failed on port ’,1,CR)
WRITE (’With Status = ’,status,CR)
ENDIF
ENDFOR
B-11
B. KAREL EXAMPLE PROGRAMS
MARRC75KR07091E Rev D
Setting Up Digital Output Ports for Process Monitoring - Declare Routines
-- Set appropriate comments for the ports.
SET_PORT_CMT(IO_DOUT, EQIP_READY, ’Equip-READY ’,status)
IF (status <> 0 ) THEN
-- Verify SET_PORT_CMT was successful
WRITE (’SET_PORT_CMT built-in failed’,CR)
WRITE (’Status = ’,status,CR)
ENDIF
SET_PORT_CMT(IO_DOUT, EQIP_NOT_RD, ’E - NOT READY’,status)
IF (status <> 0 ) THEN
-- Verify SET_PORT_CMT was successful
WRITE (’SET_PORT_CMT built-in failed’,CR)
WRITE (’Status = ’,status,CR)
ENDIF
SET_PORT_CMT(IO_DOUT, EQIP_ERROR, ’Equip- ERROR’,status)
IF (status <> 0 ) THEN
-- Verify SET_PORT_CMT was successful
WRITE (’SET_PORT_CMT built-in failed’,CR)
WRITE (’Status = ’,status,CR)
ENDIF
SET_PORT_CMT(IO_DOUT, EQIP_FIXED, ’Equip- FIXED’,status)
IF (status <> 0 ) THEN
-- Verify SET_PORT_CMT was successful
WRITE (’SET_PORT_CMT built-in failed’,CR)
WRITE (’Status = ’,status,CR)
ENDIF
SET_PORT_CMT(IO_DOUT, EQIP_ON, ’Equip- ON’,status)
IF (status <> 0 ) THEN
-- Verify SET_PORT_CMT
was
successful
WRITE (’SET_PORT_CMT built-in failed’,CR)
WRITE (’Status = ’,status,CR)
ENDIF
SET_PORT_CMT(IO_DOUT, EQIP_OFF, ’Equip- OFF’,status)
IF (status <> 0 ) THEN
-- Verify SET_PORT_CMT
was
successful
WRITE (’SET_PORT_CMT built-in failed’,CR)
WRITE (’Status = ’,status,CR)
ENDIF
SET_PORT_CMT(IO_DOUT, NODE_PULSE, ’Pulse @ node’,status)
IF (status <> 0 ) THEN
-- Verify SET_PORT_CMT
was
successful
WRITE (’SET_PORT_CMT built-in failed’,CR)
WRITE (’Status = ’,status,CR)
ENDIF
SET_PORT_CMT(IO_DOUT, FINISH, ’Finish PATH’,status)
IF (status <> 0 ) THEN
-- Verify SET_PORT_CMT
was
successful
WRITE (’SET_PORT_CMT built-in failed’,CR)
WRITE (’Status = ’,status,CR)
ENDIF
Setting Up Digital Output Ports for Process Monitoring - Declare Routines
B-12
MARRC75KR07091E Rev D
B. KAREL EXAMPLE PROGRAMS
TP_CLS
-- clear the teach pendant USER screen
WRITE (’PORT SETUP IS COMPLETE’,CR)
WRITE (’AT THIS POINT YOU NEED TO COLD START’,CR)
WRITE (’Configuration changes of PORTs will not’,CR)
WRITE (’take effect until after a COLD START.’,CR,CR)
WRITE (’Once the controller is ready after’,CR)
WRITE (’COLD START, re-load this program’,CR)
WRITE (’rerun.’,CR)
ports_ready = TRUE
-- Set the ports_ready variable so re-execution of
-- this routine, setup_ports, is not performed.
-- Aborting program to allow for the cold start.
ABORT
END setup_ports
----------------------------------------------------------------------------
----
Section 3-E: SERVICE_RTN interrupt routine Declaration
----
This routine waits until the equipment has been
----
serviced and then moves the robot back to where
----
it was before servicing. It then sets the DOUT
----
to notify that the equipment is ready.
----------------------------------------------------------------------------
ROUTINE service_rtn
BEGIN
TP_CLS
-- store the current position, where the process is stopped due to failure
-- so after resuming the process can be started from this point.
stop_pos = CURPOS(0,0)
-- move the robot to the perch position so the equipment
-- can be worked on safely.
SET_POS_REG(1, perch_pos, status) —— Put perch_pos in PR[1]
move_to_pr -- Call TP program to move to PR[1]
WRITE (chr(139),’ PLEASE READ ’,chr(143),CR)
--Display in reverse video
WRITE (’Equipment - 1 failed during’,CR)
WRITE (’processing. Motions have been stopped.’,CR)
WRITE (’Please Fix the equipment then’,CR)
WRITE (’SET DOUT[’,EQIP_FIXED,’] = TRUE ’,CR)
--Display the following message in reverse video
WRITE (chr(139), ’IMPORTANT: Once the DOUT is set, current’,CR)
WRITE (’STOPPED motion will be RESUMED’,chr(143),CR)
WAIT FOR DOUT[EQIP_FIXED]
-- wait until equipment has been fixed
Setting Up Digital Output Ports for Process Monitoring - Declare Routines
-- Move to the point where the process was stopped
SET_EPOS_REG(1, stop_pos, status)
B-13
B. KAREL EXAMPLE PROGRAMS
MARRC75KR07091E Rev D
move_to_pr -- Call TP program to move to PR[1]
-- Enable the SERVICE-DONE condition handler to resume the process.
ENABLE CONDITION[SERV_DONE]
-- Wait a sufficient time to allow equipment to warm up and get ready for
-- processing after the fix is completed.
WRITE (’Continuing the process
’,CR)
DELAY 2000
--Signal that the equipment is now ready.
DOUT[EQIP_READY] = TRUE
-- Force the teach pendant back to the IO screen
FORCE_SPMENU(tp_panel, SPI_TPDIGIO, 1)
END service_rtn
----------------------------------------------------------------------------
----
Section 3-F: Routines frst_nod, mid_nods and end_nod are TP
----
routines for doing moves with Time Before clauses
----------------------------------------------------------------------------
ROUTINE frst_nod FROM frst_nod
-- frst_nod must also be loaded.
–—
1:L PR[1] 100mm/sec CNT100 TB
0.00sec,DO[1:NODE_PULSE]=PULSE,1.0sec
;
--
2:L PR[1] 100mm/sec CNT100 TB
0.00sec,DO[2:EQUIP_ON]=PULSE,2.0sec
;
ROUTINE mid_nods FROM mid_nods
-- mid_nods must also be loaded.
--
1:L P[1] 100mm/sec CNT100 TB
0.00sec,DO[1:NODE_PULSE]=PULSE,1.0sec
;
ROUTINE end_nod FROM end_nod
-- end_nod must also be loaded.
--
1:L P[1] 100mm/sec FINE TB
.20sec,DO[3:FINISH]=ON
;
--
2:L P[1] 100mm/sec FINE TB
0.00sec,DO[1:NODE_PULSE]=PULSE,1.0sec
;
Setting Up Digital Output Ports for Process Monitoring - Main
-----------------------------------------------------------------------------
----
Section 4: Main Program
-----------------------------------------------------------------------------
BEGIN
-- DOUT_EX
-----------------------------------------------------------------------------
----
Section 4-A: Global Condition Handler Declaration
-----------------------------------------------------------------------------
CONDITION[UNINIT_CH]:
WHEN ERROR[12311] DO
-- Trap UNINITIALIZATION error
NOMESSAGE
-- Supress the error message
UNPAUSE
-- UNPAUSE
init_port
-- Allow ports to be initialized.
ENDCONDITION
ENABLE CONDITION[UNINIT_CH]
CONNECT TIMER to cont_timer
CONDITION [CONT_CH]:
WHEN cont_timer > 1000 DO
B-14
MARRC75KR07091E Rev D
B. KAREL EXAMPLE PROGRAMS
CONTINUE
ENDCONDITION
Setting Up Digital Output Ports for Process Monitoring - Main
-----------------------------------------------------------------------------
----
Section 4-B: Verify PATH variable, pth1, has been taught.
-----------------------------------------------------------------------------
tp_cls
-- Routine Call; Clears the TP USER menu and
-- forces the TP USER menu to be visible.
-- Check the number of nodes in the path
IF PATH_LEN(pth1) = 0 THEN
-- Path is empty (no nodes)
WRITE (’You need to teach the path.’,CR) -- Display instructions
WRITE (’before executing this program.’,CR)
WRITE (’Teach the PATH variable pth1’, CR, ’and restart the program’,CR)
WRITE (’PROGRAM ABORTED’,CR)
ABORT
-- ABORT the task. do not continue
-- There are no nodes to move to
ENDIF
--
Set Perch Position
--
This position is used in the service_rtn routine
IF
UNINIT(perch_pos) THEN
WRITE (’PERCH POSITION is not recorded.’,cr)
WRITE (’RELEASing Motion Control to TP.’,cr)
WRITE (’Please Move robot to desired Perch Pos’,cr)
-- Wait until the DEADMAN switch is HELD and
-- TP is TURNED ON to move robot from TP.
WHILE ((TPIN[248] = ON) AND (TPIN[247] = ON)) DO
WRITE TPPROMPT(CHR(128),CHR(137),’Hold Down the DEAD-MAN switch’)
DELAY 500
ENDWHILE
-- Release motion control from the KAREL program to the
-- TP control. Robot can be moved to desired Perch
-- position with out disturbing the flow of this KAREL task.
RELEASE
WHILE (TPIN[249] = OFF ) DO
WRITE TPPROMPT(CHR(128),CHR(137),’Turn the TP ON’)
DELAY 1000
ENDWHILE
WRITE (’ROBOT is ready to move from TP’,cr)
WRITE (’After moving ROBOT to PERCH position ’,cr)
WRITE (’Turn OFF the TP then RELEASE DEADMAN ’,cr)
WHILE (TPIN[249] = ON ) DO
WRITE TPPROMPT(CHR(128),CHR(137),’Turn OFF TP, after MOVE is done
DELAY 10000
B-15
B. KAREL EXAMPLE PROGRAMS
MARRC75KR07091E Rev D
ENDWHILE
Setting Up Digital Output Ports for Process Monitoring - Main
-- KAREL program execution will not continue passed ATTACH
-- statement until the TP is turned OFF.
-- Wait until the TP is TURNED OFF after move from TP is completed.
WHILE (TPIN[249] = ON ) DO
DELAY 2000
ENDWHILE
-- At this point the robot is positioned to the desired
-- Perch position. Get the motion
-- control back from TP and record the perch position.
ATTACH
perch_pos = CURPOS(0,0,1)
ENDIF
----------------------------------------------------------------------------
----Section 4-C: Set up Ports and Declare Process dependant condition
handler
----------------------------------------------------------------------------
-- Port assignments need to be assigned only once and take effect
-- after the controller is COLD STARTED.
-- The ports_ready variable is used to determine if the ports have
-- already been assigned by this program.
-- Therefore only the first execution of this program will assign the ports
IF NOT(ports_ready) THEN
setup_ports
ENDIF
-- Define a condition handler to trap equipment failure.
-- If equipment fails during the process, then the DOUT[EQIP_ERROR] is
-- set to TRUE. Which will stop the motion and require the equipment to be
-- fixed before motion can be resumed.
CONDITION[EQIP_FAIL]:
WHEN DOUT[EQIP_ERROR] DO
STOP
DOUT[EQIP_FIXED] = FALSE
DOUT[EQIP_READY] = FALSE
ENABLE CONDITION[RESTART]
service_rtn
ENDCONDITION
ENABLE CONDITION[EQIP_FAIL]
-- Define a condition handler to monitor the servicing process.
-- Once Servicing/Fixing of equipment is complete, wait for the equipment
-- to be in READY mode. When the equipment is READY, signal an event
-- which will restart the process where it left off. The SERV_DONE
-- condition handler is ENABLED from the SERVICE_RTN interrupt routine.
B-16
MARRC75KR07091E Rev D
B. KAREL EXAMPLE PROGRAMS
CONDITION[SERV_DONE]:
WHEN DOUT[EQIP_READY] DO
SIGNAL EVENT[WARMED_UP]
DOUT[EQIP_ERROR] = FALSE
ENDCONDITION
Setting Up Digital Output Ports for Process Monitoring - Main
-- Define a condition handler to monitor when the warm up is complete, then
-- resume the stopped motion and continue the process. Also re-enable
-- the EQIP_FAIL condition handler to continue monitoring for equipment
-- failure.
CONDITION[RESTART]:
WHEN EVENT[WARMED_UP] DO
RESUME
ENABLE CONDITION[EQIP_FAIL]
ENDCONDITION
----------------------------------------------------------------------------
----
Section 4-D: Do process manipulation
----------------------------------------------------------------------------
-- Using the PATH_LEN built-in find out the last node of the path
last_node = PATH_LEN(pth1)
-- Setting EQIP_ERROR/EQIP_FIXED number ports to be simulated.
-- This setup does not require cold start, can change the port to be
-- simulated on the fly.
SET_PORT_SIM(io_dout, NODE_PULSE, 1, status)
IF (status <> SUCCESS) THEN
WRITE (’SET_PORT_SIM Failed on port ’,indx,CR)
WRITE (’With Status = ’,status,CR)
ENDIF
SET_PORT_SIM(io_dout, FINISH, 1, status)
IF (status <> SUCCESS) THEN
WRITE (’SET_PORT_SIM Failed on port ’,indx,CR)
WRITE (’With Status = ’,status,CR)
ENDIF
Setting Up Digital Output Ports for Process Monitoring - Main
WRITE (’ NOW YOU WILL SEE THE DOUT[’,NODE_PULSE,’] PULSE’,CR)
WRITE (’ as the robot moves through every node.’,CR,CR)
WRITE (’ To simulate EQUIPMENT failure, change ’,CR)
WRITE (’ DOUT[’,EQIP_ERROR,’] = TRUE. ’,CR)
WRITE (’ Press ’’ENTER’’ to Continue’,CR)
READ(CR)
-- Change the TP display to the DI/O Screen
B-17
B. KAREL EXAMPLE PROGRAMS
MARRC75KR07091E Rev D
FORCE_SPMENU(tp_panel, SPI_TPDIGIO, 1)
-- Moving along path when equipment is ready.
-- Need to turn on equipment-1 for 1/2 second when robot position
-- is at 1st node. Pulse the DOUT[NODE_PULSE] for every node
-- Turn on the DOUT[FINISH] about 200 ms before the last node.
IF DOUT[EQIP_READY] THEN
tmp_xyz = pth1[1] -- Convert path node to XYZWPR
SET_POS_REG(1, tmp_xyz, status) -- Put position in PR[1]
frst_nod -- Call TP program to do move
FOR node_ind = 2 TO (last_node - 1) DO
tmp_xyz = pth1[node_ind]
SET_POS_REG(1, tmp_xyz, status)
mid_nods
ENDFOR
tmp_xyz = pth1[last_node]
SET_POS_REG(1, tmp_xyz, status)
end_nod
ELSE
FORCE_SPMENU(TP_PANEL,SPI_TPUSER,1)
WRITE (’ Equipment is not READY’,CR)
WRITE (’ Set equipment to READY MODE’,CR)
WRITE (’ before executing this program.’,CR)
WRITE (’ SET DOUT[’,EQIP_READY,’] = TRUE ’,CR)
ABORT
ENDIF
WRITE TPFUNC
(CHR(128),CHR(137))
-- Home Cursor and Clear to End-of-line
-- This will remove the ABORT displayed
-- above F1.
END DOUT_EX
B.2
COPYING PATH VARIABLES
This example shows the different ways of copying and appending PATH variables. The PATH Data
Type can be copied from one to another only with hard coded path variable names. However, user
defined paths can be copied from one to another. The path variable names can be determined during
execution of the program.
Copy Path Variables Program - Overview
------------------------------------------------------------------------------
----
Detail about CPY_PTH.Kl
------------------------------------------------------------------------------
---- Elements of KAREL Language Covered:
In Section:
----
Action:
----
Clauses:
B-18
MARRC75KR07091E Rev D
B. KAREL EXAMPLE PROGRAMS
----
FROM
Sec 3-A
----
IN DRAM
Sec 2
----
WHEN
Sec 4-A
----
Conditions:
----
Data types:
----
ARRAY OF STRING
Sec 2
----
BOOLEAN
Sec 2; 3-C
----
FILE
Sec 2
----
INTEGER
Sec 2; 3-B,C
----
PATH
Sec 2
----
STRING
Sec 2; 3-B
----
STRUCTURE...ENDSTRUCTURE
Sec 2
----
USER DEFINED PATH
Sec 2
----
XYZWPR
Sec 2
----
Directives:
----
ALPHABETIZE
Sec 1
----
COMMENT
Sec 1
----
CMOSVARS
Sec 1
----
CRTDEVICE
Sec 1
----
INCLUDE
Sec 2
Copy Path Variables Program - Overview and Declaration Section
----
Built-in Functions & Procedures:
----
APPEND_NODE
Sec
4-D
----
BYNAME
Sec
4-E
----
CALL_PROG
Sec
4-B
----
COPY_PATH
Sec
3-C; 4-D
----
CNV_INT_STR
Sec
4-E
----
CREATE_VAR
Sec
4-E
----
CURPOS
Sec
4-B
----
DELETE_NODE
Sec
4-C
----
LOAD
Sec
4-B
----
PATH_LEN
Sec
4-C,E
----
PROG_LIST
Sec
4-B
----
READ_KB
Sec
3-B
----
SET_CURSOR
Sec
4-E
----
SET_FILE_ATR
Sec
4-A
----
SET_POS_REG
Sec
4-D
----
SET_VAR
Sec
4-B
----
SUB_STR
Sec
4-E
----
VAR_LIST
Sec
4-E
----
Statements:
----
ABORT
Sec
4-C,E
----
CLOSE FILE
Sec
4-E
----
FOR
ENDFOR
Sec
3-C; 4-C,D,E
B-19
B. KAREL EXAMPLE PROGRAMS
MARRC75KR07091E Rev D
----
IF...THEN...ENDIF
Sec 3-B,C; 4-B,C,D,E
----
OPEN FILE
Sec 4-A
----
REPEAT...UNTIL
Sec 3-B; 4-E
----
ROUTINE
Sec 3
----
WRITE
Sec 3-B,C; 4-A,B,C,E
----
USING...ENDUSING
Sec 4-D
----
Reserve Word:
----
BEGIN
Sec 3-B,C; 4
----
END
Sec 3-B,C; 4-E
----
PROGRAM
Sec 1
----
TYPE
Sec 2
----
VAR
Sec 2
----
Predefined File Names:
----
CRTFUNC
Sec 3-B
----
CRTPROMPT
Sec 3-B,C
------------------------------------------------------------------------------
----
Section 1: Program and Environment Declaration
------------------------------------------------------------------------------
PROGRAM CPY_PTH
%ALPHABETIZE
%COMMENT = ’COPY PATH’
-- Display information by default to
CRT/KB
%CRTDEVICE
%CMOSVARS
-- Use CMOS RAM to store all static variables,
-- except those specified with IN DRAM
Copy Path Variables Program - Declaration Section
------------------------------------------------------------------------------
----
Section 2: Constant, Variable and Type Declarations
------------------------------------------------------------------------------
CONST
SUCCESS
= 0 -- The value returned from all built-ins when successful
TYPE
node_struc
= STRUCTURE
-- Create a user defined node structure
posn_dat
:XYZWPR
ENDSTRUCTURE
user_path
= PATH nodedata = node_struc
--Create a user defined path
VAR
pth1,
pth2,
pth3
pth4
:PATH
-- These are system defined PATHs
upth1,
upth2,
upth3,
B-20
MARRC75KR07091E Rev D
B. KAREL EXAMPLE PROGRAMS
upth4
:user_path
-- These are user defined PATHs
p1_len,
p2_len,
status, node_ind,
total_node
:INTEGER
F1_press,
F2_press
:BOOLEAN
src_num,
des_num
:INTEGER
dummy_str,
src_var,
des_var
:STRING[20]
cur_name
:STRING[12]
entry
:INTEGER
var_type
:INTEGER
mem_loc
:INTEGER
Copy Path Variables Program - Storing Variables in Memory
-- Store the following variables in
DRAM, which
is
temporary
memory
indx
IN DRAM
:INTEGER
prog_name IN DRAM
:STRING[10]
prog_type IN DRAM
:INTEGER
n_match
IN DRAM
:INTEGER
n_skip
IN DRAM
:INTEGER
format
IN DRAM
:INTEGER
ary_nam
IN DRAM
:ARRAY[5] OF
STRING[20]
prog_indx IN DRAM
:INTEGER
do_copy
IN DRAM
:BOOLEAN
crt_kb
IN DRAM
:FILE
%INCLUDE KLEVKMSK
-- system supplied file: definition of
KC_FUNC_KEY
%INCLUDE KLEVKEYS
-- system supplied file: definition of
KY_F1 & KY_F2
Copy Path Variables Program - Monitor User Response
------------------------------------------------------------------------------
----
Section 3: Routine Declaration
------------------------------------------------------------------------------
------------------------------------------------------------------------------
----
Section 3-A: CRT_CLS Declaration
------------------------------------------------------------------------------
ROUTINE CRT_CLS FROM rout_ex -- include this routine from the file rout_ex.kl
------------------------------------------------------------------------------
---- Section 3-B: YES_NO Declaration
----
LABEL the F1 key as YES and F2 key as NO, ask for user
B-21

 

 

 

 

 

 

 

Content      ..     21      22      23      24     ..