160
VERSION 2.1 ADVANCED AXCESS PROGRAMMING AXCESS Language Tutorial

Axcess Language Tutorial

  • Upload
    nwagner

  • View
    215

  • Download
    1

Embed Size (px)

DESCRIPTION

Learn to program in the Axcess Language. The AXCESS system is a microprocessor-based control system capable of controllingthe simple to the most complex devices. Its basic function is to give youcomplete control of every device in any system.

Citation preview

Page 1: Axcess Language Tutorial

VERSION 2.1

ADVANCEDAXCESSPROGRAMMING

AXCESS Language Tutorial

Page 2: Axcess Language Tutorial

Version 2.1March, 1993

Copyright

© AMX Corporation, 1993. All rights reserved. No part of this publication may be reproduced, transcribed,stored in a retrieval system, or translated into any language in any form by any means without the writtenpermission of AMX Corporation.

Trademarks

IBM is a trademark of International Business Machines Corporation. MS-DOS is a trademark of Microsoft Cor-poration. Phoenix is a trademark of Phoenix Terminal Blocks Inc.

Credits

Written by David Hooker and Erik Engstrom.Illustrated by Erik Engstrom and David Hooker.Layout and design by Erik Engstrom.Cover designs by Don Crum.

Special thanks to all at AMX for invaluable input and support.

Printed in USA.

For additional technical support, feel free to call us.

AMX Corporation11995 Forestgate DriveDallas, Texas 75243(214) 644-3048(800) 222-0193(214) 907-2053 FAX

Page 3: Axcess Language Tutorial

Table of Contents iii

Table of Contents

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix

Unit 1: Using the AXCESS Program

Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Introduction 3

Necessary equipment 3

Installing AXCESS onto a hard drive 3

Video monitors 4

Connecting the system 4

Device numbers 5

Blinking light status 6

Using the Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7The menu environment 7

The File menu 7

The AX File menu 9

The Diagnostics menu 12

The Communications menu 13

The Help menu 15

The Text Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17Editor basics 17

Blocking 18

Search and replace 18

The Push window 19

Simulated button press 20

Compilation errors 20

Page 4: Axcess Language Tutorial

Table of Contentsiv

Unit 2: Language Basics

Simply the Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23Introduction 23

Format of the language 23

Statements and compound statements 24

Comments within the program 25

Identifiers 26

Reserved words 26

Special characters and operators 27

The Definition Sections . . . . . . . . . . . . . . . . . . . . . . . . 29Starting a new program 29

The device-channel concept 29

Defining devices 30

Defining constants 31

Defining variables 32

Startup code 33

Mainline 33

Using Input and Output . . . . . . . . . . . . . . . . . . . . . . . . 35Controlling something over there 35

All about the channel 35

Changing the state of a channel 37

Direct assignment 39

Putting input and output together 39

Channel Characteristics . . . . . . . . . . . . . . . . . . . . . . . . 41The parts of an output channel 41

Defining latching 42

Mutually exclusive 43

Defining momentary mutually exclusive 43

Defining mutually exclusive latching 44

Defining mutually exclusive toggling 44

Putting it all to work 45

Programming feedback 46

Grouping feedback statements 47

Your First Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49The program and the panel 49

Page 5: Axcess Language Tutorial

Table of Contents v

Unit 3: Conditionals, Loops, and Waits

If and the Boolean Expressions . . . . . . . . . . . . . . . . . 57Introduction 57

Boolean expressions 58

The If statement 58

The If...Else set of statements 58

The If...Else If set of statements 59

Nesting 59

The Select...Active statement 60

Trying it out 61

“Mutually exclusive variable” method 61

The “variable assignment” method 63

More Boolean operators 65

Reading a Boolean expression table 65

Waits and Timer Keywords . . . . . . . . . . . . . . . . . . . . . 67Controlling time within AXCESS 67

The Wait list 67

Multiple Waits 69

Special uses of Wait 70

Naming Waits 71

Cancelling, pausing, and restarting Waits 71

The Wait_Until keyword 72

Misusing Wait_Until 72

Naming and removing Wait_Untils 73

The timer keywords 73

Using Time, Date, and Day 74

The While Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . 77While 77

Long_While 78

Medium_While 78

Page 6: Axcess Language Tutorial

Table of Contentsvi

Unit 4: Levels

Creating Levels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81Introduction 81

What is a level? 81

Creating levels 82

Using Levels. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85Reading levels 85

Making a preset 85

Using bar graphs 86

Connecting levels 86

Unit 5: Arrays, Strings, and Buffers

Arrays and Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91Introduction 91

Defining arrays 91

Accessing and storing array values 92

Strings 94

The string expression 94

Arrays as strings 95

String lengths 96

Sending strings and arrays 98

ASCII codes 99

Integer arrays 100

Working with Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . 101Grouping data 101

Conversion keywords 101

Array manipulation keywords 103

Finding strings 104

Removing strings 104

Uppercase vs. lowercase 105

Setting uppercase and lowercase 106

Using Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107Communicating to the outside world 107

Receiving strings 107

Creating buffers 107

Storing characters 108

Retrieving characters 108

Clearing a buffer 110

Page 7: Axcess Language Tutorial

Table of Contents vii

Two-Dimensional Arrays . . . . . . . . . . . . . . . . . . . . . . 111Powerful grouping 111

The anatomy of the two-dimensional array 111

Storing values 112

Retrieving values 113

Unit 6: Advanced AXCESS Programming

Using Subroutines . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117Introduction 117

Subroutines 117

Defining a subroutine 117

Calling your subroutines 118

Sample program 118

Local Variables and Parameters . . . . . . . . . . . . . . . . 123More power for your subroutines 123

Local variables 123

Parameters 124

Passing values back to the caller 125

Include Files and System_Calls . . . . . . . . . . . . . . . . . 127Managing large programs 127

Include files 127

System_Calls and library files 129

Factory System_Calls 130

The instance number and name mangling 131

Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143

Page 8: Axcess Language Tutorial
Page 9: Axcess Language Tutorial

Introduction to AXCESS ix

Introduction to AXCESS

What is AXCESS?

The AXCESS system is a microprocessor-based control system capable of con-trolling the simple to the most complex devices. Its basic function is to give youcomplete control of every device in any system. Through a flexible language,AXCESS can be programmed to handle almost any task. AXCESS can automati-cally dim lights, increase volume controls to preset levels, turn on video projec-tors, and much more.

An IBM-compatible computer is required to program the AXCESS system. Notmuch memory is needed; even the more complex AXCESS programs can be han-dled by an average laptop computer. Once the system is programmed, the com-puter is only needed for diagnostics tests and any loading or saving of programs.

The AXCESS language

We designed the AXCESS programming language to be user-friendly. Althoughthere are over 90 commands, many are self-explanatory and take little time tomaster. If you accidentally make a mistake in your programming, AXCESS findsthe error and reports it to you. As a result, both minor and major changes in pro-gramming can be done quickly and easily by you in the field.

AXCESS is not some strange new language that only brilliant engineers candecipher. On the contrary, anyone with an average knowledge of computers andpresentation devices should be able to understand this manual without any dif-ficulty. An understanding of DOS is not even necessary, except for a few com-mands involved in the initial installation of AXCESS.

The AXCESS Language Tutorial

This tutorial takes the approach of teaching the language while developingreal-world AXCESS system programs. You will start with the basic commandsand simple control scenarios, and progress on to more complex programming asyou discover new programming functions and techniques.

Page 10: Axcess Language Tutorial
Page 11: Axcess Language Tutorial

UNIT 1

USING THEAXCESSPROGRAM

AXCESS Language Tutorial

Page 12: Axcess Language Tutorial
Page 13: Axcess Language Tutorial

Unit 1: Using the AXCESS Program 3

Getting Started

Introduction

This unit guides you through the simple installation of the AXCESS system forboth the software and the hardware. In addition, the programming environmentis explained, from the main menus to editing techniques.

Necessary equipment

In order to operate the AXCESS system, you need an IBM-compatible computer,the AXCESS software, the CardFrame, the Master Card, and an appropriate cable.The computer should have a minimum of 512K of memory. In addition, it mustbe functioning on DOS 2.0 or higher.

AMX provides the necessary software, either on one 5.25-inch disk or one 3.5-inch disk. The disk contains a number of files: the editor/compiler program,support files, pre-written “block” files, code library files, and documentationfiles. To read more information about what is on the disk, insert the disk intoyour floppy disk drive, change to that drive (either A: or B:), and type README atthe DOS prompt. Up-to-date information about the contents of the disk alongwith any additional information will be displayed for you to read.

The AXCESS PC program can be run from the distribution diskette. To startAXCESS, change to the disk drive containing the floppy disk. Then simply typeAXCESS at the DOS prompt to start the program.

Installing AXCESS onto a hard drive

To install AXCESS onto the hard drive of your computer, change to the floppydrive containing the distribution diskette. Then type INSTALL followed by the di-rectory path on the hard drive to which you wish to install AXCESS. For example:

A:\> INSTALL C:\AXCESS

The installation program copies all of the necessary files into the specified di-rectory, in this case C:\AXCESS. If the directory does not exist, the installationprogram will create it. The AXCESS system can now be enabled by typing the fol-lowing command:

C H A P T E R

1

Getting Started

Page 14: Axcess Language Tutorial

4 Unit 1: Using the AXCESS Program

C:\AXCESS> AXCESS

For more help on the commands used in this section, see your DOS manual.

Video monitors

The AXCESS system automatically detects color or monochrome monitors. How-ever, for a monitor that “reports” being a CGA monitor but actually has no color(such as LCD or plasma-type monitors) you must force the AXCESS system intothe monochrome mode. To do this, enable AXCESS by typing the following:

C:\AXCESS> AXCESS/B

Connecting the system

At this point, the AXCESS system should be loaded into the computer. The nextstep is to supply power to the CardFrame itself. Plug in the power supply fromthe power outlet to the AXCESS system. The green two-pin Phoenix connectorshould be plugged into the lower right corner of the back of the CardFrame.

Next, the cable must be connected from the communications port of the com-puter to the nine-pin connector on the Master Card. Note: if the Master Card isin slot MC1, the nine-pin connector on the back of the CardFrame may be used.

Getting Started

Solving communications problems

Cause

The baud rate of the AXCESS system is different than that of the Master Card.

The AXCESS system baud rate can be found with the “Configure...” option in the Communications menu, and an explanation of setting the Master Card baud rate is in the AXCESS Installation Guide. Set both to the same setting.

Solution

The communications port num- ber of the AXCESS system is different than that of the com- munications port in which the Master Card cable is plugged.

The AXCESS system com port number can be found with the “Configure...” option in the Communications menu. Make sure it matches the correct Master Card communications port.

The communications settings of the AXCESS system is different than that of the Master Card.

The AXCESS system communications settings can be found with the “Configure...” option in the Communi- cations menu, and an explanation of changing these settings for the Master Card is in the AXCESS Installation Guide. Both should be set to eight data bits, no parity, and one stop bit.

The connecting cable is not made by AMX.

Inspect the cable’s pinout. The cable connection chart in the AXCESS Installation Guide should help you determine the solution.

Figure 1-1

What to do when AXCESS is

not responding properly.

Page 15: Axcess Language Tutorial

Unit 1: Using the AXCESS Program 5Getting Started

Recommended device numbers

CardFrame #

1 1 1

2 17

3 33

Device # DIP Switch Settings

0 0 0 0 0 0 0

1 2 3 4 5 6 7 8

1 0 0 0 1 0 0 0

1 0 0 0 0 1 0 0

1 0 0 0 1 1 0 0

1 0 0 0 0 0 1 0

1 0 0 0 1 0 1 0

1 0 0 0 0 1 1 0

1 0 0 0 1 1 1 0

4 49

5 65

6 81

7 97

8 113

Figure 1-2

Recommended device

numbers for the card in slot

1 of each CardFrame within

the AXCESS control system.

In the bottom left corner of the computer screen is the “push window,” whichdisplays the status of your AXCESS connections. It should now display the mes-sage “AX Present.” If it says “AX Not Responding,” there is a communicationsproblem. See Figure 1-1 for help. (More uses of the push window are describedlater in this unit.)

Device numbers

Each device on AXlink must have a unique device number. The device number ofa card is set by the slot number and the DIP switch setting on the Server Card.The DIP switch on the Server Card sets the address of the card in slot 1. The cardin slot 2 is the Server Card’s DIP switch setting plus 1. As follows, the card in slot3 is the Server Card’s DIP switch setting plus 2. This will continue until slot 16.

For example, suppose the DIP switch on the Server Card is 17. The devicenumber of card slot 1 will also be 17. Card slot 2’s device number will be 18(17+1), card slot 3’s device number will be 19 (17+2), and so on. Card slot 16’sdevice number will be 32 (17+15).

Each AXlink device—except the AMX Touch Panel—has its own DIP switch toselect its device number. The Touch Panel has a keypad to enter its device num-ber on the protected setup page.

At AMX, we have general rules for setting device numbers. For systems up toeight CardFrames, we recommend the device numbers in Figure 1-2. Thesenumbers are only for the card in slot 1 of each CardFrame; for each consecutivedevice, add one to the appropriate number.

We also recommend that all panels, infrared receivers, and radio frequencyreceivers start on device number 128 and increase with each device.

Page 16: Axcess Language Tutorial

6 Unit 1: Using the AXCESS Program

Blinking light status

As you may have noticed, there is a green LED light on the front of the MasterCard. Once the Master Card is plugged in and power is supplied to theCardFrame, this LED turns on. There is a series of three different flash patternsthat tells you the current status of the AXCESS system.

• One blink per second: the system is operating normally.

• Two blinks per second: the devices specified within the program do notmatch the devices found on AXlink. For a full description, check the ”Com-pare current devices...” option in the Diagnostics menu (this is explained inthe next chapter).

• Three blinks per second: there is an AXlink communications error, probablydue to a wiring problem. Check all the AXCESS wiring, making sure thateach cable is firmly connected.

When the green LED is on but not flashing, there is no AXlink activity. Thisusually indicates that the Master Card has no AXCESS program loaded.

Getting Started

Page 17: Axcess Language Tutorial

Unit 1: Using the AXCESS Program 7

C H A P T E R

2

Using the Menus

The menu environment

Programming AXCESS requires full knowledge of the menus that appear at thetop of the computer screen. This chapter explains the full spectrum of optionsavailable to you in each of the five main menus.

To select an option in any of the menus, press the menu’s function key anduse the cursor keys to move up and down. Highlight the needed option andpress <Enter> to select it. To exit out of the menu and return to the text editor,press the <Esc> key.

The File menu

Press <F1> to enter this menu. The File menu allows you to open, create, save, orprint an AXCESS program file or include file. (Include files will be discussed laterin the manual.) This menu also has commands for compiling your AXCESS pro-gram, changing the current directory, and viewing the current version informa-tion. The following is an in-depth look at each option in this menu.

Open..

This option gives you a list of existing AXCESS program files that are in the cur-rent directory (files with the DOS extension “AXS”). Simply move the cursor downwith the arrow keys and select the file you would like to open by pressing <En-ter>. You can find your file more quickly by pressing the first letter of your file-name; your cursor will appear before the files whose names begin with that sameletter. Once you are within the text editor, changes can be made to your program.

Listed below are special functions available with the “Open..” option. Theyappear at the bottom of the screen when you are in this menu.

• <F1> File information

• <F2> Delete file

• <F3> Rename file

• <F9> Open a non-program file

When <F1> is pressed, some basic information about the file you highlighted isdisplayed. This information includes the filename, date and time the file was last

Using the Menus

Open.. ctrl-OOpen include..New..Save ctrl-SCompile ctrl-CPrint..Change dir...Version...Exit ctrl-X

File

Page 18: Axcess Language Tutorial

8 Unit 1: Using the AXCESS Program

modified, and the file size. <F2> allows you to delete an unwanted file. Simplyhighlight a file, press <F2>, and then AXCESS will ask you if you are absolutelysure about deleting the file. <F3> lets you change the name of a file you high-light. <F9> allows you to bring in any text file to the editor. It does not matter ifthe file is not related to AXCESS; you can use the program as a simple text editor.

Pressing <Ctrl-O> also activates the “Open..” command.

Open include..

This option is identical to the “Open..” command, except the program lists theavailable include files that you can edit. An include file is an AXCESS programfile which actually contains a portion of code used by another AXCESS programfile. Include files have the DOS extension “AXI.”

New..

This option creates a basic new file for you. AXCESS loads the file NEW.OVL

(which must be present in the current directory), inserting a few headings andcomments to help you in your programming. The editor is then ready for you tobegin a new program.

Save

When you select this option, AXCESS asks you to give your file a name. If the filealready has a name, press the <Enter> key to overwrite the old file. To save thefile under a new name, type in a different name and press <Enter>.

To save a new file as an include file, instead of pressing <Enter> after typingin the filename, press the <F1> key.

Normally in DOS, filenames can consist of a maximum of eight characters (notincluding the extension). However, AXCESS allows a maximum of 57 characters,and spaces are acceptable. This gives you greater flexibility for your file descrip-tion. AXCESS converts your filename into a unique name that the computer canrecognize, and stores the entire name on the first line of the file with the key-word Program_Name.

It is highly recommended to save often and keep a backup copy of all programs.Pressing <Ctrl-S> also activates the “Save..” command.

Compile

This option compiles the source code into executable code. Source code is an-other name for the AXCESS program that you type and edit; executable code iswhat the AXCESS system can understand. By compiling your program, thesource code is translated into executable code. After compiling, the file is storedin the computer’s memory. (To download this code to the Master Card, use the“Send...” option in the AX File menu.)

Using the Menus

Source code

The AXCESS program that

you type and edit.

Executable code

A translated version of the

source code that the AXCESS

system can understand.

Page 19: Axcess Language Tutorial

Unit 1: Using the AXCESS Program 9

This feature also tells you if the AXCESS system is unable to compile your pro-gram. If this is the case, a list of errors are displayed. The cursor appears at thefirst error. (For information about correcting these errors, see the next chapter.)

Pressing <Ctrl-C> also activates the “Compile” command.

Print..

This option sends the source code to the printer if one is available. If this com-mand cannot operate the printer, use the “Configure...” option in the Communi-cations menu to check the LPT setting. This setting should be the same as the LPT

port number in which the printer cable is connected.

Change dir...

This menu option allows you to change the working directory from where you willload and save your files. Selecting this option displays a window on the screenwhere you can edit the DOS path to a different directory. After a new directorypath is entered, AXCESS rebuilds its lists of available files for the new directory.

Version...

Selecting this option displays a window showing the current version of theAXCESS PC program you are running, plus information on the amount ofmemory available. Simply press any key to go back to the editor.

Exit

This option lets you exit to DOS. AXCESS asks if you want to save the current fileif any changes have not been previously saved.

Pressing <Ctrl-X> also activates the “Exit” command.

The AX File menu

Press <F2> to enter this menu. The AX File menu helps you transfer both the ex-ecutable code and the source code of a file to the Master Card. In addition, youcan retrieve source code from the Master Card.

Retrieve

This option retrieves the source code from the Master Card, if possible. Thereare two reasons why the source code was not saved in the Master Card:

• There was not enough memory in the Master Card to store the source code.

• The “Source-send” option was toggled off. For more information, see the“Source-send” option explained a little later in this chapter.

Using the Menus

RetrieveSend... ctrl-pSource-send ONVerifyCreate S19 file...Send w/password...Options...

AX File

Page 20: Axcess Language Tutorial

10 Unit 1: Using the AXCESS Program

Always save the source code on either the hard drive or a floppy disk. Do notrely on the Master Card to keep all of the source code in memory.

Send...

This option sends the current executable code to the Master Card. If possible, thesource code is also stored in Master Card memory. If there is not enough roomin the Master Card for the program, AXCESS will stop downloading and give youa warning. When this happens, try to send the program again, but without send-ing the source code.

If you have made changes to your source code, AXCESS asks if you want torecompile your program. If you do not accept this option, the file sent to theMaster Card is not the same as the file in the text editor, but instead the lastcompiled code.

Pressing <Ctrl-P> also activates the “Send...” command.

Source-send

This option toggles on and off. The current status is listed at the right of the“Source-send” option.

With “Source-send” on, AXCESS will attempt to download both the executablecode and the source code to the Master Card when you select the “Send...” op-tion, memory permitting. This allows the “Retrieve” option to re-load the sourcecode from the Master Card. If “Source-send” is off, AXCESS downloads only theexecutable code, which cannot be retrieved from the Master Card.

It is a good idea to leave this option turned on. The only reasons to turn the“Source-send” option off are to speed up downloading time during programdevelopment, or because you know the source code is too large to send.

Verify

As a safeguard, this option checks to see if your compiled program is the exactsame as that in the Master Card. It is possible that the Master Card does nothave the latest compiled version of your program. If your compiled programfails this test, simply recompile the program and send it to the Master Card.

Create S19 file...

This menu selection is used to create a Motorola S19 format file for use in storingthe program into an EPROM. This is only used to make PC+ Program Carrierchips, which are now obsolete. You will probably never need to use this menuoption, but it is mentioned here for information purposes.

Using the Menus

BUZZWORD

Downloading is the sending

of data from computer to a

device (such as a Master

Card). Uploading is the

opposite: the computer is

the receiver.

Page 21: Axcess Language Tutorial

Unit 1: Using the AXCESS Program 11

Send w/password...

This menu command is identical to the “Send...” command, but with one addi-tion: it allows the specification of a password which will be needed to retrievethe program in the future. This password can only be numerical; no alphabeticcharacters are allowed in the password.

When a password-protected program is retrieved from a Master Card, AXCESS

will prompt the user for the password before it decompresses and displays theprogram in the editor. This provides a means of storing the source code in theMaster Card so that only authorized persons can retrieve it. If the password isforgotten, however, there will be no way to retrieve the source code from theMaster Card, so do not forget it!

Options...

This menu command brings up a window (Figure 1-3) where the user can setvarious options concerning compile-time warning and error messages and othercompiler options. The options are divided into compiler messages and compileroptions. Here is what each selection in the compiler messages section means:

• Parameter mismatch: turning this option on enables errors when a param-eter of the wrong type is passed to an AXCESS function

• Assignment of unlike types: turning this option on enables warnings when avariable or constant of one type is assigned to a variable of a different type

• Variable is not used: turning this option on enables warnings when avariable declared anywhere in the program is not actually used

• DEFINE_CALL is not used: turning this option on enables warnings when aDefine_Call subroutine declared in the program is not actually used

The compiler options section has only one option to turn on or off: SeparateDEFINE_CALL list. Compiling with this option on causes all Define_Call subrou-

Using the Menus

Figure 1-3

Screen produced by the

“Options...” selection in the

AX File menu.

OPTION Compiler messages[ ] Parameter mismatch[ ] Assignment of unlike types[ ] Variable is not used[ ] DEFINE_CALL is not used

Compiler Options[ ] Separate DEFINE_CALL list

to toggle ESC when done

Page 22: Axcess Language Tutorial

12 Unit 1: Using the AXCESS ProgramUsing the Menus

tines to be stored in a separate section of the Master Card memory than theDefine_Program section. This effectively allows the code size of a program toreach 128K (64K for the Define_Calls and 64K for the Define_Program section).When this option is turned on, the dialog box asks for a size of the Define_Call

memory segment.

The Diagnostics menu

Press <F3> to enter this menu. The Diagnostics menu allows you to view andcompare the devices on AXlink and the devices defined in the current program

stored in the Master Card.

Show current devices...

When this option is selected, AXCESS asks the Master Card for a list of all devicescurrently present on AXlink. The device number, device type, and device namein the program are displayed for each device. Pressing the <Enter> key updatesthe list. See Figure 1-4.

Compare current devices...

This option compares the devices defined in the current program in the MasterCard against the devices that actually are on AXlink. AXCESS lists the devicesthat are defined in the Define_Device section of the program but not on AXlink.Also, AXCESS lists the devices that are currently on AXlink but are undefined inthe program. After altering any devices, pressing the <Enter> key updates thislisting. See Figure 1-5.

Figure 1-4

Screen produced by the

“Show current devices”

option in the Diagnostics

menu.

Show current devices...Compare current devices...Show current versions...Watch variables...

Diagnostics

DEVICE DEVICE TYPE PROGRAM NAME------ ----------- ------------1 UNIVERSAL 8 RELAY CASS2 UNIVERSAL 8 RELAY LIGHTS3 IR/SERIAL DATA VCR4 VOLUME CONTROL VOLUME128 SOFTWIRE PANEL PANEL

These are the product type names that AMX gives the devices

These are the names of the devices assigned in the program

Page 23: Axcess Language Tutorial

Unit 1: Using the AXCESS Program 13Using the Menus

***** DEVICES PROGRAMMED BUT NOT PRESENT ****DEVICE DEVICE TYPE PROGRAM NAME------ ----------- ------------1 UNKNOWN CASS128 UNKNOWN PANEL

***** DEVICES NOT PROGRAMMED BUT PRESENT ****DEVICE DEVICE TYPE PROGRAM NAME------ ----------- ------------4 VOLUME CONTROL

These devices are not plugged into AXlink

This device is not defined in the program

Figure 1-5

Screen produced by the

“Compare Current De-

vices...” option in the

Diagnostics menu.

Show current versions...

When this option is selected, AXCESS displays a list of the devices present in thesystem, along with the firmware version of the device (if applicable).

Watch variables...

This item brings up the Variable Watch window. This window allows you toobserve the contents of selected variables while the program is running. See theAXCESS Programming Guide for details on how to use this feature.

The Communications menu

Press <F4> to enter this menu. The Communications menu lets you communi-cate directly to the Master Card. In addition, AXCESS can be configured to fitsome of your specifications, including the baud rate and the selection of commu-nications ports and printer ports.

Terminal emulator...

This option puts the AXCESS system into a dumb terminal mode. Whatever youtype on the screen exits through the communications port, and anything comingin from the communications port is displayed on your monitor. This mode isused to communicate directly to the Master Card, modems or other RS-232 de-vices, and also to debug RS-232 controlled devices. For more information, consultthe AXCESS Programming Guide for Master Card communication commands.

Pressing <Ctrl-T> also activates the “Terminal emulator...” command.

Configure...

This option lets you choose which communications port, baud rate, and printerport you need for the AXCESS system. Upon selecting this, a window appears list-

BUZZWORD

Firmware is the software that

resides in the EPROMs in

many of the AXCESS devices.

This software is what makes

these devices operate.

Terminal emulator... ctrl-tConfigure...Send file...Receive file...Pass thru...

Communications

Dumb terminal

A serial communications

device. Whatever you type

goes out the communica-

tions port, and whatever

comes in the port is

displayed on the screen.

Page 24: Axcess Language Tutorial

14 Unit 1: Using the AXCESS ProgramUsing the Menus

Figure 1-6

Screen produced by the

“Configure...” option in the

Communications menu.

