Crestron SIMPL PLUS LANGUAGE REF User Manual

0 (0)

Crestron SIMPL+®

Software

Language Reference Guide

This document was prepared and written by the Technical Documentation department at:

Crestron Electronics, Inc.

15 Volvo Drive

Rockleigh, NJ 07647

1-888-CRESTRON

All brand names, product names and trademarks are the property of their respective owners. ©2003 Crestron Electronics, Inc.

Crestron SIMPL+®

Software

Contents

SIMPL+ Language Reference Guide

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Software Requirements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Licensing of SIMPL+ Cross Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

What's New . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7

Converting from an X-Generation to a 2-Series Target . . . . . . . . . . . . . . . . . . . . . . . . 7

X-Generation Target and 2-Series Target Differences . . . . . . . . . . . . . . . . . . . . . . . . 7

Programming Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Programming Environment Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Target Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Edit Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Insert Category . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

General Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

Conventions Used . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Variable Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Relative Path Names for Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

Operators Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

Signed vs Unsigned Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Operator Precedence & Grouping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

Numeric Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Task Switching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

Task Switching for X-Generation (CNX) Control Systems . . . . . . . . . . . . . . . . . . . 22 Task Switching for 2-Series Control Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

Language Constructs & Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

Language Constructs & Functions Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

Compiler Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

#CRESTRON_LIBRARY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

#DEFAULT_NONVOLATILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

Language Reference Guide - DOC. 5797G

Contents z i

Software

Crestron SIMPL+ ®

#DEFAULT_VOLATILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 #DEFINE_CONSTANT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 #HELP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 #HELP_BEGIN … #HELP_END . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 #HINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 #IF_DEFINED … #ENDIF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 #SYMBOL_NAME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 #USER_LIBRARY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 #IF_NOT_DEFINED … #ENDIF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Declarations Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Fixed and Variable Size Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 ANALOG_INPUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 ANALOG_OUTPUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 DIGITAL_INPUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 DIGITAL_OUTPUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 INTEGER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 LONG_INTEGER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 SIGNED_INTEGER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 SIGNED_LONG_INTEGER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 STRING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 STRING_INPUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 STRING_OUTPUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 STRUCTURES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 Nonvolatile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 SendMail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 EVENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 PUSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Release . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Stacked Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 FOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 WHILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 CSWITCH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 IF - ELSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 SWITCH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 GetLastModifiedArrayIndex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 GetNumArrayCols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 GetNumArrayRows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 SetArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 Byte . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 High . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Low . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 RotateLeft . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 RotateRight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 RotateLeftLong . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 RotateRightLong . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 Atol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 Chr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 ItoA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 ItoHex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 LtoA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 LtoHex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

File Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 File Functions Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116

ii z Contents

Language Reference Guide - DOC. 5797G

Crestron SIMPL+®

Software

File Function Return Error Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

Reading and Writing Data to a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118

CheckForDisk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119

EndFileOperations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120

FileBOF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121

FileClose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122

FileDate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123

FileDay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125

FileDelete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126

FileEOF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127

FileGetDateNum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128

FileGetDayOfWeekNum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

FileGetHourNum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130

FileGetMinutesNum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131

FileGetMonthNum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

FileGetSecondsNum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133

FileGetYearNum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134

FILE_INFO Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135

FileLength . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136

FileMonth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137

FileOpen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138

FileRead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141

FileSeek . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143

FileTime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

FindClose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

FindFirst . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149

FindNext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

GetCurrentDirectory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

IsDirectory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

IsHidden . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154

IsReadOnly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155

IsSystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156

IsVolume . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157

MakeDirectory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158

ReadInteger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159

ReadIntegerArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161

ReadLongInteger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163

ReadLongIntegerArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165

ReadSignedInteger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167

ReadSignedIntegerArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169

ReadSignedLongIntegerArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173

ReadString . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175

ReadStringArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177

ReadStructure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179

RemoveDirectory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181

SetCurrentDirectory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182

StartFileOperations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183

WaitForNewDisk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184

WriteInteger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185

WriteIntegerArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187

WriteLongInteger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189

WriteSignedInteger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191

WriteSignedIntegerArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193

WriteSignedLongInteger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195

Language Reference Guide - DOC. 5797G

Contents z iii

Software

Crestron SIMPL+ ®

WriteSignedLongIntegerArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197

WriteStringArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201

WriteStructure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203

Max . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206

MIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207

MulDiv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208

SMAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209

SMin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210

Random . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211

Rnd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212

Seed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213

Print . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216

String Concatenation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218

Find . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220

Gather . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221

GetC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223

Left . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224

Len . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225

Lower . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226

Mid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227

REVERSEFIND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229

Right . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230

SetString . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231

Upper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233

ProcessLogic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235

Pulse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236

TerminateEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237

GenerateUserNotice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238

GenerateUserWarning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239

GenerateUserError . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240

CheckForNVRAMDisk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241

Day . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243

GETDATENUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244

GETDAYOFWEEKNUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245

GETHOURNUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246

GETHSECONDS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247

GETMINUTESNUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248

GETMONTHNUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249

GETSECONDSNUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250

GETTICKS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251

GETYEARNUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252

MONTH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253

SETCLOCK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254

SETDATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255

TIME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256

CancelAllWait . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258

CancelWait . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259

PauseAllWait . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260

PauseWait . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261

RetimeWait . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264

Wait . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265

Function Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268

ByRef, ByVal, ReadOnlyByRef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269

Returning a Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272

iv z Contents

Language Reference Guide - DOC. 5797G

Crestron SIMPL+®

Software

Calling a Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 Function Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 Example 2: 8-Level switch on a Pesa switcher . . . . . . . . . . . . . . . . . . . . . . 280 Example 3: Computing the Number of Days in a Month

(Using Functions) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282 Example 4: Computing the Number of Days in a Month

(Using Function Libraries) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283

Compiler Errors and Warnings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286

Compiler Errors and Warnings Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 Syntax Errors (Compiler Errors 1000 to 1013) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 Compiler Error 1000 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 Compiler Error 1001 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290 Compiler Error 1002 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 Compiler Error 1003 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 Compiler Error 1004 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 Compiler Error 1005 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294 Compiler Error 1006 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294 Compiler Error 1007 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 Compiler Error 1008 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 Compiler Error 1009 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 Compiler Error 1010 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298 Compiler Error 1011 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298 Compiler Error 1012 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 Compiler Error 1013 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 Fatal Errors (Compiler Errors 1100 to 1101) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300 Compiler Error 1100 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300 Compiler Error 1101 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301

Expression Error (Compiler Errors 1200 to 1201) . . . . . . . . . . . . . . . . . . . . . . . . . . 301 Compiler Error 1200 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301 Compiler Error 1201 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303 Declaration Errors (Compiler Errors 1300 to 1312) . . . . . . . . . . . . . . . . . . . . . . . . . 304 Compiler Error 1300 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304 Compiler Error 1301 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305 Compiler Error 1302 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 Compiler Error 1303 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307 Compiler Error 1304 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308 Compiler Error 1305 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308 Compiler Error 1306 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 Compiler Error 1307 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310 Compiler Error 1308 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 Compiler Error 1309 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312 Compiler Error 1310 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313 Compiler Error 1311 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314 Compiler Error 1312 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 Compiler Error 1313 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 Compiler Error 1314 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316 Assignment Errors (Compiler Errors 1400 to 1402) . . . . . . . . . . . . . . . . . . . . . . . . . 317 Compiler Error 1400 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317 Compiler Error 1401 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318 Compiler Error 1402 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318 Function Argument Errors (Compiler Errors 1500 to 1508) . . . . . . . . . . . . . . . . . . . 319 Compiler Error 1500 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319

Language Reference Guide - DOC. 5797G

Contents z v

Software

Crestron SIMPL+ ®

Compiler Error 1501 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320

Compiler Error 1502 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321

Compiler Error 1503 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321

Compiler Error 1504 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322

Compiler Error 1505 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323

Compiler Error 1506 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324

Compiler Error 1507 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324

Compiler Error 1508 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325

Construct Errors (Compiler Errors 1600 to 1608) . . . . . . . . . . . . . . . . . . . . . . . . . . 326

Compiler Error 1600 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326

Compiler Error 1601 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326

Compiler Error 1602 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327

Compiler Error 1603 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328

Compiler Error 1604 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329

Compiler Error 1605 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329

Compiler Error 1606 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330

Compiler Error 1607 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331

Compiler Error 1608 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331

File Errors (Compiler Errors 1700 to 1702) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332

Compiler Error 1700 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332

Compiler Error 1701 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332

Compiler Error 1702 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332

Compiler Warnings (Compiler Errors 1800 to 1803) . . . . . . . . . . . . . . . . . . . . . . . . 333

Compiler Warning 1800 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333

Compiler Warning 1801 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333

Compiler Warning 1802 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334

Compiler Warning 1803 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335

SIMPL+ Revisions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336

Obsolete Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337

System Interfacing - Cresnet and CPU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337

GetCIP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337

GetCresnet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338

GetSlot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339

IsSignalDefined . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340

SendCresnetPacket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341

SendPacketToCPU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342

SetCIP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343

SetCresnet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344

SetSlot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345

#ANALOG_OUTPUT_JOIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347

#DIGITAL_INPUT_JOIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347

#DIGITAL_OUTPUT_JOIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348

#STRING_INPUT_JOIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348

#STRING_OUTPUT_JOIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349

CEN-OEM-Specific Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350

_OEM_BREAK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350

_OEM_CD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351

_OEM_CTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351

_OEM_DTR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352

_OEM_LONG_BREAK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353

_OEM_MAX_STRING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353

_OEM_PACING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354

vi z Contents

Language Reference Guide - DOC. 5797G

Crestron SIMPL+®

Software

_OEM_RTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 _OEM_STR_IN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 _OEM_STR_OUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .357

Software License Agreement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361

Return and Warranty Policies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363

Language Reference Guide - DOC. 5797G

Contents z vii

Software

Crestron SIMPL+ ®

This page intentionally left blank.

viii z Contents

Language Reference Guide - DOC. 5797G

Crestron SIMPL+®

Software

Introduction

SIMPL+® is a language extension that enhances SIMPL Windows by using a procedural “C-like” language to code elements of the program that were difficult, or impossible, with SIMPL alone. This help system provides specific information about the SIMPL+ language syntax, and can be used as a reference manual.

For a tutorial on SIMPL+ programming, consult the SIMPL+ Programming Guide (Doc. 5789). The latest version of the guide can be obtained from the Downloads | Product Manuals section of the Crestron website (www.crestron.com).

Software Requirements

SIMPL+ has several versions. Earlier versions of SIMPL+ do not contain features and constructs found in later revisions. Each version of SIMPL+ requires a minimum revisions of SIMPL Windows and Control System Update (UPZ or, for 2-Series control systems, CUZ) files. The specifications are listed below.

Software Requirements

SIMPL+ VERSION

MINIMUM SIMPL WINDOWS REQUIRED

MINIMUM UPZ

MINIMUM CUZ

 

 

 

 

Version 1.00

1.30.01

5.04.11

N/A

Version 2.00

1.40.02

5.10.00

N/A

Version 3.00

2.00

N/A

1.00

 

 

 

 

Language Reference Guide - DOC. 5797G

SIMPL+® z 1

Software

Crestron SIMPL+ ®

Licensing of SIMPL+ Cross Compiler

Crestron SIMPL+ Cross-Compiler Version 1.1 is simply an Installshield-installed version of the Coldfire GNU C Compiler, which is available on Crestron's FTP site in the SIMPL Windows directory as directory GNUSOURCE in ftp:// ftp.crestron.com/Simpl_Windows and in the \GNUSource directory of the Programming Tools CD.

It includes and references code that is available from www.cygwin.com/cvs.html

Some files are deleted by the Installshield procedure which are not necessary for general use of the C compiler, in order to save space on user PCs. But it is an unmodified version of this code. The original executables and the source code for them can be obtained from the authors at the above sites

The source code has also been gathered underneath a single directory for your convenience and is available on Crestron's FTP site in the SIMPL Windows directory as directory GNUSOURCE in ftp://ftp.crestron.com/Simpl_Windows and in the \GNUSource directory of the Programming Tools CD. They also include GNU utilities, which are copyrighted by the Free Software Foundation.

Other Crestron software simply executes this code as a separate executable, and does not incorporate GNU source code into Crestron software. Crestron's standard licensing agreement does not apply to this software; only the license described here applies.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Refer to the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program (it is appended to this document for your convenience); if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