ing the choices. Move the cursor with the arrow keys next to the item you needto change. Pressing <Enter> places a check mark next to that item. See Figure 1-6.

Send file...

This option is not the same as the “Send...” option in the AX File menu. Instead,it allows the transfer of files between two computers through a connecting serialcable or modem. Both computers must be running the AXCESS program in orderfor the transfer to be complete.

Receive file...

This option works in conjunction with the “Send file...” option. Once two com-puters are connected with a serial cable or modem, select “Send file...” on thecomputer that has the file to be sent. Select “Receive file...” on the other com-puter to initiate the transfer of data.

Pass thru...

This option allows you to pass data between two of the computer’s communica-tions ports. All data going in one port comes out the other, and vice versa. Im-mediately after you select this option, a window appears allowing you to selectthe two communications ports you wish to use. When you have done that,pressing <F10> establishes the pass-thru connection. A window on the screenwill show the number of characters of data being received by each port. Pressingthe <Esc> key quits the pass-thru.

CONFIGURE BAUD RATE 300 600 COM 1 1200 √ LPT 1 COM 2 2400 COM 3 4800√ COM 4 9600 LPT 2 19200 √ 38400

This changes the port to which your printer is connected

This changes the speed at which serial data exits the communications port

This changes the communications port through which serial data exits

Page 25: Axcess Language Tutorial

Unit 1: Using the AXCESS Program 15Using the Menus

The Help menu

Press <F6> to enter this menu. (In order for this menu to work, the file HELP.OVL

must be present in the current directory.) The Help menu can give you a briefdefinition of a specified keyword or command. This menu is self-explanatory inits instructions to select an option.

Help on HelpEditorKeywordsSample Program

Help

Page 26: Axcess Language Tutorial
Page 27: Axcess Language Tutorial

Unit 1: Using the AXCESS Program 17

C H A P T E R

3

The Text Editor

Editor basics

The AXCESS system offers you a simple text editor for manipulating text in yourprograms. Whenever a menu is not displayed on the screen, the editor is in ef-fect. Figure 1-7 lists the commands used within the editor.

Cursor movement around the screen is controlled by the arrow keys. (If youdo not have an extended keyboard, make sure the <NumLock> feature on thekeyboard is off so you can use the keypad instead.) <Home> brings you to thebeginning of the current line, and <End> puts you at the end of the currentline. Also, <Pg Up> takes you one screen of text up, and <Pg Dn> takes youone screen of text down. <Ctrl-Home> takes you to the very beginning of theprogram, and <Ctrl-End> takes you to the very end.

The Text Editor

Editing commands

Command

<Alt-C>

<Alt-D>

<Alt-F>

<Alt-G>

<Alt-I>

<Alt-L>

<Alt-M>

<Alt-N>

<Alt-O>

<Alt-P>

<Alt-R>

<Alt-S>

<Alt-U>

Copy block

Delete block

Find Push statement

Get block from disk

Insert Push statement

Mark block

Move block

Go to next error

Print block

Go to previous error

Search & replace text

Search for text

Unmark block

Function Command

<Alt-W>

<Alt-Z>

<Alt-minus>

<Alt-=>

<Ctrl-A>

<Ctrl-E>

<Ctrl-Home>

<Ctrl-End>

<Home>

<End>

<Pg Up>

<Pg Dn>

<Ins>

Write block to disk

Delete to end of line

Delete current line

Undo last command

Simulate pressing button

Toggle error window on/off

Go to beginning of program

Go to end of program

Go to beginning of current line

Go to end of current line

Go up one screen of text

Go down one screen of text

Toggle insert/overwrite mode

Function

Figure 1-7

A list of editing commands

and their functions.

Page 28: Axcess Language Tutorial

18 Unit 1: Using the AXCESS Program

Pressing the <Ins> key toggles the insert/overwrite mode. If you are in theInsert mode, every character you type is inserted into the current cursor posi-tion. In the Overwrite mode, any character under the cursor is overwritten withthe new one.

If you would like to delete an entire line in the program, type <Alt-minussign>. If you accidentally delete the wrong line, simply press <Alt-=> to undothe last command.

There is a status line near the bottom of the screen when you are in the editor.This tells you which line the cursor is currently on, the amount of availablememory, and the current insert/overwrite mode.

Blocking

This feature allows you to treat one section of text as a complete block. Thisblock as a whole can be copied, moved, or deleted.

To mark a block, position the cursor at the beginning of the section of text.Type <Alt-L>, and this line of text will be highlighted. Move down to the end ofthe section and type <Alt-L> again. All the text between the first <Alt-L> andthe last will now be highlighted. To shorten or lengthen this text block, positionthe cursor at the new ending for the section and type <Alt-L>.

Now that a block is highlighted, it can be manipulated. To copy the block,move the cursor to the desired place for the copied text and type <Alt-C>. Theblock is copied into the specified place. In order to move the block, move thecursor again to the desired place for the text and type <Alt-M>. The block disap-pears from its previous position and is inserted into the new specified place. Ifyou would like to delete the entire block, type <Alt-D> and the block is erased.

Blocks can also be saved to a disk and then retrieved. To write a block to disk,type <Alt-W> and AXCESS will ask you for a filename. Even though the block issaved to disk, it still remains in your current program. To retrieve the block fromdisk, position the cursor in the place where you would like to insert the newtext. Type <Alt-G> and supply AXCESS with the block’s filename. The new blockis inserted into your program where the cursor appears.

Once you are finished manipulating a block, it must be unmarked by typing<Alt-U>. The block returns to a normal background color, and you can resumeediting.

Search and replace

The AXCESS system allows you to search for a particular line or fragment of text,such as “cassette” or “PROJ.” This is useful when you would like to view all ref-erences to a certain device, such as “VHS.” Move the cursor to the line where youwant the searching to begin and type <Alt-S>. AXCESS asks you for the line of

NOTE

A number of pre-written

blocks are included on the

AXCESS distribution diskette.

The Text Editor

Page 29: Axcess Language Tutorial

Unit 1: Using the AXCESS Program 19

text you would like to find. The search function is not case sensitive. This meansthat an entry of “CASS” will return possible references of “CASS” and “cass2,”and even “Cassette.”

If the fragment or word is found, the current cursor position is set at the be-ginning of the first line found. Type <Alt-S> again to go to the next line contain-ing the fragment or word.

If you would like to replace text automatically with a new fragment or line,use the search and replace function. Do the same positioning as the search com-mand, but type <Alt-R>. AXCESS asks you for the text you are searching for, aswell as the text that will replace it. Be careful with this function. If you try to re-place all references of “cass” with “CD,” “cassette” would become “CDette.” (The“cass” of “cassette” was replaced with “CD,” thus creating the strange newword.) As a safety precaution, AXCESS asks if you would like to replace the lineor fragment, case by case.

The Push window

This feature allows you to find the Push statement of an existing button or toinsert the Push statement of a new button into your program. For more informa-tion on the Push statement, see Chapter 6.

In the bottom left corner of the screen, there is a small window (colored ma-genta on color monitors). This Push window displays the Push statement of thelast button pressed in the AXCESS system. If AXCESS has just been powered upand no buttons have been pressed, the window displays “AX Present.” If theMaster Card is not connected or communicating properly, the window displays“AX Not Responding.”

For example, an AMX Touch Panel is defined as TOUCH_PANEL in theDefine_Device section of the program (for more information, see Chapter 5).When button 2 on the Touch Panel on AXlink is pressed, the Push window dis-plays the following:

PUSH[TOUCH_PANEL,2]

In order to find this Push statement in your program, type <Alt-F> when thestatement is in the Push window. The cursor is placed on the line containing theexact statement. If there is not a Push statement in the program that matches thetext in the Push window, the computer responds with a beep.

You can also insert the displayed Push statement into the program; this is es-pecially useful when a button is not yet programmed. To add a new button intothe program, press the button; its Push statement now appears in the Push win-

The Text Editor

Case sensitive

Uppercase and lowercase

values are not evaluated the

same.

Push window

A window on the bottom left

of the AXCESS program that

displays the Push statement

of the last button pressed in

the AXCESS system.

Page 30: Axcess Language Tutorial

20 Unit 1: Using the AXCESS Program

dow. Position the cursor where the statement should be inserted and type <Alt-I>; the Push statement will be inserted into your program.

If this button already appears in the program, the computer beeps and takesthe cursor to the existing Push statement. This function does not allow you toinsert the same Push statement twice—you must do this manually.

Simulated button press

There is a way to operate a button without actually pressing the button on thepanel. Simply position your cursor next to a Push statement in the program andtype <Ctrl-A>. The system thinks that the button on the corresponding panel isbeing pressed. Its function continues to operate as long as you hold down the<Ctrl> key. Also, the push window displays the Push statement.

Compilation errors

After compiling a program (see the previous chapter for the “Compile” optionin the File menu), a list of errors and/or warnings may appear in a window atthe bottom of the screen. The cursor is automatically placed at the first of thesein the file, and the type of error or warning is highlighted in the window. See theAXCESS Programming Guide for more details on warnings and errors.

Once you finish correcting the mistake, you can go to the next error by typing<Alt-N>. The cursor appears at the next error. To go back to previous mistakes,type <Alt-P>. The cursor will move to the appropriate place.

After the first error is corrected, it is a good idea to recompile your program.That one error could be causing many more down the line. For example, if youforgot to define the device VHS2 earlier in the file, every line that references VHS2

is considered wrong. If you define VHS2 in the appropriate section, all the otherlines are now correct. When the program is recompiled, those errors are re-paired.

You might want to have more space on the screen, especially if there is a largenumber of errors in a particular section. To remove the error window, press<Ctrl-E>. This command toggles the error window on and off, so press <Ctrl-E>to get the window back on the screen.

The Text Editor

Page 31: Axcess Language Tutorial

UNIT 2

LANGUAGEBASICS

AXCESS Language Tutorial

Page 32: Axcess Language Tutorial
Page 33: Axcess Language Tutorial

23Unit 2: Language Basics

C H A P T E R

4

Simply the Basics

Simply the Basics

Introduction

This unit will help you start writing AXCESS programs. By the end of this unityou should be familiar with several concepts: the basic ground rules for writingAXCESS programs, the device-channel concept, the different sections that makeup an AXCESS program, how AXCESS executes a program, basic input and outputfunctions, and simple feedback. As you progress through the chapters you willdevelop a simple AXCESS program containing these basic features, and you willbuild on this program in later units.

Format of the language

The AXCESS language is in a free format, meaning that the source code is indepen-dent of tabs and carriage returns. Because of this, it is advised to use a consistentmethod of code placement in order to make the code more readable. In thismanual, an “outline” format is used; that is, each subsection of a section isslightly indented. For example:

IF (X = 1){

PUSH[PANEL,1]{

Y = 2Z = 3

}}

However, the program section will be executed in the same manner even if itlooks like this:

IF(X=1) {PUSH[PANEL,1] {Y=2 Z=3}}

All the elements are in the correct places, but the spacing is different. Usewhatever method is easiest for you to type and understand.

Free format

A characteristic of the

AXCESS language that allows

the source code to be

independent of tabs and

carriage returns.

Page 34: Axcess Language Tutorial

Unit 2: Language Basics24

Statements and compound statements

During programming, most of the keywords and operators require a completestatement. A keyword is a word or series of words that signifies the operation forAXCESS to execute. That keyword and all its parameters form the statement. Forexample, the keyword to turn a channel on is merely On. However, the state-ment to turn on a particular channel is ON [RELAY_CARD,RELAY].

Statements can also involve mathematical or logical operations when opera-tors are used. An operator is a character that performs a specific mathematical orrelational function. For example, the operator used to set a variable equal to avalue is “=.” As expected, the statement used to set variable X to the number 5 isX = 5.

You will frequently have to group several different statements together intoone compound statement. The braces “{ }” are used to enclose this type of state-ment. Compound statements are used if several statements are to be executed ina situation where AXCESS syntax will allow just one. The statements are executedin the sequence in which they are programmed.

The number of open braces “{” and close braces “}” must be the same in yourprogram. After compiling, AXCESS will point out this error to you if the quanti-ties are different.

Compound statements give you the ability to group multiple statements to-gether into one unit, much like grouping sentences together into one paragraph.The most common example of compound statements occurs with the Push key-word. (This keyword is explained in depth later.)

PUSH[PANEL,1]{

ON [RELAY_CARD,5]X = 5

}

In this example, when button 1 on PANEL is pressed, relay 5 on RELAY_CARD

is turned on. Also, the variable X is assigned the value of 5. The open brace indi-cates the beginning of the compound statement, and the close brace ends it.

If you only needed the relay to be turned on, the statement could have beenwritten like this:

PUSH[PANEL,1]ON [RELAY_CARD,5]

Simply the Basics

Keyword

A word or series of words

that signifies the operation

for AXCESS to execute.

Statement

A keyword and all of its

parameters or conditions.

Operator

A character or group of

characters that performs a

specific mathematical or

relational function.

Compound statement

A group of several state-

ments, enclosed by a set of

braces.

Page 35: Axcess Language Tutorial

25Unit 2: Language Basics

Figure 2-1

The uses of braces,

brackets, and parentheses.

These operators cannot be

interchanged within the

program.

Simply the Basics

Special operators

Operator

{ } Braces Combine several statements into a function

[ ] Brackets Enclose the device-channel: [device, channel]

( ) Parentheses Enclose the expression after an If statementEnclose a mutually exclusive set in the Define section

Name Function

Group a mathematical operation

Enclose the location of a storage space in an arrayEnclose the instance number for use with a System_Call

Or if you prefer, braces could be added around the statement:

PUSH[PANEL,1]{

ON [RELAY_CARD,5]}

Since there is only one (and only one) statement after the line PUSH[PANEL,1],braces are not needed.

Comments within the program

AXCESS allows you to place helpful comments inside your program. A commentis a description or remark that is not considered part of the actual program. Anytext after (* and before *) will not be compiled, even if the text is separated overseveral lines. See the following example:

(* This section will define all the devices used. *)

DEFINE_DEVICEVCR = 1 (* Video cassette recorder *)CD = 2 (* Compact disc player *)

You can place any number of comments in your program. However, when theprogram is compiled, the compiler will pass over these. They have no effect onthe actual operation of the program.

It is wise to use comments. They are especially helpful in a long program,where you can label each part of the program for future reference. If changeshave to be made, you can merely look for the label of the section you need toedit. As illustrated in the next example, descriptions of Push statements arevery useful.

Comment

A description or remark

within an AXCESS program

that is not considered part of

the actual program; it is

ignored by the compiler.

Page 36: Axcess Language Tutorial

Unit 2: Language Basics26

PUSH[T_PANEL,1] (* SLIDE preset *){

(* statement(s) *)}PUSH[T_PANEL,2] (* VHS preset *){

(* statement(s) *)}PUSH[T_PANEL,3] (* V_PROJ preset *){

(* statement(s) *)}

This will help you find the SLIDE preset, VHS preset, and the V_PROJ preset ofthe Touch Panel much faster.

Identifiers

Identifiers are used to denote a device, constant, or variable. For example,T_PANEL could represent an AMX Touch Panel, PLAY could represent the firstchannel, and CD_SELECT could represent the current compact disc player.

There are certain guidelines for identifiers. They are as follows:

• They must begin with a letter followed by any combination of letters,numbers, or underscores. No spaces are allowed.

Valid identifiers: CD3, TOUCH_PANEL, VCR3_SELECT

Invalid identifiers: 3VHS, CD PLAYER, *RGB4.

• The identifier must have less than 26 characters.

• Identifiers are not case-sensitive. For example, Touch_Panel is the exactsame identifier as TOUCH_PANEL.

• The identifier must be unique. Once you define VHS3, do not choose thesame name later for a different identifier.

Reserved words

There are certain words that are reserved for AXCESS keywords or functions.These are integral to the system and cannot be redefined or used as identifiers.For example, PUSH cannot be used as an identifier, because AXCESS recognizes itas a keyword.

Identifier

A combination of letters,

numbers, or underscores

that represents a device,

constant, or variable.

Simply the Basics

Page 37: Axcess Language Tutorial

27Unit 2: Language Basics

Special characters and operators

There is also a complete set of symbols that are used within the AXCESS pro-gram, as shown in Figure 2-2. These symbols represent a wide variety of charac-ters and operators.

Simply the Basics

Special mathematical operators

Operator

( ) Parentheses

* Multiply

/ Divide

Function

%

+

Modulus

Add

Subtract

Operator

< Less than

> Greater than

<= Less than or equal to

Function

>=

<>

Greater than or equal to

Not equal to

Figure 2-2

A list of the special operators

used for mathematical

functions and operations.

Page 38: Axcess Language Tutorial
Page 39: Axcess Language Tutorial

29Unit 2: Language Basics

C H A P T E R

5

The Definition Sections

Starting a new program

Now that the ground rules are laid out, you can start writing your first AXCESS

program! When you begin a new program with the ”New..” option in the Filemenu, you are not given an empty file with which to work. Instead, there areseveral definition headings to signify what should be defined in each section.

The definition sections that are given to you are the following:

• Define_Device

• Define_Constant

• Define_Variable

• Define_Latching

• Define_Mutually_Exclusive

• Define_Start

• Define_Program

Feel free to delete any of these headings you do not need, and keep those thatyou do. If you do not have any statements under one of these headings, yourprogram will not operate any differently. However, you might want to keep theheadings there for future reference.

Although the definition sections are not used within the main program, theycreate the materials the main program needs. Devices and their channels are giv-en names, channels are given different characteristics, and variables are formed.Even the immediate startup procedures of the AXCESS system are within a De-

fine section. If you develop a good understanding of the Define statements, youwill be able to build an excellent foundation for the main part of your program.

The device-channel concept

Everything that an AXCESS system controls is controlled through a device in thesystem. Each device communicates to the Master Card through AXlink, theAXCESS system’s communications bus. Most devices, such as a Touch Panel or arelay card, have channels which either accept an input, generate an output, or

The Definition Sections

Page 40: Axcess Language Tutorial

Unit 2: Language Basics30

both. These inputs and outputs are referred to in the AXCESS program as a “de-vice-channel,” which is written like this:

[5,1]

This device-channel references channel 1 of device 5. If device names and con-stants are used instead of numbers, the same reference could look like this:

[VCR,PLAY]

Using device names and constants is obviously much more readable. This con-cept of the device-channel is the most basic concept of the entire AXCESS system,as it is the most common way that AXCESS communicates to the outside world.

Defining devices

When you start writing a program, you should first label each device in the sys-tem. Each device on AXlink must have a unique device number. Card 1 may havedevice number 1, and card 2 may have device number 2. Any time these devicenumbers are referenced in the program, AXCESS checks the corresponding device.However, with a long list of devices connected to AXlink, these numbers can bedifficult to remember. Assigning actual names to these devices is much easier.

This is the function of the Define_Device section. It is placed at the beginningof the program, and it lets you name the devices. Whenever you use this devicename in your program, AXCESS will automatically use the corresponding devicenumber to reference the device.

You will start writing your program by first defining the devices in your sys-tem. Suppose you have a VCR, a CD player, and a cassette deck, and you are con-trolling them with the first three cards in your CardFrame. These cards havedevice numbers 1, 2, and 3. You also will need to control a projection screen,some drapes, and lights. Two relay cards, one in slot 4 and one in slot 5, willhandle these (the first card handles both the screen and drapes). A SoftwirePanel will be used to control all of these devices. Here is what yourDefine_Device section should look like:

DEFINE_DEVICEVCR = 1CD = 2CASS = 3RELAY = 4LIGHTS = 5SWP = 128

The Definition Sections

Device number

A unique number from 1 to

255 designated to each

device connected to AXCESS

via AXlink.

This code fragment is from

STEP1.AXS on the AXCESS

distribution diskette.

Page 41: Axcess Language Tutorial

31Unit 2: Language Basics

From this point on, you can reference device 1 with the name VCR, device 2with the name CD, and so on.

Also, the push window at the bottom of the screen is changed. If the devicesin the previous example are on AXlink, AXCESS modifies the window to use thegiven device name instead of the device’s number. This provides a quick refer-ence tool for future programming.

There is one more reason for using Define_Device. When you compare de-vices using the ”Compare current devices...” option in the Diagnostics menu,AXCESS checks all the devices listed under Define_Device. Next, it checks whichdevices are on AXlink. AXCESS then tells you the devices that you did not definein your program. These devices cannot be used or referenced until they are de-fined, so make sure that all devices are under this heading.

The name you assign to a device number cannot change in the program. Itmust remain the same to the very end.

AMX encourages the practice of starting control panel device numbers at de-vice 128. This includes radio frequency (RF) receivers, Touch Panels, SoftwirePanels, and all other control panels and receivers.

Defining constants

Constants are identifiers whose values remain unchanged throughout the entireprogram. The process of defining them is very similar to defining devices. As-signing a value to an identifier in this section locks that value to the identifier forthe entire program, making it possible to use descriptive names instead of justnumbers in your program.

In your system, the VCR, CD player, and cassette deck devices have channelsthat activate the various transport functions, such as Play and Stop. As a generalrule, Play is usually channel 1 and Stop is channel 2. You could define thesechannel numbers as constants in your program to make it more readable.

DEFINE_CONSTANT

(* Transport channel numbers *)PLAY = 1STOP = 2PAUSE = 3FFWD = 4REW = 5

(* Relay card channel definitions *)SCREEN_UP = 1SCREEN_DOWN = 2SYS_POWER = 3DRAPE_OPEN = 4DRAPE_CLOSE = 5DRAPE_STOP = 6

Constant

An identifier whose value

remains unchanged

throughout the entire

program.

The Definition Sections

Transport functions

Common functions of

devices such as VCRs and

cassette decks. For

example: Play, Stop, Pause,

Fast Forward, and Rewind.

This code fragment is from

STEP1.AXS on the AXCESS

distribution diskette.

Page 42: Axcess Language Tutorial

Unit 2: Language Basics32

(* Lighting card channel definitions *)LIGHT_FULL = 1LIGHT_MED = 2LIGHT_LOW = 3LIGHT_OFF = 4

The value of the constant PLAY from now on is 1. Also, STOP has a value of 2.Both of these values cannot be changed anywhere in the program.

Later in your program when you need to activate the Play function of theVCR, you don’t have to remember that it is channel 1 of the device—just use theconstant PLAY and AXCESS knows to use channel 1.

More than one constant can have the same number. For example, PLAY andFWD can both equal 1. You will probably come across this if two cards do nothave the same channels for the same functions. PLAY on the VCR control cardmight be channel 1, and FWD on the slide control card might also be channel 1.

By definition, the same constant cannot reference more than one number.This may seem obvious, but this type of error could work its way into largeprograms. If you make this mistake, AXCESS will notify you with a “Duplicatesymbol” error message upon compiling.

Defining variables

Variables are places to store data that will change as the program is executed.Think of a variable as an “anything box;” nearly anything can be placed in here.For example, a variable can represent a number. The numeric range is from 0 to65,535; variables cannot hold a negative number. If one variable is subtractedfrom another, the result will be positive. (If, however, you do subtract a largernumber from a smaller number, the result “wraps around” at 65,535. For in-stance, if you subtract 20 from 10, the result is 65,525).

Once the system is turned off, variables do not lose their values. If a certainvariable equals 3 when AXCESS is shut down, it will remain 3 when the system isre-activated. This function has both advantages and drawbacks. It obviouslyhelps when you need AXCESS to retain values for the variables. However, if youneed those variables to be reset when the system is turned on, they must be resetmanually within the Define_Start section.

In your first program you will not be using variables, but keep theDefine_Variable header because you will be using them in the future. TheDefine_Mutually_Exclusive, Define_Latching, and Define_Toggling sections arealso explained later.

The Definition Sections

Variable

A place to store data that will

change as the program is

executed.

Page 43: Axcess Language Tutorial

33Unit 2: Language Basics

Startup code

When the AXCESS system is turned on, the program that was last loaded into theMaster Card is in operation. It is waiting for input from the user. However, youcan tell AXCESS to run a series of statements immediately when the system isturned on. These statements are placed under the Define_Start header, and theyare run only once on power-up. They cannot be executed again until anotherAXCESS power-up.

In your program, you may want to reset all three decks to STOP when AXCESS

is powered up. Here is what your Define_Start section should look like:

DEFINE_START

PULSE [VCR,STOP]PULSE [CD,STOP]PULSE [CASS,STOP]

(Pulse is explained later in more detail.)If variables need to be reset to certain values, the statements needed to do this

should be in this section. Remember, variables retain their values even if the sys-tem loses power.

An important note: The keyword To cannot be used within the Define_Start

section. Instead use On, Off, or Pulse. These keywords are explained later in theunit.

Mainline

Before you begin the main program, you must have the Define_Program

header. This has no real function except to tell AXCESS that you are beginning theactual program at this point. It is used simply like this:

DEFINE_PROGRAM(* Your program starts here. *)

The Define_Program header marks the start of what is called mainline. Main-line is the section of the program that actually “runs” while the Master Card isoperating. Mainline is the heart of the AXCESS program, and it is where you willspend most of your time while programming an AXCESS system.

The Definition Sections

This code fragment is from

STEP1.AXS on the AXCESS

distribution diskette.

Mainline

The section of the program

that actually is executed

continuously by the Master

Card. Also known as the

Define_Program section.

Page 44: Axcess Language Tutorial

Unit 2: Language Basics34

DEFINE_PROGRAM

AXCESS continually loops through mainline

Mainline

Figure 2-3

AXCESS continually loops

through mainline.

The Definition Sections

The most important feature of mainline is that it runs in a continuous loop.Most programming languages have a beginning and an end; they start at thetop, continue until they are finished, and quit. Not AXCESS. Mainline is like acircle: when the Master Card gets to the end, it goes back to the top and passesthrough it again. See Figure 2-3, and refer to the AXCESS Programming Guide fora complete discussion of mainline and the AXCESS bus.

Page 45: Axcess Language Tutorial

35Unit 2: Language Basics

C H A P T E R

6

Using Input and Output

Controlling something over there

The basic idea behind remote control is to do something over here to make some-thing happen over there. In an AXCESS system, the “something over here” is usu-ally some kind of control panel, such as a wireless remote control panel or aTouch Panel. The “something over there” can range from a simple relay to acomplex lighting system.

In mainline you define what happens when these inputs occur. But how doyou get your inputs in the program? How do you generate an output? The an-swer: you use channels.

All about the channel

Almost all methods of control using an AXCESS system require the use of chan-nels on devices. Every channel has two aspects: the input function and the out-put function. See Figure 2-4. When a button is pressed on a control panel, theinput function of the button sends an input change to your program. The inputchange alerts the Master Card to scan your program for a reference to that input.

When there is an input change, AXCESS passes through the entire programonce to see if the change is referenced. If so, AXCESS executes the statement(s) inthe program associated with the input change. There are six keywords used inconjunction with input changes:

• Push

• Release

• Push_Device

Using Input and Output

PUSH [Device,Channel]

RELEASE [Device,Channel]Input change

Mainline

INPUT

OUTPUT

Channel

Figure 2-4

The input and output

functions of a channel.

Input change

A signal sent by the input

function of a channel that

alerts AXCESS to scan

mainline for a reference to

that signal.

Page 46: Axcess Language Tutorial

Unit 2: Language Basics36

• Release_Device

• Push_Channel

• Release_Channel

Push

The Push keyword is used to find out if a channel has had an input change from“off” to “on,” such as when a button is pressed. If the channel has been turnedon, the corresponding Push statement is activated. The operation or operationsfollowing this Push statement are only executed once after the channel is turned on.

Push must be followed by a device number and a particular channel, andboth are enclosed in brackets. Variables can be used in their places, but this isdone only in special circumstances. Following the Push statement is the opera-tion to be executed when the Push occurs. If more than one event must happen,a compound statement must follow the Push. (See the earlier discussion oncompound statements.)

Release

The Release keyword is used in the same way as a Push, except that the opera-tion underneath a Release statement will be executed if the corresponding but-ton is released.

Push_Device

Push_Device is a system variable containing the number of the device having thechannel that was just turned on due to an input change. If a button for deviceT_PANEL was pressed, Push_Device would be equal to the device number ofT_PANEL. This variable is set when a channel is turned on, and it remains con-stant for one pass through mainline. If no channel has been turned on,Push_Device will contain zero.

Release_Device

Release_Device stores the number of the device containing the channel whosebutton was most recently released. If a button for device T_PANEL was released,Release_Device would be equal to the device number of T_PANEL. This systemvariable is used in a program in the same manner as Push_Device. This variablewill have the same value for only one pass through the program.

Using Input and Output

System variable

A value kept in the Master

Card that can be referenced

by certain keywords.

NOTE

Push_Device and

Release_Device cannot both

have a non-zero value

during the same pass

through mainline. At least

one will always be zero.

Page 47: Axcess Language Tutorial

37Unit 2: Language Basics

Push_Channel

Push_Channel is the same as Push_Device, except in this case the channel num-ber that was most recently turned on is stored inside the variable.

Release_Channel

Release_Channel, on the other hand, stores the channel whose button was mostrecently released. This system variable is used in a program in the same manneras Push_Channel.

Changing the state of a channel

So now you can respond to an input change in your program, and you want it toactivate a different device-channel. The next series of keywords allow you to ac-tivate channels based on an input change. This activation is called an outputchange, which is a message to the output function of a channel. See Figure 2-5.The keywords to do this are the following:

• On

• Off

• Total_Off

• To

• Pulse

When you use one of these keywords to activate a channel in a device, thedevice starts the operation that is associated with the channel. For instance, ac-tivating channel 5 on a relay card activates relay number 5, whereas channel 5on an infrared/serial card causes it to generate the infrared pattern it has

Using Input and Output

NOTE

Push_Channel and

Release_Channel cannot

both have a non-zero value

during the same pass

through mainline. At least

one will always be zero.

Figure 2-5

Keywords affecting output

changes.

Output change

A message to the output

function of a channel.

[Device,Channel]

ON [Device,Channel]

OFF [Device,Channel]

TOTAL_OFF [Device,Channel]

TO [Device,Channel]

PULSE [Device,Channel]

Output change

Mainline

INPUT

OUTPUT

Channel

Page 48: Axcess Language Tutorial

Unit 2: Language Basics38 Using Input and Output

stored at location 5.Variables can be used as output channels also, but doing so does not actually

cause an output change. When a variable is activated as a channel, turning it“on” gives it a value of 1, and turning it “off” gives it a value of 0.

The following are some brief definitions of each of the output change keywords.

On

The On keyword simply turns on a channel or variable. If the channel or variableis already on, its status will remain unchanged. Here are two different examples:

•ON [1,2] This turns on channel 2 of device 1.

•ON [TEMP] This sets the value of the variable TEMP to 1.

A variable is considered “on” if it contains a nonzero number; in this case, thevalue is 1. If a variable contains the value zero, it is considered “off.”

Off

The Off keyword turns a channel or variable off. The channel or variable willremain off if it is already off. Here are two different examples:

•OFF [1,2] This turns off channel 2 of device 1.

•OFF [TEMP] This sets the value of the variable TEMP to zero.

Total_Off

The Total_Off keyword acts in the same manner as Off, except that it also turnsoff the status of a channel or variable that is in a mutually exclusive set. Mutu-ally exclusive sets are discussed later in this unit.

To

The To keyword is used to activate a channel or variable for as long as the corre-sponding device-channel of its Push statement is activated. When the device-channel referenced by the Push statement changes from off to on, the To startsactivating the device-channel or variable in the brackets following it. When thedevice-channel of its Push is released, the To statement stops activating its de-vice-channel or variable. For this reason, To must be found only underneath aPush statement.

The To keyword has several conditions:

• It must be used only below a Push statement.

• It cannot be used with the Wait keyword. (This will be explained later.)

• It cannot be placed within the Define_Start section.

Page 49: Axcess Language Tutorial

39Unit 2: Language Basics

The channel or variable will act under the rules set by Define_Latching,Define_Mutually_Exclusive, and Define_Toggling. You will learn what thesedefinitions mean later when you add more to your program.

Pulse

The Pulse keyword turns on a channel or variable for a certain amount of time.Once the time elapses, the channel or variable is turned off.

As an example, refer back to the discussion on Define_Start. The Pulse key-word was used to activate the three decks’ Stop function. The duration of thisPulse is one half-second, but it can be changed if necessary with the Set_Pulse_

Time keyword. The Pulse time is measured in tenths of seconds, and the AXCESS

default is one half-second. The Pulse time remains the same value until it ischanged within the program. Here is an example of Set_Pulse_Time:

SET_PULSE_TIME(12)

This sets the current duration of future Pulses to 1.2 seconds.

Direct assignment

There is another method of generating an output change, but it does not involvethe use of any keywords. Any reference to a device-channel that does not havethe keywords Push or Release preceding it is a reference to the output side ofthe channel. Thus assigning a value directly to a device-channel changes the out-put of the channel. For example:

[SWP,1] = 1

This statement will send an output change to channel 1 of device SWP, tellingthe channel to turn on since AXCESS interprets any non-zero number as “on.”Putting this statement in mainline will make the channel be forever on.

Using direct assignment is only appropriate in feedback statements. In mostsituations, the keywords On, Off, and To are more appropriate.

Putting input and output together

Combining input and output changes into one statement is the basis of mostAXCESS programming. Now that you have these tools, you can write the codethat will actually accomplish this. On your Softwire Panel, you will have buttonnumbers 1 through 5 activate the five transport functions of the VCR: Play, Stop,Pause, Fast Forward, and Rewind. Here is your first section of program code:

Using Input and Output

Page 50: Axcess Language Tutorial

Unit 2: Language Basics40

PUSH[SWP,1]TO [VCR,PLAY]

PUSH[SWP,2]TO [VCR,STOP]

PUSH[SWP,3]TO [VCR,PAUSE]

PUSH[SWP,4]TO [VCR,FFWD]

PUSH[SWP,5]TO [VCR,REW]

In this code, there are actually five separate but similar statements. Examinethe first to see how it all fits together. First there is the keyword Push, followedby a device-channel reference, in this case [SWP,1]. This tells AXCESS, “OK,look here if channel 1 on device 128 receives an input change from off to on.” Ifsuch an input change occurs, the corresponding To statement executes. The To

statement tells AXCESS, “For as long as channel 1 on device 128 is activated,turn on device 1, channel 1.” You may be wondering where the numbers camefrom, since the Push and To statements have the words SWP, VCR, and PLAY.Remember, SWP is a device definition for device 128, and VCR is a constant witha value of 1, as is PLAY.

Duplicate the above section for the CD player and the cassette deck, replacingVCR with CD and CASS where needed. Also be sure to use different channel num-bers for the Push statements, or one activation of channel 1 could make all threedecks play at the same time.

Now that you have the transport functions of your decks programmed, youcan add the rest of the functions on your panel to the program. But before youdo that, you need to learn about the other definition sections: those that definethe characteristics of a channel.

Using Input and Output

This code fragment is from

STEP1.AXS on the AXCESS

distribution diskette.

Page 51: Axcess Language Tutorial

41Unit 2: Language Basics

C H A P T E R

7

Channel Characteristics

The parts of an output channel

An output channel actually has two parts, the physical part and the status part(simply referred to as “status”). See Figure 2-6. The physical part is the device-dependent physical control, such as a relay on a relay card, a button light(“lamp”) on a Softwire Panel, or an infrared pattern in an infrared card. The sta-tus is what records the state of the physical part. In most applications, these twoparts act exactly the same; when one is on, so is the other.

However, you can change the way the status part of an output channel be-haves. In this chapter, you will be shown how to change the status behavior,which in turn changes the way a channel reacts when it is activated by the out-put change keywords.

Channel Characteristics

Output change

Channel

INPUT

OUTPUT

Physical

Status

Figure 2-6

Parts of an output channel.

Page 52: Axcess Language Tutorial

Unit 2: Language Basics42

Defining latching

All channels are momentary by default.* When a momentary channel is activatedwith a To keyword, it activates its output and status only as long as the buttonwhich activated the To keyword is pressed. For example, the Focus channel for acertain slide projector is momentary. When the corresponding Focus button ispressed, the slide projector will focus. The projector will continue to do so untilthe button is released.

However, some devices need their particular channel to stay “on” in order tooperate. If so, the channel can be made latching by being placed in the Define_

Latching section. Once a latching channel is activated by a To keyword, thechannel changes its state from off to on (considering it was previously off).However, when the To keyword stops activating the channel—that is, its corre-sponding button is released—the channel does not go back to off like a momen-tary channel. It stays on. Only when the channel is re-activated by a To keyworddoes it return its state back to off. As a result, the status of a latching channelreflects the true on/off state of the channel.

In your program, RELAY is already defined as device number 4 andSYS_POWER is defined as a constant having the value 3. Using these two valuestogether as device-channel [RELAY,SYS_POWER] gives you a relay to use for yoursystem’s power control. You will need to make this relay latching so that it stayson after you release the Softwire Panel button. Also, your drape motor needslatched relays to operate. Here are the definitions:

DEFINE_LATCHING[RELAY,SYS_POWER][RELAY,DRAPE_OPEN][RELAY,DRAPE_CLOSE]

If you have a series of consecutive channels to be defined, you can use a short-cut. The use of double periods (..) will specify a range of channels between thefirst and last channel. Suppose the lights your system controls needs latched re-lays to operate. Instead of defining each one right after the other, you can do this:

[LIGHTS,LIGHT_FULL]..[LIGHTS,LIGHT_OFF]

Channel Characteristics

Momentary

A defined behavior of status

that causes its output

channel to be activated as

long as the corresponding

button is pressed.

Latching

A defined behavior of status

that causes its output

channel to stay on or off until

activated once more.

* Actually, the correct terminology here is the status of all channels is momentary by default.However, in the common language of programmers, “status” is understood. From this point onin the manual, the behavior of status will be described in this manner.

This code fragment is from

STEP1.AXS on the AXCESS

distribution diskette.

This code fragment is from

STEP1.AXS on the AXCESS

distribution diskette.

Page 53: Axcess Language Tutorial

43Unit 2: Language Basics

In your Define_Constant section, you defined these constants as 1 through 4,so this will make relays 1 through 4 on the LIGHTS card (card 5) latching.

Mutually exclusive

Channels can also be defined as mutually exclusive. A mutually exclusive groupis a set of channels in which only one channel of the set can be turned on at atime. There are three kinds of mutually exclusive channels: momentary, latch-ing, and toggling.

Defining momentary mutually exclusive

When a channel is turned on in a momentary mutually exclusive set, it activates itsphysical output as long as the button is pressed. When the button is released, thephysical output stops. The status, however, does not work in the same manner.Even after the physical output stops, the status still indicates that the channel ison until another channel in the mutually exclusive set is activated. The status ison to let you know which channel in the set was last activated. This is sometimescalled “last button pressed” feedback.

When a channel or variable in this set is activated, all the other members ofthe set are turned off beforehand. This is called “break before make” logic. Thisprevents an accidental activation of more than one channel at the same time,which could cause serious damage to some devices.

For example, consider the drape and screen channels of the device RELAY.Since you cannot open and close a drape all at once, and you cannot raise ascreen and lower it at the same instant (it could damage some motors if youtried!), only one channel can be turned on at a time. They must be defined asmutually exclusive. When SCREEN_UP is activated, the SCREEN_DOWN channel isturned off and SCREEN_UP turns on. The corresponding SCREEN_UP status stayson even though the relay is de-energized when the button is released. WhenSCREEN_DOWN is activated, SCREEN_UP is turned off. The SCREEN_DOWN statusis now the only status turned on.

You also will define the lighting relays as mutually exclusive so that you canutilize the “last button pressed” logic when you program the feedback for thesebuttons. This will allow the user to look at the panel and know which lightingpreset he or she activated last.

Members of a mutually exclusive set are placed in parentheses underneaththe Define_Mutually_Exclusive keyword. The double period (..) shortcut ex-plained in the latching section is also applicable here. For example:

DEFINE_MUTUALLY_EXCLUSIVE([RELAY,SCREEN_UP],[RELAY,SCREEN_DOWN])([RELAY,DRAPE_OPEN]..[RELAY,DRAPE_STOP])

Channel Characteristics

Momentary mutuallyexclusive

A characteristic of status that

allows only one channel of a

pre-defined set to be on at a

time. The output channel is

activated as long as the

corresponding button is

pressed.

IMPORTANT

Make sure you find out which

devices need mutually

exclusive channels. Do not

wait until you test out the

program, as you may

damage some devices.

NOTE

Once a channel has

feedback in a mutually

exclusive group, there will

always be one channel with

its status on in that group,

unless it is turned off with

Total_Off.

This code fragment is from

STEP1.AXS on the AXCESS

distribution diskette.

Page 54: Axcess Language Tutorial

Unit 2: Language Basics44

([LIGHTS,LIGHT_FULL]..[LIGHTS,LIGHT_OFF])([VCR,PLAY]..[VCR,REW])([CASS,PLAY]..[CASS,REW])([CD,PLAY]..[CD,REW])

The first set defines the two screen channels as mutually exclusive. Using theshortcut, the second set defines the three drape channels as mutually exclusive,and the third set defines the four lighting relays as mutually exclusive. Thefourth through the last sets also use the shortcut to define the five transportfunctions as mutually exclusive. This is done to achieve “last button pressed”status for those decks. When you add the feedback statements to the program,the buttons for the VCR, CD player, and cassette deck will indicate the last buttonselected from each group.

Defining mutually exclusive latching

There is a way for a mutually exclusive channel have its physical output con-tinually on if necessary: a channel can be defined as both mutually exclusive andlatching, resulting in the description mutually exclusive latching. If you define achannel in this manner, the physical output remains on until another button inits mutually exclusive set is pressed.

The status of a mutually exclusive latching channel behaves in the same manneras that for a mutually exclusive momentary channel. Note that the physical partand the status of a mutually exclusive latching channel operate in the same manner.

In your program, the lighting relays are already defined as latching. How-ever, you also want them to have the characteristics of a mutually exclusive set;only one lighting mode can be on at one time. Thus you would also place thedevice-channels of these relays in the Define_Mutually_Exclusive section:

DEFINE_MUTUALLY EXCLUSIVE([LIGHTS,LIGHT_FULL]..[LIGHTS,LIGHT_OFF])

Defining mutually exclusive toggling

When a channel is defined as mutually exclusive latching, there is no way toturn off the channel without activating another. Mutually exclusive toggling al-lows a channel to be turned on or off by successive presses of the same button,just like a normal latching channel. Also, the channel is still affected by its mu-tually exclusive characteristics; if the channel is on, it can be turned off by an-other activated channel in its mutually exclusive set. The status of a mutuallyexclusive toggling button operates in the same way as that for a mutually ex-clusive latching button.

Channel Characteristics

Mutually exclusivelatching

A characteristic of status

that allows only one channel

of a pre-defined set to be on

at a time. The output channel

stays on until another channel

of the set is activated.

This code fragment is from

STEP1.AXS on the AXCESS

distribution diskette.

Mutually exclusivetoggling

A characteristic of status that

allows only one channel of a

pre-defined set to be on at a

time. The output channel

stays on until it is re-

activated or another channel

of the set is activated.

Page 55: Axcess Language Tutorial

45Unit 2: Language Basics Channel Characteristics

In order to make a channel toggling, it must be defined as mutually exclusiveand toggling in both the Define_Mutually_Exclusive and Define_Toggling sec-tions. In your program, the screen relays are both mutually exclusive and latching,and thus there is no way to turn off a screen relay without turning on the other.You could fix this by defining the screen relays as mutually exclusive toggling:

DEFINE_TOGGLING[RELAY,SCREEN_UP][RELAY,SCREEN_DOWN]

Putting it all to work

Now that you know just how all these different types of channels operate, youcan skip down to the mainline section of the program and add these lines to acti-vate your system power, screen, drape, and lighting relays:

PUSH[SWP,8]TO [RELAY,SYS_POWER]

PUSH[SWP,33]TO [RELAY,SCREEN_UP]

PUSH[SWP,34]TO [RELAY,SCREEN_DOWN]

PUSH[SWP,41]TO [RELAY,DRAPE_OPEN]

PUSH[SWP,42]TO [RELAY,DRAPE_CLOSE]

PUSH[SWP,43]TO [RELAY,DRAPE_STOP]

PUSH[SWP,45]TO [LIGHTS,LIGHT_FULL]

PUSH[SWP,46]TO [LIGHTS,LIGHT_MED]

PUSH[SWP,47]TO [LIGHTS,LIGHT_LOW]

PUSH[SWP,48]TO [LIGHTS,LIGHT_OFF]

This section accomplishes several tasks:

• Pressing button number 8 on the Softwire Panel alternately latches andunlatches the SYS_POWER channel (channel 1) on card RELAY

This code fragment is from

STEP1.AXS on the AXCESS

distribution diskette.

This code fragment is from

STEP1.AXS on the AXCESS

distribution diskette.

Page 56: Axcess Language Tutorial

Unit 2: Language Basics46

• A press of the Screen Up button latches on the SCREEN_UP channel ondevice RELAY, after unlatching SCREEN_DOWN. The Screen Down buttonacts the same way as the Screen Up button, but with the opposite channels.

• Pressing Drape Open or Drape Close does several things. If it is off, itmakes sure the other drape channel is off (due to its mutually exclusiverelationship), then it latches on. If it was on, it simply turns off, but leavesits status on. (Remember, to turn off the status of a channel in a mutuallyexclusive group, use the keyword Total_Off.)

• Since the LIGHTS channels are mutually exclusive latching, a press of theLights Full button latches on the LIGHT_FULL channel on the device LIGHTS,after unlatching any LIGHTS channel that was previously on. The otherLIGHTS channels operate in a similar fashion.

Now here is the twist. The DRAPE_STOP channel is momentary mutually ex-clusive, whereas the other drape channels are mutually exclusive latching. Whenthe Drape Stop button is pressed, AXCESS makes sure the other drape channelsare off, then engages the DRAPE_STOP channel. Unlike the DRAPE_OPEN andDRAPE_CLOSE channels, however, the DRAPE_STOP channel turns off when thebutton is released. Like the others, its status stays on because it is in the mutu-ally exclusive group with the other Drape channels.

Programming feedback

So far you have been shown how a channel’s output is affected in a program.You know what to do with the input changes and how to create output changes,but now you want to see some feedback on your Softwire Panel. Feedback refersto the lighting of a button during and after it is pressed. AXCESS will not do thisautomatically; you must tell the system how to light the button.

Feedback involves only one statement per button. The first part of the state-ment references the device-channel of the button that is going to be lit. It is fol-lowed by an equal sign (=) and the device-channel corresponding to the sourceof the feedback. For example:

[SWP,1] = [VCR,PLAY]

When VCR channel 1 (the constant value of PLAY) is on, the light of SWP but-ton 1 will also be on. When the channel is off, the light will be off.

Remember that any reference to a device-channel that does not have the key-word Push or Release preceding it is referring to the output side of the channel.This is a very important concept, because it is the basis of how feedback works.

Channel Characteristics

Feedback

The lighting of a button

during and after it is pressed.

Page 57: Axcess Language Tutorial

47Unit 2: Language Basics

Also recall that one way of creating an output change is to assign a value di-rectly to the device-channel. If the value that you are assigning is another de-vice-channel reference, this is in effect saying to AXCESS, “Take the output statusof channel PLAY on device VCR, and send it as an output change to channel 1 ofdevice SWP.” Since you defined the device-channel [VCR,PLAY] as being in amutually exclusive group, its status will be on if it was the last channel activatedin that set, and the feedback assignment will light button 1 on the Softwire Panel.

Grouping feedback statements

The feedback statement is sometimes found after the end of a Push statement.For example:

PUSH[SWP,1]TO[VCR,PLAY]

[SWP,1] = [VCR,PLAY]

When SWP button 1 (Play) is pressed, both VCR channel 1 (PLAY) and thebutton’s feedback are turned on.

The feedback statements can also be grouped together in a feedback section atthe end of the program. For example:

[SWP,1] = [VCR,PLAY][SWP,2] = [VCR,STOP][SWP,3] = [VCR,PAUSE]

This feedback section will act no differently if each statement is placed underits corresponding Push statement.

Where you locate your feedback statements inside your program makes nodifference to the operation of the system, but it does make a difference in thereadability of your program. Grouping all of the feedback statements at the endof the program is fine, but in larger programs it can be a hassle to skip from thetop where the Push is located to the bottom where the feedback statements islocated. Smaller programs, however, may be easier to manage if all the Pushesare together and all the feedback statements are together. A good compromiseis to break your program into sections of code where each section has a similargroup of functions, and put the feedback statements for each section right be-low it. (See Figure 2-7.)

Channel Characteristics

NOTE

Once a channel has

feedback in a mutually

exclusive group, there will

always be one channel with

feedback on in that group,

until turned off with Total_Off.

This code fragment is from

STEP1.AXS on the AXCESS

distribution diskette.

NOTE

For the sake of saving space,

the additional feedback

statements for your program

are listed in the next chapter.

But first, try to write them on

your own.

Page 58: Axcess Language Tutorial

Unit 2: Language Basics48 Channel Characteristics

Code

Feedback

Code

Feedback

Code

Feedback

Code

Feedback

Feedback directly afterwards

Code

Code

Code

Code

Feedback

Feedback

Feedback

Feedback

Feedback at the end

Code

Code

Feedback

Feedback

Code

Code

Feedback

Feedback

Combination

Figure 2-7

Different positions for

feedback statements.

Page 59: Axcess Language Tutorial

49Unit 2: Language Basics

C H A P T E R

8

Your First Program

The program and the panel

This chapter contains your first finished program and a drawing of the SoftwirePanel layout, which is pictured in Figure 2-8. On the next few pages is the entiresource code for the program you developed in this unit. This code can be foundon your distribution disk as STEP1.AXS.

Notice that in this system, all of the feedback is at the bottom. If your programdoes not look exactly like this one, don’t worry! Ten people could write the sameprogram and none would look exactly the same. What is important is that it op-erates the way in which you intend.

Figure 2-8

The Softwire Panel layout

based on your program.

PLAY

STOP

PAUSE

FFWD

REW

VCR

PLAY

STOP

PAUSE

SKIPFWD

SKIPREV

CD

PLAY

STOP

PAUSE

FFWD

REW

CASS

SYSTEM POWER

UP

DOWN

STOP

SCREEN

OPEN

CLOSE

DRAPE

LOW

FULL

MED

LIGHTS

OFF

Your First Program

Page 60: Axcess Language Tutorial

Unit 2: Language Basics50

(***********************************************************)(* DEVICE NUMBER DEFINITIONS GO BELOW *)(***********************************************************)DEFINE_DEVICE

VCR = 1CD = 2CASS = 3RELAY = 4LIGHTS = 5SWP = 128

(***********************************************************)(* CONSTANT DEFINITIONS GO BELOW *)(***********************************************************)DEFINE_CONSTANT

(* TRANSPORT CHANNEL NUMBERS *)PLAY = 1STOP = 2PAUSE = 3FFWD = 4REW = 5

(* THE RELAY CARD CHANNEL DEFINITIONS *)SCREEN_UP = 1SCREEN_DOWN = 2SYS_POWER = 3DRAPE_OPEN = 4DRAPE_CLOSE = 5DRAPE_STOP = 6

(* THE LIGHT CARD CHANNEL DEFINITIONS *)LIGHT_FULL = 1LIGHT_MED = 2LIGHT_LOW = 3LIGHT_OFF = 4

(***********************************************************)(* VARIABLE DEFINITIONS GO BELOW *)(***********************************************************)DEFINE_VARIABLE

(***********************************************************)(* LATCHING DEFINITIONS GO BELOW *)(***********************************************************)DEFINE_LATCHING

[RELAY,SYS_POWER][RELAY,DRAPE_OPEN][RELAY,DRAPE_CLOSE][LIGHTS,LIGHT_FULL]..[LIGHTS,LIGHT_OFF]

Your First Program

Page 61: Axcess Language Tutorial

51Unit 2: Language Basics

(***********************************************************)(* MUTUALLY EXCLUSIVE DEFINITIONS GO BELOW *)(***********************************************************)DEFINE_MUTUALLY_EXCLUSIVE

([RELAY,SCREEN_UP],[RELAY,SCREEN_DOWN])([RELAY,DRAPE_OPEN]..[RELAY,DRAPE_STOP])([LIGHTS,LIGHT_FULL]..[LIGHTS,LIGHT_OFF])([VCR,PLAY]..[VCR,REW])([CASS,PLAY]..[CASS,REW])([CD,PLAY]..[CD,REW])

DEFINE_TOGGLING[RELAY,SCREEN_UP][RELAY,SCREEN_DOWN]

(***********************************************************)(* STARTUP CODE GOES BELOW *)(***********************************************************)DEFINE_START

PULSE [VCR,STOP]PULSE [CD,STOP]PULSE [CASS,STOP]

(***********************************************************)(* THE ACTUAL PROGRAM GOES BELOW *)(***********************************************************)DEFINE_PROGRAM

PUSH[SWP,1] TO [VCR,PLAY]PUSH[SWP,2] TO [VCR,STOP]PUSH[SWP,3] TO [VCR,PAUSE]PUSH[SWP,4] TO [VCR,FFWD]PUSH[SWP,5] TO [VCR,REW]

PUSH[SWP,9] TO [CD,PLAY]PUSH[SWP,1Ø] TO [CD,STOP]PUSH[SWP,11] TO [CD,PAUSE]PUSH[SWP,12] TO [CD,FFWD]PUSH[SWP,13] TO [CD,REW]