The text for the license agreement below is also available from www.gnu.org/copyleft/gpl.html GNU GENERAL PUBLIC LICENSE

Version 2, June 1991

Copyright (C) 1989, 1991 Free Software Foundation, Inc.

59 Temple Place - Suite 330, Boston, MA 02111-1307, USA

Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.

PREAMBLE

The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.

2 z SIMPL+®

Language Reference Guide - DOC. 5797G

Crestron SIMPL+®

Software

When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.

To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.

For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.

We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.

Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.

Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.

The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The “Program”, below, refers to any such program or work, and a “work based on the Program” means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term “modification”.) Each licensee is addressed as “you”.

Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.

1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.

You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.

2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:

a)You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.

b)You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.

c)If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program

Language Reference Guide - DOC. 5797G

SIMPL+® z 3

Software

Crestron SIMPL+ ®

itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensee is extend to the entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.

In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.

3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:

a)Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,

b)Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,

c)Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.

If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.

4.You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.

5.You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.

6.Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.

7.If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not

4 z SIMPL+®

Language Reference Guide - DOC. 5797G

Crestron SIMPL+®

Software

distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.

It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.

This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.

8.If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.

9.The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.

Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and “any later version”, you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.

10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.

NO WARRANTY

11.BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

12.IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Programs

Language Reference Guide - DOC. 5797G

SIMPL+® z 5

Software

Crestron SIMPL+ ®

If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software that everyone can redistribute and change under these terms.

To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.

One line to give the program's name and an idea of what it does. Copyright (C) yyyy name of author

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Refer to the GNU General Public License for more details.

You should have received a copy of the GNU General Public License

along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author

Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.

This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.

You should also get your employer (if you work as a programmer) or your school, if any, to sign a “copyright disclaimer” for the program, if necessary. Here is a sample; alter the names:

Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision'

written by James Hacker. signature of Ty Coon, 1 April 2002 Ty Coon, Vice President

This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.

FSF & GNU inquiries & questions to gnu@gnu.org.

6 z SIMPL+®

Language Reference Guide - DOC. 5797G

Crestron SIMPL+®

Software

What's New

Converting from an X-Generation to a 2-Series Target

Select 2-Series Target within SIMPL+ environment (From the SIMPL+ application menu, select Build | 2-Series Control System Target. The X- Generation Target may be deselected if no longer needed).

Recompile the SIMPL+ program.

X-Generation Target and 2-Series Target Differences

I/O Datatypes (DIGITAL_INPUT, etc.) can no longer be passed to functions as arguments.

Global variables can no longer be declared within User or Crestron Libraries.

If TerminateEvent resides within a Wait Statement Block, it will only exit the Wait Statement Block's function scope - NOT the PUSH, CHANGE, RELEASE or EVENT in which it resides.

The following functions are no longer available in the 2-Series Control System: GetCIP()

SetCIP()

GetCresnet()

SetCresnet()

GetSlot()

SetSlot() _OEM functions

#ANALOG_INPUT_JOIN

#ANALOG_OUTPUT_JOIN #DIGITAL_INPUT_JOIN #DIGITAL_OUTPUT_JOIN #STRING_INPUT_JOIN #STRING_OUTPUT_JOIN

Language Reference Guide - DOC. 5797G

SIMPL+® z 7

Software

Crestron SIMPL+ ®

Programming Environment

Programming Environment Overview

While running SIMPL Windows, select File | New SIMPL+ and the SIMPL+ programming environment appears. This section describes the environment for SIMPL+ Version 3.00.

The SIMPL+ Module Information template is filled with commented code that makes it easy to remember the language syntax and structure. Simply locate the necessary lines, uncomment them, and add the appropriate code. To uncomment a line of code, either remove the “//” that appears at the start of the line or remove the multi-line comment indicators /*…*/.

Target Selection

Target Selection Pulldown Menu

X Generation (CNX) Control Systems consist of the CEN-TVAV, CNMSX-AV/ PRO, and CNRACKX/-DP.

The 2-Series Control Systems currently consist of the AV2, CP2, CP2E, PAC2, PAC2M, PRO2, and RACK2.

Selecting a target implies that the module MUST work for that target and any statements that are not valid for that target are NOT permitted. It does NOT mean that the module won't work for other targets - it may, if it were compiled for other targets at some future time. More functions and support are available for 2-Series systems, so do not limit yourself to the X-Generation usages, if they are not needed.