PUSH[SWP,17] TO [CASS,PLAY]PUSH[SWP,18] TO [CASS,STOP]

Your First Program

Page 62: Axcess Language Tutorial

Unit 2: Language Basics52

PUSH[SWP,19] TO [CASS,PAUSE]PUSH[SWP,2Ø] TO [CASS,FFWD]PUSH[SWP,21] TO [CASS,REW]

PUSH[SWP,8] TO [RELAY,SYS_POWER]

PUSH[SWP,33] TO [RELAY,SCREEN_UP]PUSH[SWP,34] TO [RELAY,SCREEN_DOWN]

PUSH[SWP,41] TO [RELAY,DRAPE_OPEN]PUSH[SWP,42] TO [RELAY,DRAPE_CLOSE]PUSH[SWP,43] TO [RELAY,DRAPE_STOP]

PUSH[SWP,45] TO [LIGHTS,LIGHT_FULL]PUSH[SWP,46] TO [LIGHTS,LIGHT_MED]PUSH[SWP,47] TO [LIGHTS,LIGHT_LOW]PUSH[SWP,48] TO [LIGHTS,LIGHT_OFF]

(* FEEDBACK *)

[SWP,33] = [RELAY,SCREEN_UP][SWP,34] = [RELAY,SCREEN_DOWN]

[SWP,1] = [VCR,PLAY][SWP,2] = [VCR,STOP][SWP,3] = [VCR,PAUSE][SWP,4] = [VCR,FFWD][SWP,5] = [VCR,REW]

[SWP,9] = [CD,PLAY][SWP,1Ø] = [CD,STOP][SWP,11] = [CD,PAUSE][SWP,12] = [CD,FFWD][SWP,13] = [CD,REW]

[SWP,17] = [CASS,PLAY][SWP,18] = [CASS,STOP][SWP,19] = [CASS,PAUSE][SWP,2Ø] = [CASS,FFWD][SWP,21] = [CASS,REW]

[SWP,8] = [RELAY,SYS_POWER]

Your First Program

Page 63: Axcess Language Tutorial

53Unit 2: Language Basics

[SWP,41] = [RELAY,DRAPE_OPEN][SWP,42] = [RELAY,DRAPE_CLOSE][SWP,43] = [RELAY,DRAPE_STOP]

[SWP,45] = [LIGHTS,LIGHT_FULL][SWP,46] = [LIGHTS,LIGHT_MED][SWP,47] = [LIGHTS,LIGHT_LOW][SWP,48] = [LIGHTS,LIGHT_OFF]

(***********************************************************)(* END OF PROGRAM *)(* DO NOT PUT ANY CODE BELOW THIS COMMENT *)(***********************************************************)

Your First Program

Page 64: Axcess Language Tutorial
Page 65: Axcess Language Tutorial

UNIT 3

CONDITIONALS,LOOPS,AND WAITS

AXCESS Language Tutorial

Page 66: Axcess Language Tutorial
Page 67: Axcess Language Tutorial

Unit 3: Conditionals, Loops, and Waits 57

C H A P T E R

9

If and the Boolean Expressions

Introduction

While your first program may look complicated at first, it really doesn’t showthe power of the AXCESS language. The program is what we at AMX call “one-to-one.” That means that each button has one and only one function, with no spe-cial conditions or considerations. The control panel has a separate section ofbuttons for each piece of equipment.

But suppose you want the same number of functions with fewer buttons. Acommon solution is to have several groups of buttons with similar functions re-duced to one group, with a set of buttons that selects which piece of equipmentthe buttons control. In your program, you could have one button for each pieceof equipment to select each deck, and one set of transport buttons. Your panelcould now look like the one in Figure 3-1.

If and the Boolean Expressions

Figure 3-1

The revised Softwire Panel

layout for your program. The

functions are the same, but

there are fewer buttons.

VCR

CD

CASS

SELECT

PLAY

STOP

PAUSE

FFWD

REW

TRANSPORT

SYSTEM POWER

UP

DOWN

STOP

SCREEN

OPEN

CLOSE

DRAPE

LOW

FULL

MED

LIGHTS

OFF

Page 68: Axcess Language Tutorial

58 Unit 3: Conditionals, Loops, and Waits

You now have seven fewer buttons than you did before. What you want to hap-pen with this panel is that the user selects the deck with a Select button, then con-trols it with the Transport buttons. This will not be a one-to-one program becausethe Transport buttons each have three possible functions. In the program you willuse Boolean expressions to select the correct function of the Transport buttons.

Boolean expressions

A Boolean, or relational, expression is used to tell AXCESS whether or not to executea particular function or functions in the program. Picture yourself walking alonga path in the country. Suddenly you come upon a fork in the road. Which wayshould you go? If you guess, you might become lost. Therefore you judge cer-tain conditions before continuing. Is the left road heading north? Is the rightroad heading east?

This is what AXCESS must do whenever you branch off in different directionsin your program. Either AXCESS continues in the direction it is going, or it mustjump to a different section.

A Boolean expression can have one of two results, true or false. In AXCESS,any non-zero value is true and a zero value is false. When AXCESS evaluates aBoolean expression, it assigns a 1 for a true result, and a zero for a false result.

The If statement

The most common keyword in AXCESS that uses Boolean expressions is the Ifkeyword. Every If statement must be followed by a Boolean expression enclosedin parentheses. This provides the beginning of a conditional execution of state-ments. The structure is as follows:

IF (Boolean expression)(Statement 1)

If the Boolean expression is true, AXCESS executes Statement 1 and then contin-ues with whatever statements follow. If the Boolean expression is false, Statement 1is ignored. If Statement 1 is a compound statement, it must be enclosed in braces.

The If...Else set of statements

This is similar to the basic If statement, with the addition of one more branch. Ifthe Boolean expression is false, AXCESS executes a function independent of the“true” Boolean expression. For example:

Boolean expression

A conditional statement used

to tell AXCESS whether or not

to execute a particular

function or functions in the

program. Also known as a

relational expression.

If and the Boolean Expressions

Page 69: Axcess Language Tutorial

Unit 3: Conditionals, Loops, and Waits 59

IF (Boolean expression)(Statement 1)

ELSE(Statement 2)

If the Boolean statement is true, then Statement 1 is executed. Statement 2, un-derneath the Else statement, is ignored. If the Boolean statement is false, thenStatement 2 is executed. Remember that Statement 1 is automatically ignored ifthe expression is false.

The If...Else If set of statements

Whereas using If and If...Else allows two different paths, using If...Else If allowsan essentially unlimited number of paths. AXCESS stops at the first true Booleanexpression and executes the following function. After completion, it goes on tothe rest of the program. For example:

IF (Boolean expression)(Statement 1)

ELSE IF (Boolean expression)(Statement 2)

ELSE IF (Boolean expression)(Statement 3)

(* As many Else If statements as memory allows... *)

A last Else statement (not Else If) can be placed at the end as a default state-ment; that is, if AXCESS does not find a true If or Else If statement, it executes thefinal Else statement. However, this last statement is not necessary.

Nesting

Once AXCESS is travelling along a branch (for example, Statement 1 in the previ-ous example), you can tell it to branch off again with another If statement. This“branch within a branch” is called nesting. There can be any level of branches; anIf can be within an If within an If, and so on. The only restriction is the amount ofmemory available.

When you are nesting If...Else statements, be sure to use braces. Look at thefollowing incorrect example:

IF (X = 5)IF (Y = 1Ø)

(Statement 1)ELSE

(Statement 2)

If and the Boolean Expressions

Default statement

A statement (or compound

statement) that executes if

none of the conditions being

tested comes true.

Nesting

Placing conditional branches

inside other conditional

branches.

Page 70: Axcess Language Tutorial

60 Unit 3: Conditionals, Loops, and Waits

You can see by the alignment of the Else statement with the IF (X = 5) thatthese two should be associated. The second If statement is not supposed to havean Else counterpart in this example. However, such is not the case. AXCESS pairsthe second If statement with the Else, because the compiler associates the Else

with the “closest” If statement.With braces, you can force the compiler to associate the Else with IF (X =

5). For example:

IF (X = 5){

IF (Y = 1Ø)(Statement 1)

}ELSE

(Statement 2)

By using the braces, you isolate the IF (Y = 1Ø) statement from the If...Else

set of statements.

The Select...Active statement

There is a way to make If...Else If nesting easier: the Select...Active statement. Thisallows the easy placement of several branches from one path. This is the format:

SELECT{

ACTIVE (Boolean expression 1) : (Statement 1)ACTIVE (Boolean expression 2) : (Statement 2)ACTIVE (Boolean expression 3) : (Statement 3)(* ...etc. *)

}

Each one of the Boolean expressions, in order, is evaluated until one is foundto be true. The statements associated with that true expression are then exe-cuted, and the path then flows to whatever statements follow the closing brace.Using a Select...Active is much preferred to multiple If...Else If statements; ituses less memory and it runs faster. If too many If...Else If statements arechained together, they can overflow the Master Card’s memory and crash theentire system. Obviously it is much better to use Select...Active in such situations.

When using the If...Else set of statements, the code following the Else is thedefault statement—if the condition of the If is false, the default statement follow-ing the Else is executed. So what happens in a Select...Active if none of the con-

If and the Boolean Expressions

Page 71: Axcess Language Tutorial

Unit 3: Conditionals, Loops, and Waits 61

ditions evaluate as true? In such a case, no code of any Active statement will beexecuted, since Select...Active has no default statement. You can, however, cre-ate your own default for a Select...Active:

SELECT{

ACTIVE (condition) : (statement)ACTIVE (condition) : (statement)ACTIVE (condition) : (statement)ACTIVE (1) : (default statement)

}

Here, the last Active will always be true, and will execute only if all of theconditions of the previous Actives are false. This makes the last Active’s state-ment the default statement.

Trying it out

Now you can write the code for your new panel layout. Before you do that,however, you will need to update your definition sections a little.

There are two methods of implementing “select groups.” One is to base theselection on which variable of a mutually exclusive set is active. The other is touse one variable and change its value based on which deck is selected. You willexplore the “mutually exclusive variable” method first.

“Mutually exclusive variable” method

In this method, you create a variable for each selection you need and make thevariables mutually exclusive. Variables can be made mutually exclusive in thesame way device-channels can. First you create the variables in theDefine_Variable section:

DEFINE_VARIABLEVCR_SELECTCD_SELECTCASS_SELECT

Now you make the variables mutually exclusive by adding this line to theDefine_Mutually_Exclusive section:

(VCR_SELECT,CD_SELECT,CASS_SELECT)

If and the Boolean Expressions

BUZZWORD

“Select groups” refer to a

group of buttons that select

a single deck or device out of

a group. In this case, the

select group consists of the

VCR, CD player, and the

cassette deck.

This code fragment is from

STEP2.AXS on the AXCESS

distribution diskette.

This code fragment is from

STEP2.AXS on the AXCESS

distribution diskette.

Page 72: Axcess Language Tutorial

62 Unit 3: Conditionals, Loops, and Waits

Notice that there are only parentheses around the whole group and no brack-ets. This is because brackets are only necessary when a device-channel referenceis used. Now you can make the Push for each Select button go To one of thesevariables. Due to the “last button pressed” nature of the variable’s status, youcan determine which deck was last selected. Here is the mainline code:

PUSH [SWP,1]TO [VCR_SELECT]

PUSH [SWP,2]TO [CD_SELECT]

PUSH [SWP,3]TO [CASS_SELECT]

Notice that even though you do not use brackets in the mutually exclusivesection with variables, you do in the To statement. This is because the To state-ment always requires brackets.

Now you can add your conditional statements. Look at the VCR functionsfirst, noting that the button numbers on the Softwire Panel for the transport but-tons are 17 through 21 for all three decks.

IF (VCR_SELECT){

PUSH[SWP,17]TO [VCR,PLAY]

PUSH[SWP,18] TO [VCR,STOP]

PUSH[SWP,19] TO [VCR,PAUSE]

PUSH[SWP,2Ø] TO [VCR,FFWD]

PUSH[SWP,21] TO [VCR,REW]

}

Notice that the Boolean expression of the If statement is simply a variable.What happens is that the If tests the variable to see if it is zero or non-zero. Theonly time it is non-zero is if it was the last variable set by one of the Select but-tons. If another Select button is pressed, the other mutually exclusive variablesare turned off and the new SELECT variable is turned on. When you duplicate theabove code for the CD player and the cassette player, only one section will run ata time, which is what you want. Make sure that all three sections have the samebutton device-channels in the Push statements.

If and the Boolean Expressions

This code fragment is from

STEP2.AXS on the AXCESS

distribution diskette.

Page 73: Axcess Language Tutorial

Unit 3: Conditionals, Loops, and Waits 63

Not only are the functions of the Transport buttons conditional, but the feed-back is too. You could make three more If statements, one for the feedback ofeach deck. Yet a better method is to include each deck’s feedback statements inthe same If statement as the control statements. By doing this, your VCR sectionnow looks like this:

IF (VCR_SELECT){

PUSH[SWP,17]TO [VCR,PLAY]

PUSH[SWP,18]TO [VCR,STOP]

PUSH[SWP,19]TO [VCR,PAUSE]

PUSH[SWP,2Ø]TO [VCR,FFWD]

PUSH[SWP,21]TO [VCR,REW]

[SWP,17] = [VCR,PLAY][SWP,18] = [VCR,STOP][SWP,19] = [VCR,PAUSE][SWP,2Ø] = [VCR,FFWD][SWP,21] = [VCR,REW]

}

Repeating this procedure for each deck completes the programming requiredto implement your new panel layout using mutually exclusive variables. Theentire source code up to this point is on your distribution disk as STEP2.AXS.

The “variable assignment” method

Another method of programming select groups is to use one variable, assigningdifferent values to it depending on what is selected. This method is actuallymore powerful than the previous method, as it provides more flexibility whileusing a lot less code.

Before writing the program using this method, go back to the STEP1.AXS pro-gram. First add just one variable, DECK. This will be the select variable. To thisvariable you will assign the device number of your currently selected deck. Hereis your Select buttons’ code:

PUSH[SWP,1]DECK = VCR

PUSH[SWP,2]DECK = CD

PUSH[SWP,3]DECK = CASS

If and the Boolean Expressions

This code fragment is from

STEP2.AXS on the AXCESS

distribution diskette.

Select variable

A variable whose value

determines which device in a

group is currently selected.

This code fragment is from

STEP3.AXS on the AXCESS

distribution diskette.

Page 74: Axcess Language Tutorial

64 Unit 3: Conditionals, Loops, and Waits

Now here is where you see some of the real power of the AXCESS language.You can reduce the number of transport sections from three to just one by usingthe variable DECK as the device number in the To statements, instead of usingVCR, CD, and CASS. Here’s the section of code:

PUSH[SWP,17]TO [DECK,PLAY]

PUSH[SWP,18]TO [DECK,STOP]

PUSH[SWP,19]TO [DECK,PAUSE]

PUSH[SWP,2Ø]TO [DECK,FFWD]

PUSH[SWP,21]TO [DECK,REW]

Notice that there is no If statement necessary, no mutually exclusive variablesare necessary, and this is the only deck transport section of programming neededin the whole program! But how does this work? Suppose you want to play theCD player. First you press the CD Select button. This assigns the value 2 (the con-stant value of CD) to the variable DECK. Now the device-channel references ofthe To transport statements will reference device number 2 (the CD device).Pressing button number 17 on the Softwire Panel will activate [DECK,PLAY],which AXCESS will interpret as [2,1].

The feedback for the transport section works in the same manner as the con-trol section. The feedback statements use the DECK variable as the device fromwhich to get the feedback. These statements for the selection buttons, however,are something new:

[SWP,1] = (DECK = VCR)[SWP,2] = (DECK = CD)[SWP,3] = (DECK = CASS)

These statements, like all feedback statements, are direct assignment outputchanges; however, the source of the assignment is a Boolean expression. In inter-preting this kind of feedback statement, AXCESS first evaluates the Boolean ex-pression. If the expression is evaluated as true, AXCESS replaces the expressionwith a 1; otherwise AXCESS replaces it with a zero. (Remember, only one of thesewill be evaluated as true because a variable cannot have two different values atone time.) Thus the direct assignment will assign a 1 (”on”) to the Softwire Panel

If and the Boolean Expressions

This code fragment is from

STEP3.AXS on the AXCESS

distribution diskette.

This code fragment is from

STEP3.AXS on the AXCESS

distribution diskette.

Page 75: Axcess Language Tutorial

Unit 3: Conditionals, Loops, and Waits 65

button for which the expression is true, and a zero (”off”) to the false ones. Re-call that assigning a 1 to a device-channel is the same as turning that device-channel’s output on.

The entire source code for this program using the variable assignmentmethod is included on the distribution disk as STEP3.AXS.

More Boolean operators

The previously discussed If and If...Else statements could only base the programflow on one condition. You can, however, combine two of these conditions witha Boolean operator. This operator sets the rules of what the end result will be.

The Boolean operators used in the AXCESS system are And, Or, Xor, and Not.These are placed in between the two conditions after the If statement. For example:

IF ((X = 1Ø) AND (Y = 5)){

(Statement 1)}

If the end result of the Boolean expression is true, AXCESS continues withStatement 1. If the end result is false, AXCESS simply ignores Statement 1.

Reading a Boolean expression table

In most Boolean expressions, the possible conditions of two statements are ana-lyzed to achieve one result. These results can be visualized using Boolean ex-pression tables, as explained in Figure 3-3. A text formula can also be followedto find that result:

“If <statement 1> is <its condition (true or false)> <Boolean operator> <state-ment 2> is <its condition>, then the result of the expression is <result of state-ment conditions>.”

If and the Boolean Expressions

Boolean operator

A keyword or symbol that

creates a relation between

two items.

Boolean operator abbreviations

Abbrev

&& Logical And

| |

^^

Function

!

Abbrev

& Bitwise And

|

^

Function

~

Logical Or

Logical Xor

Logical Not

Bitwise Or

Bitwise Xor

Bitwise Not

Figure 3-2

The Boolean operators in

AXCESS have shorthand

symbols which can be used

in place of the words. (The

bitwise operators are

explained in the AXCESS

Programming Guide.)

Page 76: Axcess Language Tutorial

66 Unit 3: Conditionals, Loops, and WaitsIf and the Boolean Expressions

And

T

F

T

F

F

F

T F

Boolean operator

Statement 1 possible conditions

Statement 2 possible conditions

Results of statement conditions based upon rules set by the Boolean operator

And

T

F

T

F

T

F

T T

Boolean operator

Statement 1: (NUM1 = 5) is true

Statement 2:(NUM2 = 4) is false Result of statement conditions: false

Not

T

F

F

T

T

F

T FXor

T

F

F

T

T

F

T FOr

T

F

T

T

T

F

T FAnd

T

F

T

F

F

F

T FFigure 3-5

Tables of results of various

Boolean operators.

The result is found by basing the conditions of the statements against therules set by the Boolean operator. Here are those specific rules:

• And Both statements must be true for the result to be true.

• Or At least one of the conditions must be true for the result to be true.

• Xor Only one statement can be true for the result to be true.

• Not If the statement is true, the result is false. On the contrary, if thecondition is false, the result is true. This expression uses only onestatement.

Assume that it has been previously defined that NUM1 = 5 and NUM2 = 3. In-sert the variables from the example into the text formula:

”If NUM1 = 5 is true and NUM2 = 4 is false, then the result of the expression is false.”

The statement would have been true if NUM2 had been equal to 3, because inan And expression both statements must be true (see Figure 3-4).

The Boolean expression tables in Figure 3-5 are a quick reference guide for theresult of a Boolean expression. They are not necessary, but they can be very helpful.

Figure 3-3

A pictorial explanation of the

Boolean expression table for

the operator And.

Figure 3-4

An example of how a

Boolean expression table is

used to compare multiple

conditions.

Page 77: Axcess Language Tutorial

Unit 3: Conditionals, Loops, and Waits 67

C H A P T E R

10

Waits and Timer Keywords

Controlling time within AXCESS

Within the AXCESS system, there are a variety of timing keywords available foryour use. Functions can be delayed for a few seconds, or they can be delayeduntil certain conditions are right. The built-in stopwatch allows you to measuretime intervals between operations in your program. You can even programAXCESS to start rolling the film precisely on Saturday at 3:15 PM. This chapterwill help you learn each of these keywords and show you how to apply them toyour programs.

You will build on your previous program (STEP3.AXS), but this time you willnot be changing the layout of your Softwire Panel; you’ll just add more func-tions to the existing buttons.

The Wait list

The most common keyword relating to time is the Wait keyword, which is usedto activate functions after a specified delay time has elapsed. The program flowdoes not stop when a Wait is encountered. Instead, AXCESS places the Wait state-ment into a list in memory and continues on with the rest of the program. Aftereach pass through mainline, the Master Card scans this Wait list, and if anyWaits have come due, AXCESS executes the statement or compound statementimmediately following the expired Wait keyword. Up to 50 Waits are allowed inthe list at a time. (Refer to the AXCESS Programming Guide for a complete dis-cussion of mainline and the AXCESS bus.)

Time in the Wait list is measured in tenths of a second. A Wait of 10 is one sec-ond, a Wait of 15 is one and a half seconds, a Wait of 20 is two seconds, and so on.

Suppose in your system you have two relays controlling system power. Oneis for the audio amplifier, and the other is for the rest of the equipment (we’llcall that “rack power”). In many cases, a time delay is desired between power-ing up the source equipment and powering up the audio amplifier. The reason isthat if both are powered up at the same time, there is sometimes a loud “pop”over the audio system from the source equipment; but if there is a delay, thesource equipment is already on and there will be no “pop” when the amp isturned on. In most cases a one half-second delay is enough.

Waits and Timer Keywords

Wait list

A list containing unexpired

Wait statements. After each

pass through mainline, the

Master Card scan this list to

see if any have come due.

Page 78: Axcess Language Tutorial

68 Unit 3: Conditionals, Loops, and Waits

In your program, you will first add a constant definition for your new relayand change the name of the existing system power relay to RACK_POWER. If youuse relay 7 (the next available relay on the card), the line to add to the Define_

Constant section looks like this:

AMP_POWER = 7

You will also change the constant identifier SYS_POWER to RACK_POWER. Asfor the System Power button, you want the rack power to come on first (relay 3)when the power is turned on; one half-second later, the amp power should turnon. When you turn the power off, you want the reverse to happen. Here’s thenew code for the System Power button:

PUSH[SWP,8]{

IF ([RELAY,RACK_POWER]){

OFF [RELAY,AMP_POWER]WAIT 5 OFF [RELAY,RACK_POWER]

}ELSE{

ON [RELAY,RACK_POWER]WAIT 5 ON [RELAY,AMP_POWER]

}}

First, look at the organization of this set of statements. Here is a simplifiedoutline of the structure of this code:

PUSH[SWP,8]{

IF (device-channel)compound statement

ELSEcompound statement

}

From this simpler outline you can more easily examine what is happeninghere. Following the Push statement is a single If...Else statement which has onlya device-channel reference for its condition. In this case AXCESS checks that

This code fragment is from

STEP4.AXS on the AXCESS

distribution diskette.

This code fragment is from

STEP4.AXS on the AXCESS

distribution diskette.

Waits and Timer Keywords

Page 79: Axcess Language Tutorial

Unit 3: Conditionals, Loops, and Waits 69

channel’s status. If it is on, AXCESS evaluates the condition as true and executesthe first compound statement. Otherwise AXCESS executes the compound state-ment following the Else.

The first compound statement, which is executed if the rack power is on, usesa Wait to accomplish a time-delayed powering-down of the system. The firststatement inside the compound statement turns off the amplifier relay. The nextstatement is a Wait statement for five-tenths of a second (same as one half-sec-ond), followed by an Off statement to the rack power relay. AXCESS places thisWait into the Wait list and continues with the program. Since these statementsare part of an If compound statement, AXCESS does not execute the Else’s com-pound statement.

As AXCESS continues to run, the Wait is still in the Wait list. After one half-second has elapsed, AXCESS will execute the statement immediately followingthe Wait, which in this case turns off the rack power. The corresponding Wait isthen taken out of the list.

The compound statement following the Else is nearly the same as the one justdescribed; its functions are just slightly different. AXCESS first turns on the rackpower, waits a half-second, and then turns on the amp power.

Multiple Waits

Now that you know how to delay an action for a specific amount of time, youcan add a little pizzazz to your system. Suppose you want a series of severalevents to happen when you press just one button. At this point, the SystemPower button completes just two events with a delay in between.

Now you will make the System Power button accomplishes several morethings when the power is being turned on and off. Suppose that when the poweris being turned on, you want a series of timed events to take place. First, the rackpower comes on as before. At the same time, the screen starts to come down andthe drapes start to close. One half-second later, the amp power comes on, justlike before. Twenty seconds after the button is pressed, the Medium lightingscene is selected.

When the power is turned off, a different sequence happens. First the amppower is turned off, lights go to the Full setting, the screen is raised, and thedrapes are opened. One half-second later the rack power turns off. Two minuteslater the lights go to the Off setting.

Here is the code for the System Power Push for the described scenario:

PUSH[SWP,8]{

IF ([RELAY,RACK_POWER]) (* Power being turned off *){

Waits and Timer Keywords

Page 80: Axcess Language Tutorial

70 Unit 3: Conditionals, Loops, and Waits

OFF [RELAY,AMP_POWER]TO [LIGHTS,LIGHT_FULL]TO [RELAY,SCREEN_UP]TO [RELAY,DRAPE_OPEN]WAIT 5 OFF [RELAY,RACK_POWER]WAIT 12ØØ PULSE [LIGHTS,LIGHT_OFF]

}ELSE (* Power being turned on *){

ON [RELAY,RACK_POWER]TO [RELAY,SCREEN_DOWN]TO [RELAY,DRAPE_CLOSE]WAIT 5 ON [RELAY,AMP_POWER]WAIT 2ØØ PULSE [LIGHTS,LIGHT_MED]

}}

Notice the use of the Pulse keyword. This is done, as you may recall, becauseTo cannot be used inside a Wait. Since the lighting buttons are momentary, youuse a Pulse to actuate the relay for just a moment.

Waits can appear inside other Waits. This is called “nesting” Waits. You don’tneed to nest Waits in your program here, but here is how it is done:

WAIT 2ØØ{

ON [RELAY,SCREEN_UP]WAIT 2ØØ OFF [RELAY,SCREEN_UP]

}

In this example, AXCESS would wait twenty seconds, turn on the Screen Uprelay, wait twenty more seconds, then turn off the Screen Up relay. Any timedsequence of events can be accomplished with or without nested Waits. Usingnested Waits is in many cases more readable than non-nested Waits. Non-nestedWaits, however, use less code. Here is the same example without nesting:

WAIT 2ØØ ON [RELAY,SCREEN_UP]WAIT 4ØØ OFF [RELAY,SCREEN_UP]

Special uses of Wait

A Wait time of zero is a special case: the code following the Wait will be ex-ecuted directly after the current pass through mainline. This is because the Wait

goes into the Wait list, and at the end of mainline when the Master Card checks

This code fragment is from

STEP4.AXS on the AXCESS

distribution diskette.

Waits and Timer Keywords

Page 81: Axcess Language Tutorial

Unit 3: Conditionals, Loops, and Waits 71

the list for expired Waits, the Wait Ø will be due to execute. Using Wait Ø isonly done in special cases.

Any one Wait can only be placed in the Wait list once. If a particular Wait isalready in the Wait list, it cannot be placed into the list a second time until thefirst instance is either cancelled or expired. For instance, suppose the followingline appears in mainline where it will be executed every pass through mainline:

WAIT 5 FLASH = NOT FLASH

The first time this is executed, the Wait is placed into the Wait list. But what ifthis line is executed again before the Wait expires? Since the Wait is already inthe Wait list, the line is simply ignored. One half-second after the first executionof this statement, the value in variable FLASH is inverted; if it was zero it will bechanged to 1, and if it was non-zero it will be changed to zero. On the next passthrough mainline, the Wait will again be placed into the Wait list and the cyclewill repeat for the duration of the program. This in effect creates a variablewhose state inverts every half-second.

Naming Waits

When a Wait is given a unique name, it can be either cancelled, paused, orrestarted. To name a Wait, simply place a name in single quotes after the Wait

statement. For example:

WAIT 3Ø ’DELAY’

Once DELAY is entered into the list, it cannot be re-entered until the first hasbeen removed.

There are certain considerations in naming Waits:

• They should not be previously defined constants or variables.

• They cannot be names that have already been assigned to buffers orsubroutines. (Buffers and subroutines are explained later in the manual.)

• They can contain spaces, unlike other AXCESS identifiers.

Cancelling, pausing, and restarting Waits

Once a Wait is named, it can be manipulated within the program with several key-words. Pause_Wait places a Wait on “hold.” The Wait does not continue counting

Waits and Timer Keywords

Page 82: Axcess Language Tutorial

72 Unit 3: Conditionals, Loops, and Waits

down until it is resumed with Restart_Wait. The Wait then continues from whereit was paused. Cancel_Wait completely nullifies a Wait, removing it from theWait list. Cancel_All_Wait nullifies every Wait currently in the list. The key-words Pause_All_Wait and Restart_All_Wait act the same as Pause_Wait andRestart_ Wait, except they affect all Waits in the Wait list, named and un-named.

You could use a named Wait in your System Power Push routine. Supposethe user just turned off the power. The program now has a two-minute Wait inthe Wait list for the lights to go off. If the user turns the power back on before thisWait executes, the power-on sequence will start, but the events of the LIGHT_OFF

Wait will still happen! The user could end up in a very dark room which is defi-nitely not what he or she wanted. In this case it would be advantageous to namethat Wait and cancel it in the power-on section of the Push. To do this, simplyadd the Wait name to the Wait in the power-off section like this:

WAIT 12ØØ ‘LIGHTS OFF’ PULSE [LIGHTS,LIGHT_OFF]

To cancel the Wait in the power-on section, simply add this line:

CANCEL_WAIT ‘LIGHTS OFF’

The Wait_Until keyword

The Wait_Until keyword is not a true “timing” keyword; AXCESS does not waitfor a certain amount of time to elapse. Instead, AXCESS checks to see if a condi-tion is true. When the condition becomes true, AXCESS executes the statementslisted directly below the Wait_Until statement.

All Wait_Untils go into another list very similar to the Wait list, called theWait_ Until list. Just as it does with Waits, each pass through mainline AXCESS

checks to see if any Wait_Until conditions have become true. For each one thathas, AXCESS immediately executes the sequence below the Wait_Until state-ment. If not, AXCESS keeps the Wait_Until in the Wait_Until list until its condi-tion becomes true.

Misusing Wait_Until

Since AXCESS only checks the status of pending Wait_Untils after completelyrunning mainline, make sure that the condition has a chance to become true, oryou will defeat the purpose of the Wait_Until statement. You don’t need Wait_Until in your program yet, but this program segment illustrates the misuse ofWait_Until:

Waits and Timer Keywords

These code fragments are

from STEP4.AXS on the

AXCESS distribution diskette.

Wait_Until list

A list containing unexpired

Wait_Until statements. After

each pass through mainline,

the Master Card scan this list

to see if any have come due.

Page 83: Axcess Language Tutorial

Unit 3: Conditionals, Loops, and Waits 73

WAIT_UNTIL (Y=4){

(* statements *)}

Y=4Y=3

As you can see, Y will never equal four at the end of the program. TheWait_Until in this case is completely useless.

It would be hard to make this mistake in a small program such as the one youare working on, but this problem could make its way into a fairly large program.AXCESS cannot detect this sort of error, so make sure each Wait_Until statementcan become true one way or another.

Naming and removing Wait_Untils

In the same manner as a Wait, a Wait_Until can be named. To do this, a name insingle quotes is placed at the end of the statement. Once a Wait_Until has aname, it can be cancelled with the Cancel_Wait_Until keyword, which removesit from the Wait_Until list. The Cancel_All_Wait_Until keyword removes allWait_Untils from the Wait_Until list.

The timer keywords

There are several more timing features: the timer keywords. Set_Timer andGet_Timer allow you to have both a “stopwatch” and the ability to measuretime intervals within the AXCESS system.

Set_Timer

The timer provided to you is a simple one. It cannot be stopped or paused—onlyset. Like a Wait, time is measured in increments of tenths of seconds. There isonly one such timer available.

To set the timer, the Set_Timer keyword is used. You must specify a numberbetween 0 and 65,535, and the timer will start counting up from that point. Afterthe timer reaches 65,535 it wraps around to 0 and starts over.

Get_Timer

The Get_Timer system variable contains the current status of the timer. Usuallythis keyword is used in conjunction with an If statement. For example, look atthe following code segment:

Waits and Timer Keywords

Page 84: Axcess Language Tutorial

74 Unit 3: Conditionals, Loops, and Waits

IF (GET_TIMER >= 1ØØ){

(* do something *)}

Notice that a “greater than” sign was combined with the “equal” sign. Thereis a chance that the timer will reach the number 100 while the program is beingexecuted elsewhere. When AXCESS reaches the Get_Timer section, the timermight be 103. If the condition was that Get_Timer be equal to 100, the followingstatements would have been skipped. Never use only an equal sign with theGet_Timer system variable in an If statement.

Unlike variables, the timer loses its value when the AXCESS system is turnedoff. When the system is reactivated, the timer is reset to zero.

Using Time, Date, and Day

The system variables Time, Date, and Day can also be used to create timingfunctions. Time contains the current time in the form of the string HH:MM:SS, inwhich HH equals “hours,” MM equals “minutes,” and SS equals “seconds.” Thetime is given in a 24-hour format (military time). Date contains the current datein the form of the string MM/DD/YY, in which MM equals “month,” DD equals“day,” and YY equals “year.” Finally, Day contains the current day of the year inthe form of one of the strings MON, TUE, WED, THU, FRI, SAT, or SUN.

These variables have two restrictions:

• They cannot be changed within the AXCESS program. Instead, this is donewith the terminal emulator which was explained in Unit 1.

• Individual storage locations cannot be referenced. (This reference to arraysand string operations is explained in Unit 5.)

• The string operations Left_String, Mid_String, and Right_String can beused to access parts of these variables.

Most of the time, these variables are used with an If statement. Once the con-dition is true, certain statements are executed. For instance, suppose you wantedto turn off all of the lights at 11:00 PM every night.

The code would look like this:

IF (TIME = ‘23:ØØ:ØØ’)PULSE [LIGHTS,LIGHT_OFF]

Waits and Timer Keywords

Page 85: Axcess Language Tutorial

Unit 3: Conditionals, Loops, and Waits 75

The statements following the If statement will be executed every day at 11:00PM. Suppose you wanted to change it so that every hour the lights would turnoff. The statement would simply be changed to read:

IF (TIME = ‘??:ØØ:ØØ’)PULSE[LIGHTS,LIGHT_OFF]

The question mark (?) acts like a “wildcard” character, allowing any characterto be in its place. Since question marks are in place of the hour, the comparisonwill be true once an hour when the minutes and seconds are zero, and the lightswill turn off.

Your entire program up to this point is contained in the file STEP4.AXS on yourdistribution disk.

Waits and Timer Keywords

Page 86: Axcess Language Tutorial
Page 87: Axcess Language Tutorial

Unit 3: Conditionals, Loops, and Waits 77

C H A P T E R

11

The While Keywords

While

Sometimes it may be necessary to loop through a certain section of a programuntil a condition becomes true. This is the purpose of the While family of key-words. When AXCESS comes to a While, it checks to see if the condition followingit is true. If the condition is false, AXCESS skips the statement immediately fol-lowing the While—just like the If keyword. However, if the condition is true,AXCESS executes the statement and then rechecks the While’s conditional expres-sion. If the condition is still true, the statement is executed again.

This sequence continues until the condition is evaluated as false. When thecondition comes up false, program execution continues with the statement fol-lowing the While’s block of code. Here is an example:

X = 1WHILE (X < 5){

ON [RELAY,X]X = X + 1

}

In this code example, the variable X is first set to 1. Next, the While statementchecks to see if X is less than 5. Since it is, AXCESS executes the compound state-ment directly following the While: the device-channel referenced by [RELAY,1](since X equals 1) is turned on, and X is incremented by one. Then program ex-ecution goes back to the While statement. This loop continues until X becomes 5,in which case the compound statement following the While is not executed, andAXCESS goes on to the rest of the program. This block of code essentially turnson the first four channels of device RELAY.

There is a limitation on using the While keyword. The amount of time AXCESS

spends executing any single While cannot exceed 0.5 seconds. This is because theMaster Card updates AXlink (the communications bus between all AXCESS de-vices) between each pass through mainline. If AXlink is not updated at certaintime intervals, problems could develop during bus communications. Therefore,to prevent an AXCESS program from stalling mainline too long, there is a 0.5 sec-

The While Keywords

Page 88: Axcess Language Tutorial

78 Unit 3: Conditionals, Loops, and Waits

ond time-out on While loops; that is, AXCESS will forcibly exit the While after onehalf-second, regardless of the operation it is executing. (Remember, Waits arechecked after mainline and thus are not subject to such restrictions.)

Long_While

There are cases where a While loop cannot help but to take longer than one half-second to execute. If this becomes the case, simply change the While keyword inquestion to a Long_While.

The main difference between a While and a Long_While is that after each loopthrough the Long_While’s statement, the AXlink bus is updated. This, in effect,makes the statement or compound statement following a Long_While to be a“mini-mainline” for as long as the condition of the Long_While is true. There-fore, Long_While has absolutely no timeout period. But be careful! If you don’tprovide a way out of your Long_While (by allowing the condition to becomefalse), the program will become stuck inside the Long_While and no other codeoutside of the loop will be executed.

Medium_While

During the execution of a Long_While, AXCESS scans AXlink just like it doeswhen running mainline. It is during this scanning that AXCESS receives informa-tion about input changes from devices such as Softwire Panels and Touch Pan-els. This activity also takes place after each loop through a Long_While. Therefore, ifa user presses a button while AXCESS is looping through a Long_While, the inputchange is lost to any programming outside the Long_While loop.

If this becomes a problem, the Medium_While keyword may be used. Thiskeyword operates just like a Long_While, but it ignores input changes fromAXCESS devices. These input changes are not lost, but will remain pending untilthe Master Card scans for them again—either before the next pass throughmainline, or after a pass through a Long_While. (Refer to the AXCESS Program-ming Guide for a complete discussion of mainline and the AXCESS bus.)

Once again, be very careful when using Long_While and Medium_While. Ifthe condition associated with one of these in your program can never becomefalse, your program could get stuck in an infinite loop, requiring a reset of theMaster Card or maybe even a re-loading of the system’s programming.

The While Keywords

Page 89: Axcess Language Tutorial

UNIT 4

LEVELS

AXCESS Language Tutorial

Page 90: Axcess Language Tutorial
Page 91: Axcess Language Tutorial

Unit 4: Levels 81

C H A P T E R

12

Creating Levels

Introduction

So far, you have used channels in devices to interact both with the user and withwhat he or she wants to control. Channels, however, are not the only method ofcontrolling some devices, such as volume control cards, voltage generator cards,and pan/tilt control cards. Devices such as these use “levels” to interface withthe outside world. Also, several AXCESS panels have bar graph displays capableof displaying a level. This unit will show you how to create, read, and modifythese levels, plus show you how to use bar graphs and sliders on some of theAXCESS devices.

What is a level?

An input/output (I/O) channel in AXCESS is usually digital in nature; that is, itcan only have an “on” or an “off” state. Several AXCESS devices, such as the vol-ume control card and the pan/tilt control card, have analog input and/or out-put capabilities. An analog input or output may have many different states.Devices using analog I/O internally store the values relating to the state of eachof these analog inputs and outputs; these values are called levels. On a volumecard, levels relate to the volume levels of the card. Levels can be used to tell apan/tilt control card where to position a camera, or tell a voltage generator cardthe amount of voltage to generate.

Creating Levels

Level

A value that is related to an

analog input or output on an

AXCESS device.

Digital

An input or output can have

only two values: on and off.

Analog

An input or output can have

many values.

LEVEL 1

0 255

80

Level values

LEVEL 2

0 255

135

Figure 4-1

The “imaginary knob.” The

knob is the level, which can

have a range of values.

Page 92: Axcess Language Tutorial

82 Unit 4: LevelsCreating Levels

Imagine that a volume control card has two volume knobs: one for the leftspeaker and one for the right. See Figure 4-1. Each knob has a range of valuesfrom 0 to 255. These knobs represent the two levels present in the volume con-trol card. When a “level” is discussed in the text, it is usually referring to thevalue of one of these imaginary knobs.

Creating levels

In the AXCESS language, a level can have a value between 0 and 255. Level val-ues can be stored in a variable for later use. In order to read a level from anAXCESS device that supports levels, you use the keyword Create_Level. Here isthe syntax:

CREATE_LEVEL device, level number, variable

Create_Level takes three parameters:

• the device from which to read the level

• which level of the device to read (some devices have many different levels)

• the variable in which to store the level

This keyword creates an association between the specified level of the deviceand the specified variable. During execution of your program, AXCESS will continu-ally update the variable to contain the value of the level with which it is associated.(Refer to the AXCESS Programming Guide for a complete discussion of mainline

Figure 4-2

The Touch Panel layout for

this unit. VOLUME CONTROL

UP

DOWN

MUTE

PRESET

Page 93: Axcess Language Tutorial

Unit 4: Levels 83

and the AXlink bus.) Since this association only needs to be done once, this key-word is only allowed to appear in the Define_Start section of your program.

In this unit, you will develop a new program that handles levels. This systemwill contain a volume control card to control a volume level, and a Touch Panelfor the user to control the volume card. On the Touch Panel, there will be fourbuttons: Volume Up, Volume Down, Volume Mute, and Volume Preset. Therewill also be a bar graph on the Touch Panel to display and control the volumelevel. See Figure 4-2. Here are some code excerpts to get started:

DEFINE_DEVICEVOLUME = 1PANEL = 128

DEFINE_CONSTANT

(* Three channels to control both outputs together *)V_UP = 1V_DN = 2V_MT = 3

DEFINE_VARIABLEVOL_LEVEL (* This will store the volume level

value of the card *)

DEFINE_LATCHING[VOLUME,V_MT]

DEFINE_STARTCREATE_LEVEL VOLUME,1,VOL_LEVEL

This code defines the devices you will use, a variable in which to store thevolume level value, and the statement in the startup code to create the associa-tion between level number 1 of the volume card and the VOL_LEVEL variable. Italso defines some constants which give names to the different channels availablein the volume control card. By turning on and off these channels the user canraise, lower, and mute the volume levels of the card. Notice that the V_MT chan-nel is latching; this is the channel that mutes the volume. By making it latching,subsequent presses toggle the muting on and off. Here is the code for the Vol-ume Up, Volume Down, and Volume Mute buttons on the Touch Panel:

DEFINE_PROGRAMPUSH[PANEL,1]{

OFF [VOLUME,V_MT]TO [VOLUME,V_UP]

}

Creating Levels

This code fragment is from

STEP5.AXS on the AXCESS

distribution diskette.

This code fragment is from

STEP5.AXS on the AXCESS

distribution diskette.

Page 94: Axcess Language Tutorial

84 Unit 4: Levels

PUSH[PANEL,2]{

OFF [VOLUME,V_MT]TO [VOLUME,V_DN]

}

PUSH[PANEL,3]TO [VOLUME, V_MT]

[PANEL,1] = [VOLUME,V_UP][PANEL,2] = [VOLUME,V_DN][PANEL,3] = [VOLUME,V_MT]

Notice that the Volume Up and Volume Down buttons will automaticallyunmute the volume before starting to ramp the volume up or down. Also, thesecontrol channels affect both levels of the volume card simultaneously, rampingboth up and down together.

This code handles all of the functions of your system except for the bar graphand the Volume Preset button. You will add the code for these in the next chapter.

Creating Levels

Ramp

To change a level from one

value to another smoothly

over a period of time.

Page 95: Axcess Language Tutorial

Unit 4: Levels 85

C H A P T E R

13

Using Levels

Reading levels

When a level is associated with a variable using Create_Level, AXCESS continu-ally keeps the variable updated with the value of that level. In your program, asthe user ramps the volume level up, the value in VOL_LEVEL increases. When thevolume is ramped up to the maximum, VOL_LEVEL will contain 255. The samegoes for ramping down; when the volume is muted, the variable will contain zero.

Making a preset

Now you are going to add the code necessary to create a preset. A preset is alevel stored for later retrieval. What you will do here is give the Volume Presetbutton a dual role. If the button is pressed and held for two seconds, the currentlevel of the volume card is stored in the variable PRESET. If the button is pressedfor less than two seconds, it sends a command to the volume card to set the levelof the card to the previously saved level in PRESET. First, here is the code:

PUSH[PANEL,5]{

SET_TIMER(Ø)}RELEASE[PANEL,5]{

IF (GET_TIMER>2Ø){

PRESET = VOL_LEVEL}ELSE{

SEND_COMMAND VOLUME, "'PØL', ITOA(PRESET)"OFF [VOLUME,V_MT]

}}[PANEL,5] = (PRESET = VOL_LEVEL)

This code uses the timing keywords Set_Timer and Get_Timer to test theamount of time between the Push and the Release of the Preset button. If the timeis greater than two seconds—remember, Get_Timer returns time in increments

Using Levels

NOTE

The volume card remembers

the last level when it is muted

so that it can unmute to that

same level.

Preset

A level saved for later

retrieval. When a preset is

recalled, the level returns to

the preset value.

This code fragment is from

STEP5.AXS on the AXCESS

distribution diskette.

For information on a

particular device’s

Send_Command functions,

see the AXCESS Program-

ming Guide and the

product’s literature.

Page 96: Axcess Language Tutorial

86 Unit 4: Levels

of one-tenth of a second—then the current level of the card (stored in VOL_LEVEL)is saved into the variable PRESET. If the button press is less than two seconds acommand is sent to the volume card to go to the level saved in PRESET, and thevolume is unmuted. Note that the feedback for the Volume Preset button is litwhenever the current volume level equals the value of the PRESET variable.

Using bar graphs

Now you will add the code to continuously display the current level of the vol-ume card on the Touch Panel’s bar graph. To update a bar graph on a device,you use the Send_Level keyword. Here is the syntax:

SEND_LEVEL device, level number, value

This keyword is used to update a level in a device. Assume your bar graph dis-play on the Touch Panel has level number 1. In order to keep the display updat-ed continually, you will add the following line into your program (on mainline):

SEND_LEVEL PANEL, 1, VOL_LEVEL

Since this code resides in mainline it will be executed continually, thus mak-ing sure that the bar graph reflects the value of level number 1 of the volumecard. As the volume ramps up, VOL_LEVEL increases and the bar graph fills. Asthe volume ramps down, VOL_LEVEL decreases and the level indicated on thebar graph also decreases. Since both volume levels are ramping together, youonly have to track one of them for the bar graph.

Connecting levels

Touch Panel bar graphs have a unique feature: you can touch and slide the bargraph itself and the level will raise or lower to that point; the level simply tracksthe movement of your finger. However, to do this you must set up a connectionbetween the bar graph and the volume level. That is what the keyword Define_

Connect_Level accomplishes.Define_Connect_Level is not a keyword that is used inside mainline, but is

actually a definition section like Define_Device or Define_Start. When you useit, the best location to place it is immediately following the Define_Variable sec-tion. Underneath the Define_Connect_Level header is where all level connec-tions are listed. Here is how Define_Connect_Level is used:

Using Levels

This code fragment is from

STEP5.AXS on the AXCESS

distribution diskette.

Page 97: Axcess Language Tutorial

Unit 4: Levels 87

DEFINE_CONNECT_LEVEL(device 1,level number 1,device 2,level number 2,...etc.)

The section inside the parentheses represents a single connection. All levelslisted in the connection will follow each other. If any one level changes, all oth-ers will change to match. Any number of levels may be supported per connec-tion, and there is no limit to the number of connections.

Here is how you would use Define_Connect_Level in your program to con-nect the Touch Panel's bar graph to the volume card's levels:

DEFINE_CONNECT_LEVEL(PANEL, 1, VOLUME, 1, VOLUME, 2)

This connects level number 1 on the Touch Panel (your bar graph) and levels1 and 2 on the volume card together. The reason that two levels on the volumecard are included is because volume control cards have two levels: the left audiochannel and the right audio channel. These connections are a two-way street:anytime the bar graph is changed, both volume levels will follow, and anytime avolume level is changed (probably by the volume control buttons on the TouchPanel), the bar graph will automatically follow. When using Define_Connect_

Level, it is not necessary to use the Send_Level keyword in your program sincethe connection constantly takes care of updating the bar graph.

The example programs for this unit can be found on the AXCESS distributiondiskette. The file STEP5.AXS uses the Create_Level and Send_Level keywords,and STEP6.AXS uses the Define_Connect_Level keyword.

Using Levels

This code fragment is from

STEP6.AXS on the AXCESS

distribution diskette.

Page 98: Axcess Language Tutorial
Page 99: Axcess Language Tutorial

UNIT 5

ARRAYS,STRINGS,AND BUFFERS

AXCESS Language Tutorial

Page 100: Axcess Language Tutorial
Page 101: Axcess Language Tutorial

91Unit 5: Arrays, Strings, and Buffers

Arrays and Strings

Introduction

In the previous unit you developed a program that demonstrates the most com-mon features of the AXCESS language. In this unit, more advanced concepts will beintroduced: arrays, strings, buffers, and two-dimensional arrays. Understandingthese concepts and the keywords that go with them will allow you to easily handledata, and will provide another means of communicating with the outside world.

In this first chapter, you will develop a small example program. For this pro-gram, you will need to create a level and assign it to a variable. You will use thevariable VOLUME_LEVEL for this. Your control panel will have nine buttons: Vol-ume Up (button 1), Volume Down (button 2), Store (button 3), Preset 1, Preset 2,Preset 3, Preset 4, Preset 5, and Preset 6 (buttons 9 through 14). The Volume Upand Volume Down buttons ramp a volume card up and down. The Store buttonsimply toggles a state on and off. The Preset 1–6 buttons either store or recall apreset, depending on whether the Store button is on or not.

Defining arrays

In the program developed in Unit 2, you used a variable called DECK. This vari-able could only hold one value at a time. However, if you need a variable tohold several values at once, use an array. An array is a single variable that hasmore than one storage location.

Arrays must be defined as variables within the Define_Variable section ofyour program. Its definition has two parts: a unique identifier and its storagecapacity. First, the variable must be named by a valid identifier (see Chapter 4for the rules concerning identifiers). Second, the number of storage locations inthe array must be indicated; a maximum of 255 locations can be specified.

For your new program, you want to store several preset levels for the volumecontrol card. You could create several individual variables and use If statementsor Select...Active statements to select the preset you want to use. Or even better,you could create an array and use the index value (explained later) to pick thepreset you want to use. Here is your array declaration:

Arrays and Strings

Array

A single variable that has

more than one storage

location.

The example program for

this chapter can be found on

your distribution diskette as

STEP7.AXS.

C H A P T E R

14

Page 102: Axcess Language Tutorial

92 Unit 5: Arrays, Strings, and BuffersArrays and Strings

Figure 5-1

The array PRESETS has six

empty storage locations.

PRESETS

DEFINE_VARIABLEPRESETS[6]

This declares a new variable, PRESETS, which is shown in Figure 5-1. The vari-able PRESETS is an array which can hold six distinct values, as defined by thenumber 6 inside the brackets.

Accessing and storing array values

To access a particular value in an array, simply refer to the storage location in-side the array you wish to retrieve, such as follows:

THE_LEVEL=PRESETS[3]

The number inside the brackets is called the index value. The index value is thenumber that tells AXCESS which location in the array to retrieve, and it must be anumber from 1 to 255. This example assigns the value in the third location ofPRESETS to the variable THE_LEVEL. Retrieving a value from an array does not inany way change the array. See Figure 5-2.

Index value

The number that tells AXCESS

which location in an array to

retrieve. This value must be

an integer from 1 to 255.

PRESETS[3]

PRESETS

A B C D E F

THE_LEVEL

Figure 5-2

The value in PRESETS[3] is

assigned to the variable

THE_LEVEL.

Page 103: Axcess Language Tutorial

93Unit 5: Arrays, Strings, and Buffers Arrays and Strings

PRESETS

A 6 C D E F

6

Figure 5-3

The storage location

PRESETS[2] is assigned a

value of 6.

You can place values into a storage location by setting the particular locationequal to the needed value. For example, PRESETS was previously defined as hav-ing six locations. If you want the second location to hold a value of 6 you wouldtype the following:

PRESETS[2]=6

The number 6 is placed into the second location, as shown in Figure 5-3. Fromnow on, anytime PRESETS[2] is referenced, its value is 6.

In the example program, pressing a Preset button either stores or recalls a pre-set. Examine the section of code that accomplishes this:

PUSH[SWP,3]STORE = NOT STORE

[SWP,3] = STORE

IF ((PUSH_CHANNEL >= 9) AND (PUSH_CHANNEL <= 14)){

IF (STORE)PRESETS [PUSH_CHANNEL – 8] = VOLUME_LEVEL

ELSESEND_COMMAND VOLUME_CARD,“‘PØL’,ITOA (PRESETS[PUSH_CHANNEL – 8])”

}

The first PUSH[SWP,3] is the Store button, which simply toggles the STORE