8 z SIMPL+®

Language Reference Guide - DOC. 5797G

Crestron SIMPL+®

Software

NOTE: In previous versions of SIMPL+, the settings for the target types were system-wide. Those settings applied to all SIMPL+ modules that were opened and not specific to the active module being edited. In version 3.00, the target type setting is specific only to the active module being edited and saved within that module. The toolbar buttons reflect the target type of the active module within the SIMPL+ environment.

One or both targets may be selected to compile the program for both types of control systems. When compiling a program for a specific type of control system, an error message appears if a wrong control system target is selected that does not support a particular function or syntax.. Shown below are the two target selection buttons of the menu toolbar.

Toolbar Target Selection Buttons.

X-GEN - shortcut to Build | X-Generation Control Systems Target 2 - shortcut to

Build | 2-Series Control Systems Target. (This is the default setting upon opening

SIMPL+.)

NOTE: If a program is compiled for the wrong type of control system, an error message appears when attempting to upload, and the program must be recompiled.

Edit Preferences

Preferences Toolbar Pull-Down Menu

Language Reference Guide - DOC. 5797G

SIMPL+® z 9

Software

Crestron SIMPL+ ®

 

Text Editor Tab

Font - Used to select font to be used in SIMPL+ Text Editor's main window.

Cursor Positioning, Auto-Indent - When the 'enter' key is pressed, the cursor will automatically indent to the same initial tab position as in the current line.

To manually indent a block of text, highlight the block and press TAB.

To manually outdent a block of text, highlight the block and press

SHIFT and TAB.

If you have manually inserted spaces for tabs, then pressing SHIFT TAB will only outdent by only one space.

Cursor Positioning, Allow cursor positioning past end of line - If checked, the cursor will be allowed to be placed anywhere within the text editor. This includes any white-space area. Disabling this option will force the cursor to the end of the current line selected when the cursor is clicked on any white-space past the end of the line.

Tab Size - The number of spaces that equal 1 tab character.

Insert Spaces for tabs - Spaces will be inserted in place of the tab character.

10 z SIMPL+®

Language Reference Guide - DOC. 5797G

Crestron SIMPL+®

Software

 

Target Devices Tab

Execute SIMPL+ Cross Compiler - After target files are compiled, the cross compiler can be launched from the SIMPL+ environment. This will enable you to generate the target file that will be uploaded to the operating system. Normally, the SIMPL Windows environment will handle this, since it is responsible for uploading the target file to the operating system.

Display Compile Warnings - When selected, the compiler displays all program warnings during compile in the compile output window. The total number of warnings will always be displayed whether this option is selected or not.

Insert Category

Displays a list of all available categories for the symbol tree in the SIMPL Windows environment. This list is for reference only.

To specify a category for a SIMPL+ module, the #CATEGORY directive must be used with a category specified in this list. If a category name is typed in that does not exist in the Symbol Tree Category list, the SIMPL+ module will default to the category type, Miscellaneous.

Symbol Tree Category List in SIMPL Windows

Language Reference Guide - DOC. 5797G

SIMPL+® z 11

Crestron SIMPL PLUS LANGUAGE REF User Manual

Software

Crestron SIMPL+ ®

 

Insert #CATEGORY Toolbar Pull-Down Menu in SIMPL+

Symbol Tree Category Pop-Up Window

Category Selection Insertion Box

12 z SIMPL+®

Language Reference Guide - DOC. 5797G

Crestron SIMPL+®

Software

General Information

Conventions Used

Variable names are placed in <> when discussing syntax. For example, PUSH <variable>.

Optional parameters are placed in [ ]. For example, when a list has many parameters, it would be described as <var1>[, <var2>...] When discussing array notation, [ ] is used for array subscripting and is not used to mark optional code.

Examples are placed in a Computer Style font, i.e.,

MyVariable = ATOI(SomeOtherVariable);

Variable Names

Variable names in SIMPL+ may be up to 30 characters long and may not contain any of the operators specified in the “Operators” section. Valid characters in a variable name are a-z, A-Z, 0-9, #, _, and $ but may not begin with 0-9.

Variable names may not duplicate existing function or keyword names.