variable using the Not operator. (Remember, Not inverts the state of whateverfollows it.) The Push statement is immediately followed by a feedback statementfor the Store button. The next statement is an If statement which checks to see ifPush_Channel is greater than or equal to nine, and less than or equal to 14. Inother words, the statements inside the If’s block are executed if one of the Presetbuttons are pressed. Inside the block is another If statement which uses the stateof the variable STORE to determine whether to assign the volume card’s level to a

This code fragment is from

STEP7.AXS on the AXCESS

distribution diskette.

NOTE

The keyword

Send_Command sends a

string to an AXCESS device,

which then interprets the

string as a command for an

action. See the AXCESS

Programming Guide for a list

of device-specific com-

mands.

Page 104: Axcess Language Tutorial

94 Unit 5: Arrays, Strings, and BuffersArrays and Strings

location in the PRESETS array, or to send a command to the volume card telling itto go to a previously stored level. In order to place the variable VOLUME_LEVEL

into the array PRESETS at the correct location, 8 must be subtracted fromPush_Channel to find the index value.

Strings

Many times you may need to reference entire groups of values at once. You cando this by using strings and string expressions. A string is a set of valuesgrouped together with single and/or double quotes. Strings enclosed in singlequotes are called string literals.

Single quotes can only enclose values ranging from decimal 32 (the space char-acter) to decimal 126 (the tilde character ‘~’). These string literals are constantvalues that are set at compile time. Once loaded into the master card these stringscannot be changed, except when a new program is loaded into the Master Card.

Here is an example of assigning a string to an array:

PRESETS='FOUR'

When AXCESS processes this assignment, it places the ‘F’ (ASCII value 70) inlocation 1 of PRESETS, ‘O’ (ASCII value 79) in location 2, and so on. See Figure 5-4.String ‘FOUR’ is placed in the array PRESETS. Note that an index value is notgiven when strings are assigned to arrays. The first letter is automatically placedinto the first storage location, the second letter is placed into the second storagelocation, and so on.

The string expression

Single and double quotes are interpreted in two different ways by the AXCESS

system. Whereas single quotes enclose string literals, double quotes represent adifferent operation: they enclose string expressions. A string expression combinesseveral types of data into a single string. A string expression can contain any

PRESETS

F O U R E F

F O U R

Figure 5-4

The string ‘FOUR’ is assigned

to the array PRESETS.

String

A set of values grouped

together with single and/or

double quotes.

String literal

A set of characters (values

ranging from 32 to 127)

enclosed in single quotes.

String expression

Enclosed by double quotes,

this expression combines

several types of data into a

single string.

Page 105: Axcess Language Tutorial

95Unit 5: Arrays, Strings, and Buffers Arrays and Strings

PLAY

PRESETS

1 5 Ø N O 10

5 Ø N O X

Figure 5-5

A string expression is

assigned to the array

PRESETS.

ASCII value (0 to 255), as well as variables, string literals, and arrays. The differ-ence between a string literal and the string expression is that the string expres-sion is “built” at run time instead of compile time. As AXCESS processes a stringexpression, it evaluates each member of the expression from left to right, and theresult is a complete string. Here is an example:

PRESETS="PLAY,5,Ø,'NO',X"

Assuming that PLAY is a constant with the value of 1, and X is a variable withthe value of 10, the string expression is evaluated as a string with the followingvalues: “1,5,0,‘N’,‘O’,10.” See Figure 5-5. Since the expression is evaluated at runtime, whatever value is in the variable X when the expression is evaluated iswhat is placed into the result.

Arrays as strings

There are two ways of referencing data in arrays within AXCESS programs: eachlocation as an individual value, or each array as a group of values. So far you haveseen how to access the individual locations. However, an entire array can be ac-cessed as one unit. If you refer to an array without specifying an index value, thecontents of the entire array is referenced as a string. Consider the following lines:

DEFINE_VARIABLES1[1Ø]

DEFINE_PROGRAMS1='TEST ONE'SEND_STRING CARD,'TEST TWO'SEND_STRING CARD,S1

This small section of code will send two strings to the card named CARD: first‘TEST TWO’, then ‘TEST ONE.’ Notice that there are no quotes around the variable

Run time

When the program is

executed in the Master Card.

Compile time

When the program is

compiled.

NOTE

A string expression cannot

contain another string

expression; i.e. a set of

double quotes cannot

enclose another set of

double quotes.

Page 106: Axcess Language Tutorial

96 Unit 5: Arrays, Strings, and Buffers

S1 in the second Send_String. This is because the variable S1 is an array, andwhen an array is referenced as a single unit like this, it is considered a string. Ifyou had assigned a string expression to S1 and then sent it to the card, the entirecontents of the string expression would be sent.

Suppose that during power-up of the AXCESS system you want to set all of thepresets to default values. You could do this by assigning values to each indi-vidual location in the PRESETS array. A better solution, however, is to use astring expression to set all six at once, like this:

DEFINE_STARTPRESETS = “Ø,3Ø,9Ø,128,191,255” (* set all preset

values at power-up *)

String lengths

Every array declared in the Define_Variable section has a string length valueassociated with it. The string length of an array is an internal value set for arraysby string assignment operations. This number is different than the storage ca-pacity declared in the Define_Variable section. You can get this length value ofan array by using the Length_String function. Here is an example:

Y = LENGTH_STRING (PRESETS)

Here are examples of some assignments, and what the above line of codewould return to the variable Y in each case:

PRESETS = 'FOUR' (* Y = 4 *)PRESETS = 'ONE' (* Y = 3 *)PRESETS = "12,5,'123'" (* Y = 5 *)PRESETS = "PLAY,5,Ø,'NO',X" (* Y = 6 *)

The length of a string array cannot exceed the number of storage locationsallocated to it in the Define_Variable section. If the string ‘GOODBYE’ is placed inthe PRESETS variable, the array will only contain the string ‘GOODBY,’ droppingthe final ‘E’ because PRESETS was defined to hold a maximum of six locations.The length of PRESETS would also be set to 6.

Assigning string literals and string expressions automatically sets the lengthof the string array to the length of the string literal or string expression being

Arrays and Strings

This code fragment is from

STEP7.AXS on the AXCESS

distribution diskette.

String length

An internal value set for

arrays by string assignment

operations.

Page 107: Axcess Language Tutorial

97Unit 5: Arrays, Strings, and Buffers

assigned to it. However, assigning values to individual elements of an arraydoes not affect the length value of the array. For instance, if the letters ‘W,’ ‘O,’‘R,’ and ‘D’ are assigned individually to elements of PRESETS as shown below,the length will not change. If the length was previously 3, it will still be 3.

PRESETS[1] = 'W'PRESETS[2] = 'O'PRESETS[3] = 'R'PRESETS[4] = 'D'

There is a way, however, to explicitly set the string length value of an arrayvariable. The Set_Length_String keyword accomplishes this. For instance, to setthe length value of PRESETS to 4, you would use the following statement:

SET_LENGTH_STRING(PRESETS,4)

After execution, the string length value of the array PRESETS is 4.String lengths play an important role in the handling of strings. Consider this

string expression that contains an array in the expression:

"5,PRESETS,'GO'"

As AXCESS constructs a string from this string expression, the number of char-acters from the array PRESETS it will add will be equal to PRESETS’ string lengthvalue. If PRESETS contains “1,2,3,4,5,6” but its string length value is 3, the result-ing string from the above string expression will look like this:

"5,1,2,3,'G','O'"

The string length value of an array is very important to many string opera-tions in AXCESS. This value determines how much of the string is used when theentire array is referenced as a string. Knowing this will prevent subtle errorsfrom creeping into your code. For instance, if you assign values to individualelements in an array, and then assign that array to another, nothing will actuallybe copied. Here is an example:

Arrays and Strings

Page 108: Axcess Language Tutorial

98 Unit 5: Arrays, Strings, and Buffers

PRESETS[1] = 5PRESETS[2] = 6PRESETS[4] = 'A'SAVE_PRESETS = PRESETS

What do you think the array SAVE_PRESETS will contain after this code is ex-ecuted? It will totally depend on the length value of the PRESETS variable. If thiswere the entire program, PRESETS would have a default length of 0, so nothingwould be copied into SAVE_PRESETS. In order to assure that SAVE_PRESETS wereto hold a copy of PRESETS, you would first need to set the length value of thePRESETS array with this line inserted before the copy statement:

SET_LENGTH_STRING (PRESETS,4)

After this, the length value of PRESETS is 4, so the first 4 locations of PRESETS

will be used in all cases where you refer to the entire array.

Sending strings and arrays

To send a string to the outside world, you use the Send_String keyword. Here isthe syntax:

SEND_STRING device,<string, variable, or string expression>

The first value after the Send_String keyword is the device number or identi-fier to which you wish to send the string. Following that is a comma, then thestring, variable (which can be either a normal variable or an array), or string ex-pression you wish to send. When an array variable is specified, the number ofcharacters from the array that are sent is determined by the length value for thearray. (Remember, you can set that value with the Set_Length_String function.)

For instance, if you need to send the PRESETS array to a card named RS232, youwould write the following line:

SEND_STRING RS232,PRESETS

String literals and string expression can also be sent using Send_String. Hereare some examples:

Arrays and Strings

Page 109: Axcess Language Tutorial

99Unit 5: Arrays, Strings, and Buffers

SEND_STRING RS232,'THIS IS A STRING LITERAL'SEND_STRING RS232,"'EXPRESSION ',PRESETS,$ØD,$ØA"

The first example sends the entire set of characters enclosed in the singlequotes, from left to right, to the card named RS232. The second example firstbuilds the string expression using a string literal, followed by however manycharacters from PRESETS as defined by its length value, and then two numbersexpressed here in hexadecimal. (The hexadecimal numbers in the example rep-resent the codes for “carriage return” and “line feed,” respectively.)

ASCII codes

As you have learned, a string is broken up into single letters when placed into astring array. Each storage space returns the letter it is holding when referenced.For example, assume that PRESETS[3] holds the letter ‘R.’ There are actuallythree ways you can reference this array location (in this example using If state-ments):

IF(TEMP[3] = 'R'){

(* statement(s) *)}

or

IF(TEMP[3] = 82){

(* statement(s) *)}

or

IF(TEMP[3] = $52){

(* statement(s) *)}

The letter ‘R’ has an ASCII value of 82 decimal, which is equivalent to 52 inhexadecimal. In AXCESS, hexadecimal numbers begin with a dollar sign ($).Therefore, the third example above shows $52, meaning “this number, 52, is ahexadecimal number.”

All three methods—letters, decimal ASCII codes, and hexadecimal ASCII

codes—can be used interchangeably. Feel free to use whichever method is easi-est for the task at hand.

Arrays and Strings

Page 110: Axcess Language Tutorial

100 Unit 5: Arrays, Strings, and Buffers

Integer arrays

So far, in all of the arrays you have seen, the range of values in each location iszero to 255. Recall that the range of values in a single variable is zero to 65,535,and when a value greater than 255 is assigned to an array location, the numberis truncated above 255. For instance, if the number 500 is assigned to a locationin an array, the actual number that is assigned is 244. (The way to find this is tokeep subtracting 256 from the number until the number is less than 256.)

So what if you need to create an array in which each location can contain val-ues greater than 255? The answer is to use an integer array. An integer array isjust like a normal array, except that each location can hold values from zero to65,535. To declare an integer array, simply place the keyword Integer in front ofthe array definition in the Define_Variable section. If you wanted your PRESETS

array to be an integer array, here is how you would declare it:

DEFINE_VARIABLEINTEGER PRESETS[6]

This declares an integer array with six locations; each location can hold valuesfrom zero to 65,535.

There are certain limitations of integer arrays. If an integer array is assignedto a normal array, all values are truncated above 255. (See the earlier discussionon truncating values.) This also happens if an integer array is sent to a deviceusing the keywords Send_String or Send_Command. There is no problem,however, in assigning a normal array to an integer array.

Integer array

An array where each location

can hold a value ranging from

zero to 65,535. Note that an

integer array will take up

twice as much AXCESS

memory than a normal array

of the same storage capacity

would.

Arrays and Strings

NOTE

If your array is only going to

hold alphanumeric values, do

not worry about making it an

integer array.

Page 111: Axcess Language Tutorial

101Unit 5: Arrays, Strings, and Buffers

C H A P T E R

15

Working with Arrays

Grouping data

The ability to group data into cohesive units (arrays) is one of the more powerfulfeatures of the AXCESS language. Thus there are many keywords to help you ma-nipulate arrays and strings. These keywords can be grouped into two classes:conversion keywords and array manipulation keywords.

Conversion keywords

There are five conversion keywords available:

• Itoa

• Itohex

• Atoi

• Upper_String

• Lower_String

The first three keywords serve to convert numbers—either as a constant, in avariable, or explicitly defined—into its string representation, and vice versa. Thelast two convert a string into all uppercase or all lowercase.

Itoa

Itoa, which is short for “integer to ASCII,” creates a string that represents thedecimal value of a number. Here are some examples:

DEFINE_CONSTANTCONST = 456

DEFINE_VARIABLESTR[5]VAR

DEFINE_PROGRAMVAR = 789STR = ITOA(123) (* STR = ‘123’ *)STR = ITOA(CONST) (* STR = ‘456’ *)STR = ITOA(VAR) (* STR = ‘789’ *)

Working with Arrays

Page 112: Axcess Language Tutorial

102 Unit 5: Arrays, Strings, and Buffers

The comment after each statement shows the value of the array STR after eachassignment. The length value of STR is set to 3 in each case, even though its stor-age capacity is 5.

Itohex

This keyword is short for “integer to hexadecimal.” Itohex works in the exactmanner as Itoa, except that the integer is transformed into a hexadecimal ASCII

string. If you substitute the Itoa keywords in the previous example with Itohex

keywords, this would be the result:

STR = ITOHEX(123) (* STR = ‘76’ *)STR = ITOHEX(CONST) (* STR = ‘1C8’ *)STR = ITOHEX(VAR) (* STR = ‘315’ *)

Notice that there are no dollar signs in the results. This is because the dollarsign indicates a numerical value expressed in hexadecimal, and is only usedwhen telling AXCESS that a number is hexadecimal.

Atoi

The Atoi keyword stands for “ASCII to integer” and does just that. It takes astring literal, string expression, or array as a parameter, and returns a single in-teger as the result. Here are some examples:

DEFINE_CONSTANTSTR1 = ‘456’STR2 = ‘YES789GO19’

DEFINE_PROGRAMNUM = ATOI('123') (* NUM = 123 *)NUM = ATOI(STR1) (* NUM = 456 *)NUM = ATOI(STR2) (* NUM = 789 *)

If the string contains all non-numeric characters (such as ‘HELLO’), Atoi re-turns the integer 0. However, if there are any numeric characters embeddedwithin the string, Atoi returns the first complete set it comes upon, as is the casewith STR2 above. Notice that only the first set of numbers from STR2 is returned.

Working with Arrays

NOTE

The three keywords Itoa,

Itohex, and Atoi automatically

set the length value of the

resulting string.

Page 113: Axcess Language Tutorial

103Unit 5: Arrays, Strings, and Buffers

Array manipulation keywords

There are a number of keywords at your disposal that allow you to manipulatearrays and to retrieve certain portions of an array:

• Left_String

• Mid_String

• Right_String

• Find_String

• Remove_String

Left_String

For this keyword, you must specify two parameters: the string or array you arereferencing and the number of characters you need. Left_String returns a stringcontaining the number of characters specified starting at the beginning of thestring. Here is an example:

STR = LEFT_STRING (PRESETS,3)

After execution of this line, the array STR will contain the first 3 characters ofthe array PRESETS. If PRESETS contains the string ‘HELLO,’ then STR will contain‘HEL.’ Also, the length value of STR will be set to 3.

Right_String

This keyword requires the same parameters as Left_String. However, Right_

String begins reading at the end of the string array for the specified amount ofcharacters. Assuming PRESETS still contains ‘HELLO,’ replacing Left_String inthe previous example with Right_String will assign the string ‘LLO’ to STR. Thiskeyword also will set the length value of the array receiving the result.

Mid_String

This keyword returns the specified amount of characters starting at a specifiedlocation in the source string. Three parameters, rather than two, are needed forits operation: the string to reference, the position at which to start, and the num-ber of characters to return. Here is an example:

STR = MID_STRING (PRESETS,2,3)

Working with Arrays

Page 114: Axcess Language Tutorial

104 Unit 5: Arrays, Strings, and Buffers

This line tells AXCESS: “Place three characters from the array PRESETS, startingat location 2 and moving to the right, into the array variable STR.” If PRESETS

contains ‘HELLO,’ this line will assign ‘ELL’ to the array STR. This keyword alsowill set the length value of the array receiving the result.

Finding strings

The keywords explained previously are helpful when you know where certainparts of strings are located within a string array. However, there will be manytimes when you have no idea where to look. In these cases, the Find_String key-word is used. This keyword will search through a string for a specified sequenceof characters. As soon as it finds a duplication of the sequence, it returns the be-ginning position of that duplication.

For example, suppose you don’t know the exact contents of the PRESETS ar-ray, but you want to find out if it contains the string ‘LO.’ Assume that PRESETS

contains ‘HELLO,’ and the following line is executed.

X = FIND_STRING (PRESETS,'LO',1)

When AXCESS executes this statement, it will search the array PRESETS fromthe beginning, looking for the string ‘LO.’ If AXCESS finds the substring, as in thiscase it will, it returns the starting position of the substring in the PRESETS array:in this case, 4. The third parameter (in this example, 1) tells AXCESS where in thestring to start the search.

Removing strings

The Remove_String keyword works much like the Find_String keyword. How-ever, when AXCESS finds the sequence it is looking for, it extracts every characterup to and including the sequence. All the other characters move up to fill in thespace. Here is an example:

DEFINE_VARIABLESOURCE[2Ø]DEST[2Ø]

DEFINE_PROGRAMSOURCE = ‘THIS IS A TEST’DEST = REMOVE_STRING (SOURCE,‘IS’,1)

Working with Arrays

Page 115: Axcess Language Tutorial

105Unit 5: Arrays, Strings, and Buffers

After the last line is executed, DEST will contain ‘THIS’ and SOURCE will con-tain ‘ IS A TEST.’ Notice that after the removal, the first location of the arraySOURCE contains a space. This is because Remove_String removed all charactersfrom the beginning of SOURCE up to and including the string ‘IS.’ It did not re-move the space following the string ‘IS’ in SOURCE. Also notice that the first oc-currence of ‘IS’ is embedded in the word ‘THIS.’ The length values of both arraysare set according to the results of the operation. In this case, the length value ofSOURCE is set to 4, and DEST is set to 10.

In Find_String, each of the first two parameters can be a string literal, stringexpression, or array. However, in the case of Remove_String, having anythingexcept an array as the first parameter makes no sense because AXCESS cannotremove part of a string literal or string expression, only an array variable. This isbecause string literals are constant values and string expressions may containconstant values. Once loaded into the Master Card, constant values cannot bechanged. Look at these examples:

STR = REMOVE_STRING(PRESETS,“12”,1) (* OK *)STR = REMOVE_STRING(“2,‘HELLO’,1Ø,13”,‘HELLO’,1) (* NO *)

Remember that Remove_String changes the first parameter after it removeswhatever characters it needs, and only variables can be changed at run time.Also remember to supply the starting position of the search as the third param-eter for both Find_String and Remove_String.

Uppercase vs. lowercase

When using Find_String and Remove_String, as well as when comparing twostring values, it is important to remember that such comparisons are case sensi-tive, which means that uppercase and lowercase values are not evaluated thesame. As you recall, the compiler is not case sensitive when it comes to key-words and identifiers. The compiler is case sensitive, however, when it comes tovalues inside single quotes (string literals). Here are some examples:

DEFINE_PROGRAMIdentifier_1 = 'Fred'Identifier_2 = 'FRED'

if (IDENTIFIER_1 = IDENTIFIER_2){

(* This will not be true because 'Fred' and 'FRED'are not the same. *)

}

Working with Arrays

Page 116: Axcess Language Tutorial

106 Unit 5: Arrays, Strings, and Buffers

Notice that the string literals ‘FRED’ and ‘Fred’ are not the same. However, inthe case of identifiers IDENTIFIER_1 and IDENTIFIER_2, AXCESS makes no differen-tiation based on the case of the letters making up the identifier name. Also no-tice that in this example the keyword If is not capitalized. This also makesabsolutely no difference to the AXCESS compiler.

Setting uppercase and lowercase

Within the AXCESS system, the lower case letter “a” is not the same as the upper caseletter “A.” Each has its own decimal ASCII code; the code for “a” is 97, and the codefor “A” is 65.

This could become a problem when, for example, your program compares anincoming string ABC against another:

IF (ABC = 'YES'){(* statement(s) *)}

If the incoming string is ‘YES,’ there is no problem. The statements are ex-ecuted as normal. However, what if ABC equals ‘Yes’? Since ‘YES’ and ‘Yes’ donot have the same decimal ASCII value, the statements below the If would notbe executed.

The solution is to change all incoming strings to either uppercase or lowercase.The keywords that do this are Upper_String and Lower_String. For example,the following statement could have been added before the preceding program:

ABC2 = UPPER_STRING(ABC)

The If statement can now compare ABC2 against ‘YES,’ providing that the Ifstatement reads IF (ABC2 = ‘YES’). The string ‘Yes’ is accepted since it hasbeen converted into uppercase.

As expected, Lower_String converts a string into lowercase in the same man-ner that Upper_String operates.

Working with Arrays

NOTE

When programming, you

may use whatever capitaliz-

ing scheme you wish. At

AMX, as a standard we

capitalize all keywords and

identifiers in the program.

Page 117: Axcess Language Tutorial

107Unit 5: Arrays, Strings, and Buffers

C H A P T E R

16

Using Buffers

Communicating to the outside world

One of the most powerful features of the AXCESS system is its ability to send andreceive any combination of values using RS-232, RS-422, PA-422, MIDI, and a varietyof other formats. You have the ability to construct any combination of numbersand characters with the string expression and send it to an external device. Inaddition, you can receive strings from external devices and interpret them toobtain useful information.

Receiving strings

Receiving strings requires several more steps than sending strings. To be able toreceive strings from a device, you must first create a buffer for that device. Abuffer is an array variable that is associated with a particular device for the pur-pose of storing information received from the device.

Creating buffers

To create a buffer, use the Create_Buffer keyword. This keyword can only ap-pear in the Define_Start section of your program, and it has the following syntax:

CREATE_BUFFER device, array

The Create_Buffer keyword directs AXCESS to place any data received from thespecified device into the specified array. When AXCESS places the byte into the

Figure 5-6

When data comes in from a

device, it goes into the spot

determined by the length

value of the array. Here, the

length value was 3. So the

‘Y’ is put into location 4, and

the length value is

incremented to 4.

Buffer

An array variable that is

associated with a particular

device for the purpose of

storing information sent by

the device.

IMPORTANT

Create_Buffer can only be

used within the Define_Start

section.

BUFFER

P L A Y O 10

Yfrom device

Using Buffers

Page 118: Axcess Language Tutorial

108 Unit 5: Arrays, Strings, and Buffers

array, it increments the length value for the array and then places the byte intothe array at the current end of the array. See Figure 5-6 for a pictorial explanation.

Even though the array is acting as a buffer, it is still an array and can betreated as one. You can still access the individual locations, send it to a device,assign it to other arrays, assign other arrays to it, as well as use the array ma-nipulation keywords discussed in the previous chapter.

Storing characters

When a device sends string information to the Master Card, the Master Cardplaces the incoming information into the buffer created for that device, and up-dates the buffer’s length value. (Remember, a buffer is an array.) These actionsare executed after the Master Card has passed through mainline. Since all datagoing in and out of these devices is serial (that is, one byte at a time), each byteis handled one at a time.

If the buffer is full when a character needs to be inserted into it, AXCESS dropsthe first character, shifting the contents of the buffer left in order to insert the newcharacter at the end of the buffer. See Figure 5-7 for a diagram showing this action.

Retrieving characters

This is where the keyword Get_Buffer_Char comes into play. This keyword hasa two-part operation:

• First, it retrieves the first character in the buffer for your own utilization.This creates the same effect as if you retrieved the first storage location of anormal string array.

Using Buffers

BUFFER

C O N T R O

from device

C

O N T R O

dropped

L

L

Figure 5-7

Inserting a character into a

full buffer causes the first

character to be dropped.

NOTE

A buffer is said to be “full”

when its length value is equal

to its storage capacity.

Page 119: Axcess Language Tutorial

109Unit 5: Arrays, Strings, and Buffers

• Second, it removes that character from the buffer, causing all the othercharacters to shift up one place. The second character is now the first, thethird is now the second, and so on.

Here is the syntax of this keyword:

string = GET_BUFFER_CHAR (array)

The parameter passed to Get_Buffer_Char must be an array, but does not needto be a buffer. (Remember: All buffers are arrays, but not all arrays are buffers.)The statement will operate identically in either case. The result must be a simplevariable (not an array), because one and only one character will ever be returned.

In these examples, you will create an array called BUFR with a capacity of tencharacters. Then you will make it a buffer associated with a device named RS232.

DEFINE_VARIABLEBUFR[1Ø]CHAR

DEFINE_STARTCREATE_BUFFER RS232,BUFR

Now all string data sent to the Master Card from the device RS232 will gointo the array BUFR, as described earlier. Now, suppose you want to get thedata out of the buffer as soon as it enters. This is usually a two-step process.Here is an example:

IF (LENGTH_STRING (BUFR))CHAR = GET_BUFFER_CHAR (BUFR)

These two lines of code are actually one statement: an If statement. The condi-tion of the If is the result of the Length_String keyword; if there are not anycharacters in the buffer (length value of BUFR is zero), then AXCESS will skip thesecond part of the statement. The second part, which will be executed if thereare one or more characters in BUFR, tells AXCESS to get the first character in BUFR

place it into the variable CHAR. This process is diagrammed in Figure 5-8.

Using Buffers

Page 120: Axcess Language Tutorial

110 Unit 5: Arrays, Strings, and BuffersUsing Buffers

BUFR

A X C E S S

A

X C E S S

GET_BUFFER_CHAR (BUFR)

CHAR

LENGTH_STRING = 6

LENGTH_STRING = 5

Figure 5-8

Getting the next character

out of a buffer with

Get_Buffer_Char.

Characters should be continuously retrieved and removed from the buffer sothat incoming strings have spaces to completely enter. Be sure to place aGet_Buffer_Char statement in a position to do this. Remember, the AXCESS sys-tem is constantly running through the main program, and AXCESS will executethe Get_Buffer_Char statement as long as it is in its path of execution.

Clearing a buffer

AXCESS provides a single keyword which clears a buffer: Clear_Buffer. Here ishow it is used:

CLEAR_BUFFER BUFR

This keyword effectively sets the length of the buffer to zero, so that subse-quent Get_Buffer_Char statements will not return anything. Using Clear_Bufferis preferable to other methods, such as assigning a null string to the buffer, orusing Set_Length_String. The Clear_Buffer keyword actually compiles intosmaller code and executes faster than the other methods, plus it is clearer to thereader as to what the programmer is trying to accomplish.

BUZZWORD

A null string is simply an

empty set of single quotes,

which represents a string

literal with no content and a

length value of zero.

Page 121: Axcess Language Tutorial

111Unit 5: Arrays, Strings, and Buffers

C H A P T E R

17

Two-Dimensional Arrays

Powerful grouping

In the previous two chapters, you learned how to group data into arrays andhow to manipulate those arrays as single units. In this chapter, you will see howto group multiple arrays together into one two-dimensional array. Using two-dimensional arrays provides even greater flexibility and power for the morecomplex applications.

The anatomy of the two-dimensional array

To understand the structure of the two-dimensional array you must refer backto the basic single variable. A variable holds one and only one value at a time.Using arrays, you can create a variable that can hold many values, and you ref-erence the value you want with an index value. In this way, you are able to per-form many programming feats such as storing several related values andaccessing a particular one.

The two-dimensional array expands on the one-dimensional array in the sameway that the one-dimensional array expands on the simple variable: it holdsmultiple one-dimensional arrays which can be referenced with an index value.Here’s how you declare a two-dimensional array:

DEFINE_VARIABLENAMES[1Ø][3Ø]

Two-dimensional

array

A storage place holding

multiple one-dimensional

arrays.

NAMES

Entire row is NAMES[3]

Single location isNAMES[3][6]

Figure 5-9

The structure of a two-

dimensional array.

Two-Dimensional Arrays

Page 122: Axcess Language Tutorial

112 Unit 5: Arrays, Strings, and Buffers

Notice how this declaration differs from the one-dimensional array. Instead ofa single storage capacity value, there are two. Here’s how to interpret this vari-able declaration: “NAMES is a two-dimensional array that can hold 10 one-di-mensional arrays, each with a storage capacity of 30 characters.” The total storagecapacity of NAMES is 10 characters by 30 characters, for 300 characters total. Thevariable NAMES might be used to store up to 10 names, each with a maximumlength of 30 characters. Figure 5-9 depicts the structure of the array NAMES.

Storing values

The method of storing values into a two-dimensional array is basically the sameas that of a one-dimensional array. You can assign values to individual loca-tions; you can assign one-dimensional arrays, string literals, and string expres-sions to one of the one-dimensional arrays inside the two-dimensional array;and you can assign entire two-dimensional arrays to other two-dimensional ar-rays. Here is a small program as an example:

DEFINE_VARIABLENAMES[1Ø][3Ø] (* two-dimensional array *)PEOPLE[8][2Ø] (* another two-dimensional array *)ONE_NAME[3Ø] (* one-dimensional array *)A_VALUE (* single-value variable *)

DEFINE_PROGRAMA_VALUE = 1Ø (* 1 *)ONE_NAME = 'EMMITT SMITH' (* 2 *)NAMES[1][1] = 6 (* 3 *)NAMES[1][2] = A_VALUE (* 4 *)NAMES[2] = 'TROY AIKMAN' (* 5 *)NAMES[3] = "1,2,ONE_NAME,3" (* 6 *)

Figure 5-10 depicts what the two-dimensional array NAMES will look like afterthis code is executed.

Each row in the two-dimensional array has a length value just like a one-di-mensional array. When a string literal or string expression is assigned to a rowof a two-dimensional array (see statements 5 and 6 in the above example), thatrow has its length value set in the same manner as a one-dimensional arraydoes. The Length_String and Set_Length_String functions operate on rows intwo-dimensional arrays in the same way as whole one-dimensional arrays. As-suming that the above example has executed, here is what the Length_String

function returns on the first three rows of NAMES:

NOTE

A two-dimensional array can

be declared with the Integer

keyword, just like a one-

dimensional array can. This

allows values in the range

zero to 65,535 to be

assigned to locations within

the two-dimensional array.

Two-Dimensional Arrays

Page 123: Axcess Language Tutorial

113Unit 5: Arrays, Strings, and Buffers

NAMES

6 10

T R

1 2

O

E

Y

M

X

M

A

I

I

T

K

T

M

X

A

S

N

M I T H 3

Figure 5-10

The two-dimensional array

NAMES after the assign-

ments.

Two-Dimensional Arrays

X = LENGTH_STRING (NAMES[1]) (* X will contain Ø *)

X = LENGTH_STRING (NAMES[2]) (* X will contain 11 *)

X = LENGTH_STRING (NAMES[3]) (* X will contain 15 *)

As you can see, it helps to think of a two-dimensional array as an array ofone-dimensional arrays.

Retrieving values

Retrieving values from a two-dimensional array is done in the same manner as aone-dimensional array. Recall that there are two ways of referencing data in aone-dimensional array: referencing a single value inside the array, and referenc-ing the entire array. When using a two-dimensional array, there are three waysof referencing the contents:

• By “cell” (single values)

• By “row” (an array of values)

• As a whole

Single locations (or “cells”) are retrieved by using two index values, the firstspecifying the row and the second specifying which location in that row. Here isan example:

VALUE = NAMES[3][6]

BUZZWORD

The term “cell” is often used

to refer to one particular

location in a two-dimensional

array.

Page 124: Axcess Language Tutorial

114 Unit 5: Arrays, Strings, and Buffers

This line of code takes whatever value is in the sixth location of the third rowin the two-dimensional array NAMES, and assigns it to the variable VALUE. In thecontext of the previous examples, VALUE will now contain an ‘E.’

Retrieving a whole row from a two-dimensional array is done in the sameway, except only the first index value is used. The index value will indicate therow that is to be retrieved, and the length value for that row determines howmany locations from the row are actually retrieved. For instance:

ONE_NAME = NAMES[2]

After this line is executed, the array ONE_NAME will contain the string ‘TROY

AIKMAN,’ and its length value will be 11. If you were to try to retrieve the entirefirst row, nothing would be returned because its length value is zero.

The third method of accessing a two-dimensional array is to assign it to an-other two-dimensional array:

PEOPLE = NAMES

This will copy the entire contents of NAMES into PEOPLE, regardless of the indi-vidual rows’ length values. Making an assignment like this copies the entire con-tents of the two dimensional array, including the rows’ length values.PEOPLE[2] will contain ‘TROY AIKMAN’ and have a length value of 11, just likeNAMES[2].

If you go back to the original example, however, you will notice that the two-dimensional array PEOPLE is defined with a size 8 by 20, whereas NAMES is 10by 30. When AXCESS performs a copy from a two-dimensional array into asmaller one, any information that falls “outside” the ranges of the smaller arrayis not copied.

Two-Dimensional Arrays

Page 125: Axcess Language Tutorial

UNIT 6

ADVANCEDAXCESSPROGRAMMING

AXCESS Language Tutorial

Page 126: Axcess Language Tutorial
Page 127: Axcess Language Tutorial

Unit 6: Advanced AXCESS Programming 117

C H A P T E R

18

Using Subroutines

Subroutine

A section of code that

stands alone and can be

”called” from anywhere else

in the program.

Using Subroutines

Introduction

By now you should have a firm grasp of the basics of AXCESS programming.Now you will delve into some more complex topics such as using subroutines,creating local variables, and passing parameter. With these tools, you will beable to tame complex systems with a relatively small amount of code.

Subroutines

There is a way to break the program into smaller, more manageable parts calledsubroutines. A subroutine is a section of code that stands alone and can be“called” from anywhere else in the program.

You may create subroutines for a variety of reasons. The most common usageof subroutines is to execute the same group of instructions from different placesin the program. Using a subroutine to do this means that you don’t have to re-typethose instructions over and over in the program—you can just call the subroutine.

Defining a subroutine

In AXCESS, subroutines are created using the Define_Call statement. Enclosed insingle quotes, the subroutine name follows the Define_Call keyword. There arecertain restrictions for these subroutine names:

• They cannot be previously defined contents or variables.

• They cannot be names that have already been assigned to buffers or Waits.

• They are case-sensitive. ‘Test’ and ‘TEST’ are not the same.

Subroutines must be defined before they can be used. For this reason,Define_Calls are usually found right before the Define_Start section of the pro-gram. For example:

DEFINE_CALL ‘LIGHTS OFF’{

(* the subroutine goes here *)}

Page 128: Axcess Language Tutorial

118 Unit 6: Advanced AXCESS ProgrammingUsing Subroutines

DEFINE_START(* startup code goes here *)

DEFINE_PROGRAM(* the main program starts here *)

Spaces in the subroutine name are allowed since it is a string literal. Noticethat the subroutine’s code is enclosed in braces. No matter how long the subrou-tine is, it must be in this format.

Calling your subroutines

In order to tell AXCESS to execute a subroutine, use the Call keyword and the nameof the subroutine in single quotes. For example, in order to execute the previ-ous subroutine you would type the following where you want the Call to occur.

CALL ‘LIGHTS OFF’

When AXCESS executes the Call, program execution “jumps” to the first lineinside the braces of the Define_Call. The subroutine is executed only once, andthen AXCESS returns to the statement directly following the Call statement.

Sample program

Now you will look at a complete example program using a subroutine. Here arethe basic requirements for the program:

• The devices used are four infrared/serial cards and an AMX TX Serieswireless (radio frequency) remote controller. The device numbers are 1, 2, 3,4, and 128, respectively. The infrared/serial cards will transmit infraredcode to three different VCRs and a video projector.

• The TX transmitter will have three buttons. Here are the functions to beassociated with each button:

Button 1: Projector to input 1, stop all VCRs, wait 5 seconds, play VCR 1.

Button 2: Projector to input 2, stop all VCRs, wait 5 seconds, play VCR 2.

Button 3: Projector to input 3, stop all VCRs, wait 5 seconds, play VCR 3.

This code listing is from

STEP8.AXS on the AXCESS

distribution diskette.

Page 129: Axcess Language Tutorial

Unit 6: Advanced AXCESS Programming 119

This is the actual program:

DEFINE_DEVICEVCR1 = 1VCR2 = 2VCR3 = 3VPROJ = 4RADIO = 128

DEFINE_CONSTANT(* COMMON TRANSPORT CONSTANTS *)PLAY = 1STOP = 2PAUSE = 3FFWD = 4REWIND = 5

DEFINE_VARIABLEWHICH_VCR (* This will hold which VCR and input

is selected *)CALL_ACTIVE (* This will be on while the Call is

waiting to play the VCR *)

DEFINE_CALL ‘DO SWITCH’{

CALL_ACTIVE = 1PULSE [VPROJ,WHICH_VCR+1Ø]PULSE [VCR1,STOP]PULSE [VCR2,STOP]PULSE [VCR3,STOP]WAIT 5Ø PULSE [WHICH_VCR,PLAY]WAIT 6Ø CALL_ACTIVE = Ø

}

DEFINE_STARTCALL_ACTIVE = Ø

DEFINE_PROGRAMPUSH[PANEL,1]{

IF (NOT CALL_ACTIVE){

WHICH_VCR = VCR1CALL ‘DO SWITCH’

}}

PUSH[PANEL,2]{

IF (NOT CALL_ACTIVE){

WHICH_VCR = VCR2CALL ‘DO SWITCH’

}}

Using Subroutines

Page 130: Axcess Language Tutorial

120 Unit 6: Advanced AXCESS Programming

PUSH[PANEL,3]{

IF (NOT CALL_ACTIVE){

WHICH_VCR = VCR3CALL ‘DO SWITCH’

}}

Here is the program explained step-by-step:

DEFINE_DEVICEVCR1 = 1VCR2 = 2VCR3 = 3VPROJ = 4RADIO = 128

This section defines the five devices used in the program.

DEFINE_CONSTANT(* COMMON TRANSPORT CONSTANTS *)PLAY = 1STOP = 2PAUSE = 3FFWD = 4REWIND = 5

This section defines the common locations in the IR cards for the transportfunctions PLAY through REWIND.

DEFINE_VARIABLEWHICH_VCRCALL_ACTIVE

The variable WHICH_VCR will hold the selected VCR/input number.CALL_ACTIVE tells whether or not the subroutine is waiting to tell the VCR toplay. If its value is zero, the subroutine is not waiting; if the value is 1 orgreater, the Waits in the subroutine are still pending.

DEFINE_STARTCALL_ACTIVE = Ø

Using Subroutines

Page 131: Axcess Language Tutorial

Unit 6: Advanced AXCESS Programming 121

When the system is turned on or reset, this will initialize CALL_ACTIVE to zero.

DEFINE_CALL ‘DO SWITCH’{

This begins the subroutine. Notice that the sequence must begin with a braceno matter how long the subroutine is.

CALL_ACTIVE = 1

The first statement of the subroutine turns CALL_ACTIVE on. In this programCALL_ACTIVE acts as a “flag” to let the rest of the program know that the Waitsinside the subroutine are still pending, and the subroutine is not to be re-acti-vated until the Waits are finished.

PULSE [VPROJ,WHICH_VCR+1Ø]PULSE [VCR1,STOP]PULSE [VCR2,STOP]PULSE [VCR3,STOP]WAIT 5Ø PULSE [WHICH_VCR,PLAY]

This section is the heart of the Define_Call. The first statement Pulses thefunction on the video projector’s controller card corresponding to the input de-sired on the projector. A little trick was used here: since the functions on IR cardsfor video projectors have the switcher inputs located at 11–20, you can simplyadd 10 to the desired input number to obtain the needed IR function number. Forinstance, if WHICH_VCR contains 2—meaning you selected VCR number 2 andinput number 2 on the projector—the first Pulse statement will activate func-tion 12, which (on video projector cards) is usually the input 2 Select function.

The next three Pulses stop all three VCRs, and then a Wait is started with atime of five seconds. When this Wait is over, AXCESS will Pulse the Play functionon the VCR whose device number equals WHICH_VCR.

WAIT 6Ø CALL_ACTIVE = Ø}

Using Subroutines

BUZZWORD

A “flag” is a variable that is

used to store an on or off

state.

Page 132: Axcess Language Tutorial

122 Unit 6: Advanced AXCESS Programming

Six seconds after the subroutine is called, CALL_ACTIVE is reset to zero. Thiswill create a one half-second delay between the end of the Play Pulse and the“unlocking” of the subroutine. Thus, six seconds after being called, the subrou-tine can be safely re-activated again.

DEFINE_PROGRAMPUSH[PANEL,1]{

IF (NOT CALL_ACTIVE){

WHICH_VCR = 1CALL ‘DO SWITCH’

}}

The main program starts here. The code inside each Push first checks to see ifthe subroutine is busy by checking CALL_ACTIVE with an If statement. If the flagis not on, the code sets WHICH_VCR to the desired VCR number and projector in-put number, and then calls ‘DO SWITCH.’ This is repeated for each button.

You may realize that the value assigned to the variable WHICH_VCR in eachPush is equivalent to the channel in the Push statement. Since this is true, thethree button presses could be combined into one section like this:

DEFINE_PROGRAMPUSH[PANEL,1]PUSH[PANEL,2]PUSH[PANEL,3]{

IF (NOT CALL_ACTIVE){

WHICH_VCR = PUSH_CHANNELCALL ‘DO SWITCH’

}}

This works great for control panels with buttons positioned sequentially, butnot so well if the buttons’ channel codes are not sequential. Since you will buildon this program in the upcoming chapters, leave the section as three separatePushes.

Using Subroutines

BUZZWORD

When flags are used to

disable events in this way, it

is called “locking” or “locking

out.” When the flag is turned

off, the event or code is

“unlocked.”

Page 133: Axcess Language Tutorial

Unit 6: Advanced AXCESS Programming 123

C H A P T E R

19

Local Variables and Parameters

More power for your subroutines

Two features which expand on the functionality of subroutines are local variablesand parameters. Using these features can help simplify your programs, add morepower to your code, and make your program easier to read and understand.

Local variables

The first of these two features is the local variable. A local variable is a variablewhich is declared inside a Define_Call and can only be used inside that sameDefine_Call. Variables declared in the main Define_Variable section are calledglobal variables. The words “local” and “global” refer to a variable’s scope, whichis the part of the program that can access the variable. Global variables haveglobal scope; that is, the entire program has access to them. A local variable haslocal scope, and can only be accessed inside the Define_Call in which it is de-clared. Here is an example of a local variable declaration:

DEFINE_CALL ‘TEST CALL’LOCAL_VAR

LOC_VARLOC_ARRAY[1Ø]

{LOC_VAR = 1LOC_ARRAY = ‘TESTING’

}

This section of code defines the subroutine ‘TEST CALL.’ It then declares two localvariables, LOC_VAR (a simple variable) and LOC_ARRAY (an array with a storagecapacity of 10.) Local variables are defined after the Define_Call and before thefirst open brace, with the keyword Local_Var preceding the block of local vari-ables defined. Nowhere else in the entire program can any code access the twovariables LOC_VAR and LOC_ARRAY; they are local to the subroutine ‘TEST CALL.’

A local variable can have the same name as a local variable in another sub-routine. If another subroutine declares a local variable LOC_VAR, that subrou-tine will use its LOC_VAR and ‘TEST CALL’ will use its own LOC_VAR. A localvariable can also have the same name as a global variable. If this happens, thelocal variable takes precedence in its scope; the global variable is hidden. For

Local Variables and Parameters

Local variable

A variable declared in a

subroutine, and whose

scope is limited to that

subroutine.

Global variable

Any variable defined in the

Define_Variable section of

the program. The scope of

these variables extends

throughout the entire

program.Scope

The part of the program

where the variable can be

accessed. A variable has

global scope if the entire

program has access to it; a

variable has local scope if

only a section of the program

has access to it.

NOTE

A global variable is said to be

hidden if a local variable of

the same name is in scope.

Page 134: Axcess Language Tutorial

124 Unit 6: Advanced AXCESS Programming

instance, if in the previous example there was a global variable LOC_VAR, thereference in the subroutine still refers to the local variable. In this case the glo-bal LOC_VAR is hidden from the subroutine.

Local variables are best used in cases where a subroutine needs to use a vari-able, but no other piece of code needs it. Such variables are usually temporaryflags, loop counters, and other variables a subroutine may need to do its work.A well-organized program may even have more local variables than global vari-ables, because the main work of the program is handled mostly by subroutinesrather than the main program.

Parameters

Several AXCESS keywords and functions use parameters, such as Atoi andMid_String. Your Define_Call subroutines can also use parameters. Parametersare variables defined as part of the Define_Call declaration that can receive val-ues from and pass back values to the Call statement that called the subroutine.Here is a subroutine declaration using parameters:

DEFINE_CALL ‘DO SWITCH’ (INPUT,OUTPUT){

SEND_STRING SWITCHER, “’I’, ITOA(INPUT), ‘O’,ITOA(OUTPUT)”

}

This subroutine is defined as having two parameters, INPUT and OUTPUT (en-closed in parentheses), which are essentially local variables of the subroutine.These variables, however, have their initial values set by the parameters in theCall statement which called the routine. Here is a Call to this subroutine:

CALL ‘DO SWITCH’ (3,7)

This calls the subroutine ‘DO SWITCH,’ and assigns the value 3 to INPUT and 7to OUTPUT. The subroutine uses a string expression to construct the string ‘I3O7’and then sends the string to the card named SWITCHER. This shows the powerof using parameters. Later in the program, the same subroutine can be usedwith different parameters to produce different strings. Here are some examples:

CALL ‘DO SWITCH’ (1,2) (* sends ‘I1O2’ *)

CALL ‘DO SWITCH’ (2,12) (* sends ‘I2O12’ *)

CALL ‘DO SWITCH’ (1Ø,2Ø) (* sends ‘I1ØO2Ø’ *)

Local Variables and Parameters

Page 135: Axcess Language Tutorial

Unit 6: Advanced AXCESS Programming 125Local Variables and Parameters

Passing values back to the caller

A parameter variable can be modified inside a subroutine just as any other typeof variable. After all code in the subroutine has been executed and beforeAXCESS returns to the caller, AXCESS attempts to copy the values in the param-eter variables back into the caller’s parameters. This is only successful if thesubroutine is called with variables in the Call statement. Here is an example:

DEFINE_CALL ‘SQUARE’ (NUMBER){

NUMBER = NUMBER * NUMBER}

X = 5

CALL ‘SQUARE’ ( X )(* X now equals 25 *)

CALL ‘SQUARE’ ( X )(* X now equals 625 *)

When the subroutine SQUARE is called with a variable as a parameter (in thiscase X), a series of events occurs.

• The value of the variable (in this case, 5) is assigned to NUMBER.

• The subroutine takes the parameter, multiplies it by itself (thus squaring it)and assigns the result back to itself.

• AXCESS then re-assigns NUMBER back to the variable X, so that upon returnfrom the subroutine, X will contain its previous value squared.

If, however, a constant value is passed to the routine, a re-assignment cannotbe made. For example:

CALL ‘SQUARE’ ( 5 )

This will assign the value 5 to the parameter variable NUMBER in the subrou-tine, and NUMBER will be squared. However, AXCESS cannot take the value inNUMBER and re-assign it to the constant value 5. Calling a routine in which a pa-rameter is expected to return some sort of result should not be called with a con-stant value as that parameter. If you want to use a constant value as a parameterto this subroutine and still get a new value returned, rewrite the Define_Call tohave two parameters:

BUZZWORD

The “caller” refers to the Call

statement that called the

subroutine.

Page 136: Axcess Language Tutorial

126 Unit 6: Advanced AXCESS ProgrammingLocal Variables and Parameters

DEFINE_CALL ‘SQUARE’ (NUMBER,RESULT){

RESULT = NUMBER * NUMBER}

Here are some examples of using this subroutine:

CALL ‘SQUARE’ (5,X)(* on return, X will contain 25 *)

CALL ‘SQUARE’ (X,Y)(* on return, X will contain 25 and Y will contain 625 *)

It is important to note that the re-assignment of the parameter variable to thecaller’s variable happens after the subroutine is finished and before any othercode is executed. This fact could lead to a very-hard-to-find bug:

DEFINE_VARIABLEGLOBAL

DEFINE_CALL ‘BUGGY’ (PARAM){

PARAM = 1ØGLOBAL = 2Ø

}

DEFINE_PROGRAM

GLOBAL = 5CALL ‘BUGGY’ (GLOBAL)(* What will GLOBAL contain here? *)

You might expect GLOBAL to contain 20 when AXCESS reaches the comment.However, this is not the case. In the subroutine BUGGY, after GLOBAL is set to 20,AXCESS re-assigns the value in PARAM to the variable in the Call statement whichcalled BUGGY—in this case GLOBAL. The parameter variable PARAM contains thevalue 10 at the end of the subroutine, and this value is re-assigned to the vari-able in the Call statement: GLOBAL. In the end, GLOBAL will contain the value 10at the comment.

Page 137: Axcess Language Tutorial

Unit 6: Advanced AXCESS Programming 127

C H A P T E R

20

Include Files and System_Calls

Managing large programs

In this chapter, two advanced features of AXCESS will be introduced: includefiles and System_Calls. These two features are important in managing largeprograms and in simplifying basic programming. Include files allow you tobreak a large program into smaller, more manageable files. System_Calls pro-vide ready access to “pre-canned” programming solutions and tools, withouthaving to rewrite them.

Include files

Most of the time, your program will reside in a single file. AXCESS program filesare saved with a DOS extension of “AXS.” When you compile your program,AXCESS compiles it in the computer’s memory, and when you save your pro-gram, AXCESS saves it to disk using this extension.

Sometimes, however, a program may grow to be too large to fit into yourcomputer’s memory all at once. In such a case, it is possible to break the pro-gram up into multiple files. This is done by taking portions of your program andputting them into one or more include files. An include file is a DOS file which isincluded in the compiling process without having to reside in the computer’smemory. Include files always have the DOS extension “AXI.”

To include a file in a program, use the keyword Include, followed by thefilename in single quotes. Here is an example:

DEFINE_PROGRAM

(* Program statements can go here *)

INCLUDE ‘TEST.AXI’

(* More program statements can go here *)

When the compiler reaches the Include statement, it “jumps” into the speci-fied file and continues compiling. When it has reached the end of the file, itcomes back to the line following the Include statement and continues compiling.See Figure 6-1 for a pictorial explanation.

Include file

A DOS file which is included

in the compiling process

without having to reside in

the computer’s memory.

Include Files and System_Calls

Page 138: Axcess Language Tutorial

128 Unit 6: Advanced AXCESS ProgrammingInclude Files and System_Calls

AXCESS main program(in computer memory)

#INCLUDE ‘TEST.AXI’Include file TEST.AXI

(on disk)

Figure 6-1

Compilation flow using an

include file.

The code compiled in the include file is compiled just as if it were in the mainprogram where the Include statement is located. The Include statement can ap-pear anywhere in your program, since it is actually a statement to the compilerand not the AXCESS control system. What you decide to put into include files isup to you. Here are several suggestions on their use in large programs:

• Place each definition section in its own include file

• Group sections of the main program into include files

• Place all subroutines into an include file

• Place routines that you want to share between multiple programs into aninclude file

• Place code you wish to re-use in other systems into include files

This by no means is a comprehensive nor mandatory list of how to organizeyour programs, but simply some suggestions to get you started toward biggerand better system programming.

Include files are loaded and edited using the AXCESS editor much like normalprogram files (see Unit 1). Like program files, the AXCESS name (not the DOS

name) of the include file is stored on the first line of the file as a Program_Namedeclaration.

Page 139: Axcess Language Tutorial

Unit 6: Advanced AXCESS Programming 129

System_Calls and library files

Using include files makes it very easy to share already-written code betweenmultiple programs. For instance, suppose you had created a subroutine tohandle a certain audio/video switcher, and you saved the subroutine into aninclude file. When you need to use the subroutine in another program, you sim-ply include the file into your program and bingo, you have a pre-written pieceof code ready for use.

This is where library files come in. Library files are actually special types ofinclude files which have the DOS extension “LIB.” The difference between theseand include files is that these files must contain a Define_Call subroutine havingthe same name as the Program_Name on the first line of the library file. ThisDefine_Call can then be called from within a program using the System_Call

keyword. Here is a small example library file listing:

PROGRAM_NAME = ‘SQUARE’

DEFINE_CALL ‘SQUARE’ (NUMBER){

NUMBER = NUMBER * NUMBER}

This is the entire contents of a library file. Now if you have a variable X whichyou want to square within a program, use the following line:

SYSTEM_CALL ‘SQUARE’ (X)

This line generates a call to the subroutine SQUARE. This is because aSystem_Call statement is identical to a Call statement, except that the actualDefine_Call is in a library file instead of the main program.

After AXCESS compiles the main program, it searches through all availablelibrary files for the one that has the following statement on the first line:

PROGRAM_NAME = ‘SQUARE’

When AXCESS finds this file, it is compiled. Since the library file contains aDefine_Call with the same name as the Program_Name in the file, theSystem_Call to SQUARE actually calls the Define_Call SQUARE in this libraryfile. See Figure 6-2.