Variable names in SIMPL+ are not case sensitive. For example, declaring a variable “joe” can be used as “jOe” or “JOE” or any variation of case.

NOTE: Version 3.00.12 users: variable names may be 120 characters for 2-Series systems.

Comments

It is beneficial to comment code to make it more readable and for documentation. Comments do not exist in any form after code generation and are not required.

SIMPL+ has two styles of comments, single line and block comments. Single line comments start with the characters //. The rest of the line (until a carriage return) is considered a comment. If they occur within a quoted string, such as in PRINT, they are NOT treated as comment characters, but rather as two backslash (Hex 2F) characters.

Examples:

PRINT(“Hello, World!\n”); // This stuff is a comment. PRINT(“hello, // world!\n”); // This stuff is a comment, // but the string actually

Language Reference Guide - DOC. 5797G

SIMPL+® z 13

Software

Crestron SIMPL+ ®

//printed is hello,

//world.

The second form of comment characters are the block comments. /* starts a block comment and */ ends a block comment. This is useful for commenting out large sections of code or writing large sections of documentation. Note that nested comments are not supported. Also, if /* or */ appear inside of a quoted string such as in an PRINT statement, they are not considered comments but part of the string.

Examples:

/*

This

is

all

a comment!

*/

PUSH Trig

{

// code that does something.

}

Relative Path Names for Files

Your current working directory is reset to the default (“\” or root) whenever “StartFileOperations” is performed. It is changed only by “SetCurrentDirectory”.

File names can consist of full path names or relative path names.

Full path names have the same restrictions as DOS file names in characters and format, with a maximum length of 256 characters.

Relative path names do not begin with a “\” and start from the current working directory.

14 z SIMPL+®

Language Reference Guide - DOC. 5797G

Crestron SIMPL+®

Software

Operators

Operators Overview

SIMPL+ operators perform functions between two or more variables. SIMPL+ operators consist of Arithmetic, Bitwise, and Rational Operators.

Arithmetic Operators

 

OPERATOR

 

NAME

 

EXAMPLE

 

EXPLANATION

 

-

Negation

-X

Negate the value of X (2’s Complement of X).

 

 

 

 

 

 

 

 

 

*

Multiplication

X *Y

Multiply X by Y (signed arithmetic).

 

/

Unsigned Division

X / Y

Divide X by Y, truncates result (unsigned arithmetic).

 

 

 

 

 

 

 

 

 

S/

Signed Division

X S/ Y

Divide X by Y, truncates result (signed arithmetic).

 

MOD

Signed Modulo

X MOD Y

Remainder after dividing X by Y (signed arithmetic).

 

 

 

 

 

 

 

 

 

UMOD

Unsigned Modulo

X UMOD Y

Remainder after dividing X by Y (unsigned arithmetic).

 

 

 

 

 

 

Only 2-Series Systems.

 

+

Addition

X + Y

Add the value of Y to X.

 

 

 

 

 

 

 

 

 

-

Subtraction

X - Y

Subtract the value of Y from X.

 

Bitwise Operators

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

OPERATOR

 

NAME

 

EXAMPLE

 

EXPLANATION

 

<<

 

Shift Left

 

X << Y

 

Shift X to the left by Y bits; 0 is Shifted in.

 

 

 

 

 

 

 

 

>>

 

Shift Right

 

X >> Y

 

Shift X to the right by Y bits; 0 is Shifted in.

{{

 

Rotate Left

 

X {{ Y

 

Rotate X to the left by Y bits; full 16 bits used. Same as

 

 

 

 

 

 

 

RotateLeft().

 

 

 

 

 

 

 

 

}}

 

Rotate Right

 

X }} Y

 

Rotate X to the right by Y bits; full 16 bits used. Same as

 

 

 

 

 

 

 

RotateRight().

 

NOT

 

1's Complement

 

NOT(X)

 

Change 0 bits to 1, 1 bits to 0.

 

 

 

 

 

 

 

 

&

 

Bitwise AND

 

X & Y

 

AND the bits of X with the bits of Y.

|

 

Bitwise OR

 

X | Y

 

OR the bits of X with the bits of Y.

 

 

 

 

 

 

 

 

^

 

Bitwise XOR

 

X ^ Y

 

XOR the bits of X with the bits of Y.

 

 

 

 

 

 

 

 