Include Files and System_Calls

Library file

A special file containing

AXCESS program code.

These files are used only for

System_Calls.

This is the file SQUARE.LIB

on your AXCESS distribution

diskette.

Page 140: Axcess Language Tutorial

130 Unit 6: Advanced AXCESS Programming

Library file

PROGRAM_NAME = ‘SQUARE’DEFINE_CALL ‘SQUARE’ (NUMBER){ NUMBER = NUMBER * NUMBER}

AXCESS main program

SYSTEM_CALL ‘SQUARE’ (X)

When using System_Calls, you do not have to implicitly include the file withthe subroutine you wish to use because AXCESS automatically does this for you.In essence, the System_Call is almost like the Include and Call keywordsbundled into one keyword.

Factory System_Calls

AMX has written a number of System_Calls to handle many of the most commonprogramming requirements in AXCESS systems. These library files are includedon the AXCESS distribution diskette. The System_Calls are divided into severalcategories including VCRs, switchers, laser discs, and others. Factory System_

Calls follow a standard naming convention, and the System_Calls in each grouptake the same parameters. See Figure 6-3 for descriptions of these two standards.

The main goal of these System_Calls is to maintain a consistent “look andfeel” for the control panels, regardless of how the deck behaves from its ownremote control. For instance, when some VCRs are in the pause mode, pressingPause again will cause the deck to play, whereas on other VCRs, pressing Pauseagain does nothing. However, when using a VCR System_Call, pressing Pauseon the control panel while the deck is in pause mode will always cause the deckto play. This is because the different VCR System_Calls were written to take into

Include Files and System_Calls

Figure 6-2

The compilation order of a

library file.

BUZZWORD

The “look and feel” of

something refers to how it

interacts with the user. In the

case of control panels, this

refers to how a device reacts

when certain buttons are

pressed, and what kind of

feedback the user receives.

This is also called the “user

interface.”

Page 141: Axcess Language Tutorial

Unit 6: Advanced AXCESS Programming 131Include Files and System_Calls

account the different behaviors of VCRs. Therefore, no matter what type ormodel of equipment is being used, the behavior of the buttons on the controlpanel will not change. See the AXCESS Programming Guide for a detailed de-scription of the “look and feel” of the various factory System_Calls.

The instance number and name mangling

A System_Call can be called more than once in a single program. Take a look atthis example that uses the SQUARE System_Call:

DEFINE_VARIABLENUM1NUM2

DEFINE_PROGRAM

NUM1 = 5NUM2 = 6SYSTEM_CALL ‘SQUARE’ (NUM1)SYSTEM_CALL ‘SQUARE’ (NUM2)

Figure 6-3

A list of pre-written

System_Calls for your use.

Switcher

SLD PANEL, FORWARD, REVERSE, FOCUS_IN, FOCUS_OUT, POWER, DEVICE

Factory System_Calls

Device type

VCR VCR

System_Call*

PANEL, PLAY, STOP, PAUSE, FFWD, REWIND, SRCH_FWD, SRCH_REW, RECORD, DEVICE

Parameters required

Cassette deck CAS PANEL, PLAY, STOP, PAUSE, FFWD, REWIND, SRCH_FWD, SRCH_REW, RECORD, DEVICE

Laser disc player LDP PANEL, PLAY, STOP, PAUSE, SKIP_FWD, SKIP_REV, SCAN_FWD, SCAN_REW, DEVICE

Compact disc player CDP PANEL, PLAY, STOP, PAUSE, SKIP_FWD, SKIP_REV, SCAN_FWD, SCAN_REW, DEVICE

Slide projector

SWT INPUT, OUTPUT, LEVEL, DEVICE

Other Varies Varies

* There is a complete set of System_Calls for each type of device. Following the first three letters of the System_Call name is a number. For instance: System_Call ‘VCR3.’

Page 142: Axcess Language Tutorial

132 Unit 6: Advanced AXCESS Programming

This code generates two calls to the subroutine SQUARE in the library file, butit only includes and compiles the library file once. The two System_Calls call thesame routine. This is fine for most System_Calls, but there are occasions wherethis could cause problems.

To illustrate this, make a new library file which has Wait statements in its sub-routine. Here is a listing:

DEFINE_CALL ‘SEND’ (STR1[1Ø],STR2[1Ø],CARD ){

SEND_STRING CARD, STR1WAIT 2Ø ‘SS WAIT’

SEND_STRING CARD, STR2}

This subroutine takes three parameters. The purpose of the subroutine is tosend the two strings to the device specified in the parameter variable CARD, witha delay of two seconds between sends.

The following line will send the string ‘AMX,’ followed two seconds later bythe string ‘AXCESS’ to card number 3:

SYSTEM_CALL ‘SEND’ (’AMX’,‘AXCESS’,3)

This code compiles and works fine. But what happens when you add anotherSystem_Call to the program?

SYSTEM_CALL ‘SEND’ (’AMX’,‘AXCESS’,3)SYSTEM_CALL ‘SEND’ (’GOOD’,‘TIMES’,5)

Only one Define_Call SEND is compiled, and both of these lines call the samesubroutine. The first call sets the routine’s STR1, STR2, and CARD parameter vari-ables, sends the string ‘AMX’ to device 3, and starts the named Wait. The nextSystem_Call resets the parameter variables to all new values, and sends thestring ‘GOOD’ to card 5. Since the Wait is already in the wait list, however, it isnot restarted. Thus when the Wait comes due, it will use the latest values storedin the parameter variables CARD and STR2. In this case, CARD will still be 5 andSTR2 will contain the string ‘TIMES,’ so ‘TIMES’ is sent to device number 5.

Include Files and System_Calls

Page 143: Axcess Language Tutorial

Unit 6: Advanced AXCESS Programming 133

Notice that the string ‘AXCESS’ is never sent to card 3. This is because theSTR2 parameter variable in the subroutine is overwritten by the secondSystem_Call before the Wait comes due. This is the problem with using Waits

in System_Call subroutines.There is a way to get around this, however. By using an instance number, you

can force the compiler to compile two separate copies of the subroutine. Here isan example of the same System_Calls using instance numbers:

SYSTEM_CALL [1] ‘SEND’ (’AMX’,‘AXCESS’,3)SYSTEM_CALL [2] ‘SEND’ (’GOOD’,‘TIMES’,5)

The number in the brackets is the instance number. By using this number, youtell the compiler to compile multiple copies of the routine, and have the differentSystem_Calls each call a separate copy. The compiler accomplishes this by usingthe instance number to modify the actual name of the Define_Call before compil-ing it. When compiling a library file called with an instance number, AXCESS con-verts the number to ASCII and appends it to the Define_Call name (see Figure 6-4.)

Include Files and System_Calls

Instance number

A number enclosed in

brackets after the System_

Call keyword to denote

which copy of the compiled

library file to call.

Library file

DEFINE_CALL ‘SEND1’

AXCESS main program

SYSTEM_CALL [1] ‘SEND’

(‘AMX’,‘AXCESS’,3)

Figure 6-4

How AXCESS modifies the

Define_Call name in the

library file using the instance

number.

Page 144: Axcess Language Tutorial

134 Unit 6: Advanced AXCESS Programming

This process is called name mangling. When an instance number is used in aSystem_Call, AXCESS “mangles” the names of the Define_Call and any Waitsand Wait_Untils in the subroutine. When the System_Call subroutine SEND iscalled with an instance number of 1, AXCESS generates a call to SEND1. Then itcompiles the library file, adding a ‘1’ to the end of the Define_Call name andthe Wait name. If a System_Call were made with the instance number equal to100, the Define_Call would be named ‘SEND100,’ and the Wait would be named‘SS WAIT100.’

In the program, all System_Calls using the same instance number call thesame copy of the library file. For instance:

SYSTEM_CALL [1] ‘SEND’ (’HOW’,‘FEE’,3) (* calls copy 1 *)SYSTEM_CALL [2] ‘SEND’ (’DO’,‘FI’,3) (* calls copy 2 *)SYSTEM_CALL [2] ‘SEND’ (’YOU’,‘FO’,3) (* calls copy 2 *)SYSTEM_CALL [3] ‘SEND’ (’DO’,‘FUM’,3) (* calls copy 3 *)

Suppose there is a Define_Call SEND1 in your program, and you attempt thefollowing line of code:

SYSTEM_CALL [1] ‘SEND’ (’LETS’, ‘GO’, 3)

After name mangling, this generates a call to SEND1, which will actually callthe subroutine SEND1 in the program file, not the library file. In fact, since thecall to SEND1 is resolved (that is, a subroutine SEND1 was found) the library file isnever compiled. However, if the instance number was 2, the SEND1 subroutinewould not be called, and the SEND library file would be compiled with thenames mangled using the character ‘2.’

Include Files and System_Calls

Name mangling

The process where the name

of the Define_Call and any

Waits and Wait_Untils in a

library file are changed so

that multiple separate copies

can be compiled into a

program.

Page 145: Axcess Language Tutorial

GLOSSARYAND INDEX

ADVANCEDAXCESSPROGRAMMING

AXCESS Language Tutorial

Page 146: Axcess Language Tutorial
Page 147: Axcess Language Tutorial

Glossary 137

Glossary

Analog An input or output that can have many values.

Array A single variable that has more than one storage location.

ASCII A coding scheme that assigns numeric values to letters, numbers, andother characters.

AXlink The AXCESS communications bus.

Bar graph A visual representation of a level.

Baud rate Speed of data transmission; measured in bits per second (bps).

Bitwise operator A keyword or symbol that performs a bit-by-bit operationbetween two items.

Block Highlighted section of text in the AXCESS text editor.

Block file File saved on disk using the Write Block to Disk command (Alt-W);it has the DOS extension “AXB.”

Boolean expression A conditional statement used to tell AXCESS whether ornot to execute a particular function or functions in the program. This is alsoknown as a relational expression.

Boolean operator A keyword or symbol that creates a relation between twoitems.

Buffer An array variable that is associated with a particular device for the pur-pose of storing information sent by the device.

Caller The Call statement that called a subroutine.

CardFrame Housing for the AXCESS control cards.

Case sensitive Uppercase and lowercase values are not evaluated the same;for example, “CASS” is not the same as “cass.”

Cell One particular location in a two-dimensional array.

Channel The basic input/output unit. Channels correspond to actual controlfunctions such as relays and infrared signals. Each AXCESS device has 255channels, although all are not always used.

Page 148: Axcess Language Tutorial

Glossary 138

Comment A description or remark within an AXCESS program that is not con-sidered part of the actual program; it is ignored by the compiler.

Communications port Port through which serial data is transferred.

Compilation error An error that occurs at compile time.

Compile time When the program is compiled.

Compound statement A group of several statements enclosed by a set ofbraces.

Constant An identifier whose value remains unchanged throughout the entireprogram.

Decimal Base 10 numbering system.

Deck Any piece of equipment controlled by an AXCESS device.

Default statement A statement (or compound statement) that is executed ifnone of the conditions being tested is true.

Definition section One of the various divisions of the AXCESS program. Thesesections are Define_Device, Define_Constant, Define_Variable, Define_

Latching, Define_Mutually_Exclusive, Define_Start, and Define_Program.

Device A component that can be connected to AXlink.

Device-channel A reference to a specific channel in the AXCESS system in theformat [device,channel].

Device number A unique number from 1 to 255 designated to each deviceconnected to AXCESS via AXlink.

Digital An input or output that can have only two values: “on” or “off.”

DIP switch A switch on a circuit board that can be turned on or off to deter-mine various settings.

Direct assignment Generating an output change by assigning a value to adevice-channel.

Downloading The sending of data from a computer to a device (such as aMaster Card).

Dumb terminal A serial communications device. Whatever is typed goes outthe communications port, and whatever comes in the port is displayed on thescreen.

EPROM Acronym for erasable programmable read-only memory.

Page 149: Axcess Language Tutorial

Glossary 139

Error See compilation error, run-time error, and logic error.

Executable code A translated version of the source code that the AXCESS sys-tem can understand.

Feedback The lighting of a button during and after it is pressed.

Firmware Residing within the EPROMs in many AXCESS devices, this softwareenables these devices to operate.

Flag A variable that is used to store an “on” or “off” state.

Free format A characteristic of the AXCESS language that allows the sourcecode to be independent of tabs and carriage returns.

Global variable Any variable in the Define_Variable section of the program.The scope of these variables extends throughout the entire program.

Hexadecimal Base 16 numbering system.

Identifier A combination of letters, numbers, or underscores that represents adevice, constant, or variable.

Include file A DOS file which is included in the compiling process without hav-ing to reside in the computer’s memory; it has the DOS extension “AXI.”

Index value The number that tells AXCESS which location in an array to re-trieve. This value must be an integer from 1 to 255.

Infinite loop A loop which will never terminate.

Input change A signal sent by the input function of a channel that alertsAXCESS to scan mainline for a reference to that signal.

Instance number A number enclosed in brackets after the System_Call key-word to denote which copy of the compiled library file to call.

Integer In AXCESS, the range of whole numbers from 0 to 65,535, inclusive.

Integer array An array where each location can hold a value ranging fromzero to 65,535. Note that an integer array will take up twice as much AXCESS

memory than a normal array of the same storage capacity would.

Keyword A word or series of words that signifies the operation for AXCESS toexecute.

Latching A defined behavior of status that causes its output channel to stay onor off until activated once more.

Level A value that is related to an analog input or output on an AXCESS device.

Page 150: Axcess Language Tutorial

Glossary 140

Library file A special file containing AXCESS program code. These files are usedonly for System_Calls.

Local variable A variable declared in a subroutine, and whose scope is limitedto that subroutine.

Locking When flags are used to disable events.

Logic error An error in the actual design of the program.

“Look and feel” How something interacts with the user. This is also called theuser interface.

Loop A block of code that is continuously executed until a condition is satis-fied.

Master Card The AXCESS card that controls the activities of the AXCESS system.

Mainline The section of the program that actually is executed continuously bythe Master Card. This is also known as the Define_Program section.

Modem Communications device used to transfer serial data through phonelines.

Momentary A defined behavior of status that causes its output channel to beactivated as long as the corresponding button is pressed.

Momentary mutually exclusive A characteristic of status that allows only onechannel of a pre-defined set to be on at a time. The output channel is activatedas long as the corresponding button is pressed.

Mutually exclusive latching A characteristic of status that allows only onechannel of a pre-defined set to be on at a time. The output channel stays onuntil another channel of the set is activated.

Mutually exclusive set Only one channel or variable in this set can be on at atime.

Mutually exclusive toggling A characteristic of status that allows only onechannel of a pre-defined set to be on at a time. The output channel stays onuntil it is re-activated or another channel of the set is activated.

Name mangling The process where the name of the Define_Call and anyWaits and Wait_Untils in a library file are changed so that multiple separatecopies can be compiled into a program.

Nesting Placing conditional branches inside other conditional branches.

Null string An empty set of single quotes, which represents a string literal withno content and a length value of zero.

Page 151: Axcess Language Tutorial

Glossary 141

One-to-one Each button has one and only one function, with no specialconditions or considerations.

Operator A character or group of characters that performs a specificmathematical or relational function.

Output change A message to the output function of a channel.

Password A series of numbers that allows access to restricted data.

Preset A level saved for later retrieval. When a preset is recalled, thelevel returns to the preset value.

Program file File containing the AXCESS program source code; it has theDOS extension “AXS.”

Push window A window on the bottom left of the AXCESS program thatdisplays the Push statement of the last button pressed in the AXCESS sys-tem.

Ramp To change a level from one value to another smoothly over a pe-riod of time.

Re-assignment When AXCESS assigns a new value to a parameter vari-able after a subroutine is executed, but before it returns to the caller.

Relational expression See Boolean expression.

Reserved word An identifier reserved for use by the AXCESS compiler.

Row A one-dimensional array of values in a two-dimensional array.

Run time When the program is executed in the Master Card.

Run-time error An error that occurs during program execution.

S19 format File format used to place code or data into EPROM chips.

Scope The part of the program where the variable can be accessed. Avariable has global scope if the entire program has access to it; a variablehas local scope if only a section of the program has access to it.

Select group A group of buttons that selects a single deck or device outof a group.

Select variable A variable whose value determines which device in agroup is currently selected.

Serial The transfer of data one byte at a time.

Server Card The AXCESS card that distributes command signals amongdevice cards, to and from the Master Card, and within its CardFrame.

Page 152: Axcess Language Tutorial

Glossary 142

Source code The AXCESS program that you type and edit.

State The “on” or “off” status of a channel.

Statement A keyword and all of its parameters or conditions.

Status Records the state of the physical part of a channel.

String A set of values grouped together with single and/or double quotes.

String expression Enclosed by double quotes, this expression combines sev-eral types of data into a single string.

String length An internal value set for arrays by string assignment operations.

String literal A set of characters (values ranging from 32 to 127) enclosed insingle quotes.

Subroutine A section of code that stands alone and can be “called” from any-where else in the program.

System variable A value kept in the Master Card that can be referenced bycertain keywords.

Transport function A common function of devices such as VCRs and cassettedecks. For example: Play, Stop, Pause, Fast Forward, and Rewind.

Two-dimensional array A storage place holding multiple one-dimensionalarrays.

Uploading The opposite of downloading; the computer receives data from adevice.

User interface See “look and feel.”

Variable A place to store data that will change as the program is executed.

Wait list A list containing unexpired Wait statements. After each pass throughmainline, the Master Card scans this list to see if any have come due.

Wait_Until list A list containing unexpired Wait_Until statements. After eachpass through mainline, the Master Card scans this list to see if any have comedue.

Warning A statement by the compiler urging caution with a potentially haz-ardous statement in the source code.

Wildcard character Allows any character to be in its place; in AXCESS, this isthe question mark (?). This is only valid when comparing dates and times.

Page 153: Axcess Language Tutorial

Index 143

Index

A

Active. See Select...ActiveAnalog input or output 81And 66Arrays 91–100

accessing values 92–94as strings 95defining 91–92integer 100manipulation keywords 103sending 98–99storing values 92–94string lengths 96two-dimensional 111–114

ASCII codes 99Atoi 102AX File menu 9–12

Create S19 file... 10Options... 11Retrieve 9–10Send w/password... 11Send... 10Source-send 9, 10Verify 10

AXCESScolor mode 4firmware version information 13installation 3mainline 33–34memory 9monochrome mode 4power-up 33program files. See Program filesstarting program 3text editor 8version information 9

AXlinkand While 77comparing devices on 12

device numbers 5errors 6listing devices on 12

B

Bar graphs 86Blocks 18Boolean expression tables 65–66Boolean expressions 58

and Wait_Until 72in feedback statements 64

Boolean operators 65Braces 24

nesting If...Else statements 59nesting Waits 70with compound statements 58with subroutines 118

Bracketswith arrays 92with Push 36with To 38

Branching 58. See also If, Select...Active.Buffers 107–110

clearing 110creating 107–108retrieving characters from 108–110storing characters in 108

C

Call 118. See also Subroutinesparameters 124

Callingsubroutines 118

Cancel_All_Wait 72Cancel_All_Wait_Until 73Cancel_Wait 72Cancel_Wait_Until 73CardFrame

Page 154: Axcess Language Tutorial

Index144

Create_Level 82Creating

buffers 107–108

D

Date 74Day 74Define_Call 117

and System_Call 129local variables 123parameters 124storing in separate section of memory

11unused 11

Define_Connect_Level 86–87Define_Constant 31

identifiers 26Define_Device 30

identifiers 26Define_Mutually_Exclusive 43Define_Program 33Define_Start 33

and Create_Buffer 107and Create_Level 83and Define_Call 117and To 33, 38setting variables 32

Define_Variable 32array string lengths 96arrays 91identifiers 26integer arrays 100

Definingarrays 91–92constants 31–32devices 30–31latching 42–43momentary mutually exclusive 43–44mutually exclusive latching 44mutually exclusive toggling 44–45subroutines 117variables 32

Delays. See WaitDevice numbers 5, 30

receivers 5Touch Panel 5

Device-channel 29–30

connections 4power supply 4

Cardsdevice numbers 5

Channels 29–30, 35–37changing states of 37–39input function 35momentary 42momentary mutually exclusive 43mutually exclusive 43mutually exclusive latching 44mutually exclusive toggling 44–45output function 37specifying ranges 42status 41, 43, 44

Clear_Buffer 110Clearing

buffers 110Comments 25–26Communications

baud rate 13configuring 13pass-thru 14problems 5terminal emulator 13

Communications menu 13Configure... 13Pass thru... 14Receive file... 14Send file... 14Terminal emulator... 13

Compiled code. See Executable codeCompiler

messages 11options 11warnings 11

Compiling 8comments 25include files 127

Computer 3Conditional statements. See Boolean

expressionsConnecting

levels 86–87Constants

assignment of unlike types 11defining 31–32strings 94

Create_Buffer 107

Page 155: Axcess Language Tutorial

Index 145

Findingstrings 104

G

Get_Buffer_Char 108Get_Timer 73–74, 85Global variables 123

H

Help menu 15HELP.OVL file 15

I

Identifiers 26constants 31guidelines 26

If 58associating with Else 60nesting 59–60

If...Else 58–59default statement 59

If...Else If 59Include 127

files 127opening files 8saving files 8

Indenting 23Index values 92Input changes 35

and While keywords 78keywords 35–37

InstallationAXCESS program 3

Instance numbers 131Integer 100

arrays 100Itoa 101Itohex 102

K

Keywords 24

direct assignment 39Devices

defining 30–31Diagnostics menu 12

Compare current devices... 12Show current devices... 12Show current versions... 13Watch variables... 13

DIP switchessettings 5

Direct assignment 39using a Boolean expression 64

Directorieschanging 9

Disk files 3, 8, 15Double periods 42Double quotes

with string expressions 94with strings 94

E

Else 58–59, 59. See also IfEquipment 3Error window 20Errors

parameter mismatch option 11viewing 20

Executable code 8sending 10

F

Feedbackdirect assignment 39grouping statements 47“last button pressed” 43programming 46–47

File menu 7Change dir... 9Compile 8–9Exit 9New.. 8, 29Open include.. 8Open.. 7–8Print.. 9Save 8Version... 9

Find_String 104

Page 156: Axcess Language Tutorial

Index146

Mid_String 103–104Modems

transferring files 14Momentary 42Momentary mutually exclusive

defining 43–44Monitors 4Mutually exclusive 43

double periods 43latching 44momentary 43–44parentheses 43toggling 44–45variables 61

Mutually exclusive latchingdefining 44

Mutually exclusive togglingdefining 44–45

N

Name mangling 131Nesting

If statements 59–60Waits 70

NEW.OVL file 8Not 66

O

Off 38On 38Operators 24Or 66Output changes 37

and channel status 41direct assignment 39keywords 38–39

Output channels 41physical part 41status 41

P

Parameters 124–126mismatch error 11reassignment 125–126

L

Latching 42defining 42–43status 42

Left_String 103Length_String 96, 109, 112Levels 81–84

and bar graphs 86connecting 86–87creating 82–84preset 85–86reading 85sending 86

Library files 129Local variables 123–124Local_Var 123Long_While 78Loops 77–78Lower_String 106Lowercase 105

M

Mainline 33–34. See also Define_Programand buffers 108and Push_Channel 37and Push_Device 36and Release_Channel 37and Release_Device 36and Wait 71and Wait_Until 72and While 77

Master CardCardFrame slot 4executing mainline 33LED 6sending compiled program to 10sending source code to 9verifying program 10

Medium_While 78Menus 7–15

AX File menu 9–12Communications menu 13Diagnostics menu 12File menu 7Help menu 15

Messagessetting options for 11

Page 157: Axcess Language Tutorial

Index 147

Parenthesesand If 58Call parameters 124mutually exclusive set 43

Passwords 11Pause_All_Wait 72Pause_Wait 71Presets

creating 85–86Printing 9

configuring 13Program execution sequence 24

and Waits 67Program files

compiling 8creating 8deleting 8information on 7naming 8opening 7printing 9saving 8

Program spacing 23Program_Name

and include files 128and program files 8and System_Call 129

Pulse 39and Wait 70

Push 36and feedback 47and To 38compound statements 24finding 19inserting 19simulated 20

Push window 5, 19and Define_Device 31

Push_Channel 37Push_Device 36

Q

Question marks 75Quotation marks

with strings 94

R

README file 3Receiving

strings 107Relational expressions. See Boolean

expressionsRelease 36Release_Channel 37Release_Device 36Remove_String 104Removing

strings 104Reserved words 26Restart_All_Wait 72Restart_Wait 72Retrieving

source code 9–10Right_String 103

S

S19 files 10Search and replace 18Select groups

Mutually exclusive variable method61–63

variable assignment method 63–65Select...Active 60–61

default statement 61Send_Command 93Send_Level 86, 87Send_String 98Sending

arrays 98–99levels 86program to Master Card 10Source-send option 10strings 98–99

Server CardDIP switch settings 5

Set_Length_String 97, 110, 112Set_Pulse_ Time 39Set_Timer 73, 85Simulated button press 20Single quotes

and case-sensitivity 105with Include files 127

Page 158: Axcess Language Tutorial

Index148

with strings 94with subroutines 117

Source code 8retrieving from Master Card 9sending 10

Startup code 33Statements 24–25

compound 24–25String expressions 94–95Strings 91–100, 94

array string lengths 96assigning to a two-dimensional array

112assigning to an array 94, 96conversion keywords 101–102finding 104receiving 107removing 104sending 98–99setting upper/lower case 106string literals 94

Subroutines 117–122calling 118defining 117restrictions on names 117

Substrings. See Arrays: manipulationkeywords

Symbols 27System_Call 129

from the factory 130

T

Text editor 8, 17–20blocking 18–20commands 17exiting 9insert/overwrite mode 18search and replace 18

Time 74Timer keywords 73–74To 38–39

and Define_Start 33, 38and Wait 38momentary channels 42

Total_Off 38and mutually exclusive groups 43

Touch Panelsbar graphs 86device numbers 5levels 86

Transferring files 14Two-dimensional arrays 111–114

retrieving values from 113–114storing values in 112

U

Upper_String 106Uppercase 105

V

Variable Watch window 13Variables

arrays 91as output channels 38assignment of unlike types 11defining 32local 123–124mutually exclusive 61scope 123unused 11

Verifying Master Card program 10Versions

AXCESS program 9firmware 13

Video monitors 4

W

Wait 67and Pulse 70and To 38, 70cancelling 71–72list 67multiple Waits 69–70naming 71nesting Waits 70pausing 71–72problems in library files 132restarting 71–72special uses 70

Page 159: Axcess Language Tutorial

Index 149

Wait_Until 72list 72misusing 72–73naming 73problems in library files 132removing 73

Warningsassignment of unlike types 11Define_Call is not used 11turning on and off 11variable is not used 11

While 77–78timeout 78

Wildcard characters 75

X

Xor 66

Page 160: Axcess Language Tutorial