NOTE: For the Shift and Rotate operators, only the lower 5-bits of Y are used, giving values of Y ranging from 0 to 31. For example, if Y=600, the lower 5-bits equate to 24. Rotating a 16-bit number through 16 positions gives the original number back.

Therefore, for rotating 24, the result is equivalent to rotating through 8. Shifting greater than 16 will always give a 0 as a result.

Language Reference Guide - DOC. 5797G

SIMPL+® z 15

 

Software

 

 

Crestron SIMPL+ ®

Relational Operators

 

 

 

 

 

 

 

 

 

 

 

 

OPERATOR

 

NAME

EXAMPLE

EXPLANATION

 

=

 

Comparison

X = Y

True if X is equal to Y, False otherwise.

 

 

 

 

 

 

 

=

 

Assignment

X = Y

Assigns the contents in Y to X. The assignment

 

 

 

 

 

 

operator cannot be used within expressions.

 

!

 

Complement

! X

If X = 0, X changes to 1. If X is different from 0,

 

 

 

 

 

 

evaluates to 0.

 

 

 

 

 

 

 

<>

 

Not Equal To

X <> Y

X is not equal to Y.

 

<

 

Unsigned Less Than

X < Y

X is less than Y (unsigned).

 

 

 

 

 

 

 

>

 

Unsigned Greater

X > Y

X is greater than Y (unsigned).

 

<=

 

Unsigned Less Than or Equal

X <= Y

X is less or equal to Y (unsigned).

 

 

 

 

 

 

 

>=

 

Unsigned Greater Than or Equal

X >= Y

X is greater or equal to Y (unsigned).

 

 

S<

 

Signed Less Than

X S< Y

X is less than Y (signed).

 

 

 

 

 

 

 

 

 

S>

 

Signed Greater Than

X S> Y

X is greater than Y (signed).

 

 

S<=

 

Signed Less Than or Equal

X S<= Y

X is less or equal to Y (signed).

 

 

 

 

 

 

 

 

 

S>=

 

Signed Greater Than or Equal

X S>= Y

X is greater or equal to Y (signed).

 

&&

 

Logical AND

X && Y

True if X and Y are both non-zero. False

 

 

 

 

 

 

otherwise.

 

 

 

 

 

 

 

||

 

Logical OR

X || Y

True if either X or Y is non-zero. False otherwise.

 

 

 

 

 

 

 

 

All of the above operators, with the exception of the negation (-), NOT, and complement (!) operators, are called binary operators. Binary operators take two values, perform an operation, and return a third value as a result. For example, 5 + 6 would return the value of 11. The arguments for a given operator are called its operands. In the above example, the + sign is the operator and 5 and 6 are the operands.

The negation, NOT, and complement operators are called unary operators, which means it takes a single number and performs an operation. In this case, the negation operator performs a negate, or 2's complement. A 2's complement takes a 16-bit number, bitwise inverts it, and adds 1. The operand in a negation is the value being negated. Operands do not have to be simple numbers. They may also be variables or the results of a function call. For example, in the expression -X, the - sign is the operator and the variable X is the operand.

16 z SIMPL+®

Language Reference Guide - DOC. 5797G

Crestron SIMPL+®

 

 

Software

 

String Operators

 

 

 

 

 

 

 

 

 

OPERATOR

NAME

EXAMPLE

EXPLANATION

 

=

Assignment*

A$ = B$

Assigns the value in B$ to A$.

 

*NOTE: Not allowed in expressions because of possible confusion with comparison.

 

 

 

 

 

 

=

Comparison

A$ = B$

A$ equal B$

 

<>

Not Equal To

A$ <> B$

A$ is not equal to B$

 

 

 

 

 

 

<

Less Than

A$ < B$

A$ is less than B$

 

>

Greater Than

A$ > B$

A$ is greater than B$

 

 

 

 

 

For less than and greater than operations, the string is evaluated in ASCII order. For example, the comparison “ABC” > “ABD” would be false. The system looks character by character; the first two characters are identical in both strings, and when it evaluated the characters C (ASCII 67) vs. D (ASCII 68), the result is false. The comparison “ABC”<“ABCD” is true because a shorter string alphabetically precedes one that is identical but longer.

Language Reference Guide - DOC. 5797G

SIMPL+® z 17

Software

Crestron SIMPL+ ®

Signed vs Unsigned Arithmetic

ANALOG_INPUT, ANALOG_OUTPUTs, and INTEGER in SIMPL+ are 16-bit quantities. A 16-bit quantity can range from 0 - 65535 when it is treated without having a sign (positive or negative). If a 16-bit number is treated as signed in SIMPL+, the range becomes -32768 to 32767. The range from -32768 to -1 maps into 32768 to 65535. Expressed mathematically, the mapping is 65536 - AbsoluteValue(Number). The values are treated differently depending on whether signed or unsigned comparisons are used. Another way is as follows.

Signed

0

-

32767

32768 -

65535

Unsigned

0

-

32767

-32768 -

-1

Assignments may be directly done with negative constants, for example:

INTEGER I, J;

I = -1;

J = 65535;

Results in I being equivalent to J.

Example:

IF (65535 S> 0)

X=0;

ELSE

X=1;

Above, the value of X is set to 1 since in signed arithmetic, 65535 is the same as -1, which is not greater than 0.

IF (65535 > 0)

X=0;

ELSE

X=1;

Above, the value of X is set to 0 since in unsigned arithmetic, 65535 is greater than 0.

18 z SIMPL+®

Language Reference Guide - DOC. 5797G

Crestron SIMPL+®

Software

Datatype Conversions

SOURCE

DESTINATION

ACTION

INTEGER

LONG_INTEGER

Lower 2 bytes of destination = source.

 

 

Upper 2 bytes cleared.

 

 

 

INTEGER

SIGNED_INTEGER

The 2 bytes of source moved to destination.

 

 

2 byte number now treated as signed.

INTEGER

SIGNED_LONG_INTEGER

Lower 2 bytes of destination = source.

 

 

Upper 2 bytes cleared.

 

 

 

LONG_INTEGER

INTEGER

Lower 2 bytes of source moved to destination,

 

 

treated as unsigned.

LONG_INTEGER

SIGNED_INTEGER

Lower 2 bytes of source moved to destination,

 

 

treated as signed.

 

 

 

LONG_INTEGER

SIGNED_LONG_INTEGER

The 4 bytes of destination = source, now treated as

 

 

signed.

SIGNED_LONG_INTEGER

INTEGER

Lower 2 bytes of source moved to destination.

 

 

 

SIGNED_LONG_INTEGER

SIGNED_INTEGER

Lower 2 bytes of source moved to destination.

SIGNED_LONG_INTEGER

LONG_INTEGER

The 4 bytes of destination = source, now treated as

 

 

unsigned.

 

 

 

SIGNED_INTEGER

INTEGER

Lower 2 bytes of source moved to destination, 2 byte

 

 

number now treated as unsigned.

SIGNED_INTEGER

LONG_INTEGER

2 byte source is sign extended to 4 bytes

 

 

 

SIGNED_INTEGER

SIGNED_LONG_INTEGER

2 byte source is sign extended to 4 bytes

 

 

 

Language Reference Guide - DOC. 5797G

SIMPL+® z 19

Software

Crestron SIMPL+ ®

Operator Precedence & Grouping

In an expression where many operators are present, some operators have “priority” over others. Operators with the same precedence level are evaluated strictly left to right. Grouping is used to change the way an expression is evaluated.

Operator Precedence & Grouping

PRECEDENCE LEVEL

OPERATORS

1

- (Negate)

 

 

2

! NOT

3

* / S/ MOD

 

 

4

+ -

5

{{ }}

 

 

6

<< >>

7

> < >= <= S> S> S>= S<=

 

 

8

= <>

9

&

 

 

10

^

11

|

 

 

12

&&

13

||

 

 

As an example, the expression:

3+5*6

Evaluates to 33 since the multiplication is performed first. It may be beneficial to use grouping to show which operations are performed first. Grouping is simply starting an expression with '(' and ending with ')'. Therefore, the expression 3+5*6 is equivalent to 3+(5*6). Grouping is very important if you want to override the default behavior and have one piece of the expression evaluated first. Therefore, to make sure the + is evaluated first, the expression is written as (3+5)*6, for a result of 48.

20 z SIMPL+®

Language Reference Guide - DOC. 5797G

Loading...
+ 344 hidden pages