Crestron SIMPL+ Reference Manual
Crestron SIMPL+ Reference Manual

Crestron SIMPL+ Reference Manual

Language reference guide
Hide thumbs Also See for SIMPL+:
Table of Contents

Advertisement

Crestron SIMPL+
®
Software
Language Reference Guide

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the SIMPL+ and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Summary of Contents for Crestron SIMPL+

  • Page 1 Crestron SIMPL+ ® Software Language Reference Guide...
  • Page 2 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.
  • Page 3: Table Of Contents

    Software Requirements ........
  • Page 4 File Functions Overview ........116 Contents Crestron SIMPL+ Language Reference Guide - DOC. 5797G...
  • Page 5 ® Crestron SIMPL+ Software File Function Return Error Codes ....... . 117 Reading and Writing Data to a File .
  • Page 6 Software Crestron SIMPL+ ® WriteSignedLongIntegerArray ........197 WriteStringArray .
  • Page 7 ® Crestron SIMPL+ Calling a Function ..........274 Function Libraries .
  • Page 8 _OEM_PACING ..........354 Contents Crestron SIMPL+ Language Reference Guide - DOC. 5797G...
  • Page 9 Software License Agreement ........
  • Page 10 Software Crestron SIMPL+ ® This page intentionally left blank. viii Contents Language Reference Guide - DOC. 5797G...
  • Page 11: Introduction

    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.
  • Page 12: Licensing Of Simpl+ Cross Compiler

    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.
  • Page 13 (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.
  • Page 14 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.)
  • Page 15 choice.
  • Page 16 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.
  • Page 17: What's New

    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.
  • Page 18: Programming Environment

    - 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. ® SIMPL+ Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 19: Edit Preferences

    ® Crestron SIMPL+ 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.
  • Page 20 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. Language Reference Guide - DOC. 5797G Crestron SIMPL+ ®...
  • Page 21: Insert Category

    ® Crestron SIMPL+ 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.
  • Page 22 Software Crestron SIMPL+ ® Insert #CATEGORY Toolbar Pull-Down Menu in SIMPL+ Symbol Tree Category Pop-Up Window Category Selection Insertion Box ® SIMPL+ Language Reference Guide - DOC. 5797G...
  • Page 23: General Information

    ® Crestron SIMPL+ 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.
  • Page 24: Relative Path Names For Files

    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. Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 25: Operators

    ® Crestron SIMPL+ 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 Negation Multiplication Unsigned Division Signed Division Signed Modulo UMOD Unsigned Modulo Addition...
  • Page 26 X is greater or equal to Y (signed). X && Y True if X and Y are both non-zero. False otherwise. X || Y True if either X or Y is non-zero. False otherwise. Language Reference Guide - DOC. 5797G Crestron SIMPL+ ®...
  • Page 27 ® Crestron SIMPL+ String Operators OPERATOR *NOTE: Not allowed in expressions because of possible confusion with comparison. <> < > 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;...
  • Page 28: Signed Vs Unsigned Arithmetic

    32768 - Unsigned 0 - 32767 -32768 - INTEGER I, J; I = -1; J = 65535; IF (65535 S> 0) X=0; ELSE X=1; IF (65535 > 0) X=0; ELSE X=1; Crestron SIMPL+ 65535 Language Reference Guide - DOC. 5797G ®...
  • Page 29 ® Crestron SIMPL+ Datatype Conversions SOURCE INTEGER LONG_INTEGER INTEGER SIGNED_INTEGER INTEGER SIGNED_LONG_INTEGER LONG_INTEGER INTEGER LONG_INTEGER SIGNED_INTEGER LONG_INTEGER SIGNED_LONG_INTEGER SIGNED_LONG_INTEGER INTEGER SIGNED_LONG_INTEGER SIGNED_INTEGER SIGNED_LONG_INTEGER LONG_INTEGER SIGNED_INTEGER INTEGER SIGNED_INTEGER LONG_INTEGER SIGNED_INTEGER SIGNED_LONG_INTEGER Language Reference Guide - DOC. 5797G DESTINATION Lower 2 bytes of destination = source.
  • Page 30: Operator Precedence & Grouping

    + is evaluated first, the expression is written as (3+5)*6, for a result of 48. ® SIMPL+ PRECEDENCE LEVEL - (Negate) ! NOT * / S/ MOD {{ }} << >> > < >= <= S> S> S>= S<= = <> & && 3+5*6 Crestron SIMPL+ OPERATORS Language Reference Guide - DOC. 5797G ®...
  • Page 31: Numeric Formats

    ® Crestron SIMPL+ Numeric Formats Numeric (Integer) constants may be expressed in three formats; decimal, hexadecimal, or quoted character. Decimal constants are specified by writing a decimal number. Hexadecimal constants are specified by prefacing the hex constant by 0x. Quoted character constants are a single character placed between single quotes (') and have the numeric value specified on an ASCII chart.
  • Page 32: Task Switching

    Example: ® SIMPL+ DIGITAL_INPUT trig; ANALOG_OUTPUT i; INTEGER j; PUSH trig j=0; FOR(j=0 to 32000) i = j; Language Reference Guide - DOC. 5797G Crestron SIMPL+ ®...
  • Page 33 ® Crestron SIMPL+ A SIMPL program drives the trig signal and monitors the state of the analog_output with an ANALOG DEBUGGER (Speedkey: TEST2) symbol. If the system did not task switch out, the only TEST2 output would show 32000. If this program were run,...
  • Page 34 NOTE: The event is STILL reentering. It is being forced to terminate immediately and prevent reentry more than one level deep. ® SIMPL+ Running = 1; FOR(I = 0 TO 32000) // code Running = 0; FUNCTION MAIN() Running = 0; Language Reference Guide - DOC. 5797G Crestron SIMPL+ ®...
  • Page 35: Task Switching For 2-Series Control Systems

    ® Crestron SIMPL+ Task Switching for 2-Series Control Systems In the 2-Series Control Systems, each SIMPL+ module also runs as one or more concurrent tasks in the control system. The MAIN and each event handler run as separate tasks sharing a common global data space.
  • Page 36 = q; DIGITAL_INPUT diInput1, diInput2; INTEGER I, LastNumSeconds; PUSH diInput1 WHILE (diInput1) // do something main() LastNumSeconds = 0; WHILE (1) seconds = GetNumSeconds(); IF (seconds <> LastNumSeconds) // do something Language Reference Guide - DOC. 5797G Crestron SIMPL+ ®...
  • Page 37 ® Crestron SIMPL+ number of seconds. Since the allotted time for a SIMPL+ task to run is in fractions of a second, it is very unlikely to change during the allotted time. Unless the programmer puts in a DELAY which will put the task to “sleep” for a period of time, this task will dominate the CPU time.
  • Page 38 DELAY (1500); // 15 sec delay PRINT (“Event 2 done\n”); Starting Event 1 Starting Event 2 Event 2 Done Event 1 Done Starting Event 1 Starting Event 2 Event 1 Done Event 2 Done Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 39: Language Constructs & Functions

    ® Crestron SIMPL+ Language Constructs & Functions Language Constructs & Functions Overview Functions take one or more comma-separated parameters and return a result. The following template shows how each language construct and function is explained. Name: The name used to refer to the construct or function.
  • Page 40: Control System

    X-Generation (e.g., CEN-TVAV, CNMSX- AV/PRO, CNRACKX/-DP) and 2-Series control systems. SIMPL+ is not available in the control systems preceding the X generation - CNMS, CNRACK/-D/-DP, CNLCOMP/-232, and ST-CP. ® SIMPL+ Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 41: Arrays

    ® Crestron SIMPL+ Arrays Various one and two dimensional arrays are supported. All input and output arrays are 1-based, meaning that the first element has index 1, not 0. Internal variables are 0-based, meaning that the first element has index 0. In both cases, the index of the last element is the same as the dimension of the array.
  • Page 42 INTEGER MyArray[10][20]; STRING PhoneNumbers[100][32]; STRING_INPUT in$[32]; STRING_OUTPUT out$[10]; STRING_INPUT in$[5][32]; <struct_type> myStruct[10]; Crestron SIMPL+ MEANING 10 digital inputs, in[1] to in[10] 11 rows by 21 columns of data, from MyArray[0][0] to MyArray[10][20] 101 strings that are a maximum of 32 characters long, e.g.
  • Page 43: Compiler Directives

    ® Crestron SIMPL+ Compiler Directives Compiler Directives Overview Compiler directives are used by the SIMPL+ compiler to control attributes of the symbol without generating the actual SIMPL+ code. #CATEGORY Name: #CATEGORY Syntax: Description: A Category is the name of the folder in the Logic Symbols library tree where the module is shown.
  • Page 44: Crestron_Library

    Name: #CRESTRON_LIBRARY Syntax: Description: Directs the compiler to include code from a Crestron provided library. The module name specified is the Crestron Library Filename without the CSL extension. Example: Directs the compiler to include the Crestron Library “Special Integer Functions.CSL”...
  • Page 45: Default_Nonvolatile

    ® Crestron SIMPL+ #DEFAULT_NONVOLATILE Name: #DEFAULT_NONVOLATILE Syntax: Description: Program variables retain their value if hardware power is lost. The compiler will default all variables declared within the SIMPL+ module as nonvolatile. Individual variables can use the Volatile keyword to override this default. See also...
  • Page 46: Default_Volatile

    Nonvolatile keyword to override this default. See also #DEFAULT_NONVOLATILE on Example: Version: SIMPL+ Version 3.00 Control System: 2-Series only. On an X-generation system, all variables are non-volatile. ® SIMPL+ #DEFAULT_VOLATILE page #DEFAULT_VOLATILE Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 47: Define_Constant

    ® Crestron SIMPL+ #DEFINE_CONSTANT Name: #DEFINE_CONSTANT Syntax: Description: Define a <constant_value> that will be substituted anywhere in the current source file where <constant_name> is used. Example: Assigns the value of 0x03 to the variable I. Version: SIMPL+ Version 1.00 Language Reference Guide - DOC. 5797G #DEFINE_CONSTANT <constant_name>...
  • Page 48: Help

    Example: Version: SIMPL+ Version 1.00 ® SIMPL+ #HELP “<help text>” #HELP “This is line 1 of my help text” #HELP “This is line 2 of my help text” Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 49: Help_Begin

    ® Crestron SIMPL+ #HELP_BEGIN … #HELP_END Name: #HELP_BEGIN … #HELP_END Syntax: Description: The #HELP_BEGIN, #HELP_END pair makes it easier to create help since each line does not need a separate #HELP directive. When F1 is hit either on the symbol in the Symbol Library, in either the Program View or the Detail view, the help text will be displayed.
  • Page 50: Hint

    The #HINT shows up in the status bar and provides a short tactical clue as to the function of the symbol, in the same way that Crestron-defined built-in symbols do. If the hint is specified, it will be visible when the symbol is highlighted in the User Modules section of the Symbol Library.
  • Page 51: If_Defined

    ® Crestron SIMPL+ #IF_DEFINED … #ENDIF Name: #IF_DEFINED … #ENDIF Syntax: Description: Results in compilation of the <code> only if <constant_name> has previously been defined. This construct is generally useful for putting in code for debugging purposes, giving the ability to easily turn the debugging on and off during compilation.
  • Page 52: Symbol_Name

    “Checksum Program.USP”, the tree views will show “Checksum Program” as the name. Example: Version: SIMPL+ Version 1.00 ® SIMPL+ #SYMBOL_NAME “<name of symbol>” #SYMBOL_NAME “My SIMPL+ Program” Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 53: User_Library

    ® Crestron SIMPL+ #USER_LIBRARY Name: #USER_LIBRARY Syntax: Description: Directs the compiler to include code from a User written library. The module name specified is the User Library Filename without the USL extension that is used by User Libraries. Pathnames are not allowed as the USL modules are stored in the User SIMPL+ path (refer to Edit | Preferences | Paths in SIMPL Windows).
  • Page 54: If_Not_Defined

    SIMPL+ Version 2.00 ® SIMPL+ #IF_NOT_DEFINED <constant_name> <code> #ENDIF #DEFINE_CONSTANT DEBUG 1 DIGITAL_OUTPUT OUT$; INTEGER I; FOR(I=0 to 20) #IF_DEFINED DEBUG PRINT(“Loop index I = %d\n”, I); #ENDIF #IF_NOT_DEFINED_DEBUG OUT$ = ITOA(I); #ENDIF Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 55: Declarations

    ® Crestron SIMPL+ Declarations Declarations Overview Declarations control the name, type, and number of inputs and outputs on a SIMPL+ symbol. The name is shown as a cue on the symbol in SIMPL Windows and is used as the variable name in the body of the SIMPL+ program. When the symbol is drawn in SIMPL Windows, the inputs are shown in the order of DIGITAL_INPUTs, ANALOG_INPUTs, STRING_INPUTs.
  • Page 56: Fixed And Variable Size Arrays

    1, assigning "off" sets that variable to 0. The following shows equivalent, given that VALUE is a DIGITAL_OUTPUT: ® SIMPL+ DIGITAL_INPUT YesVotes[10] DIGITAL_INPUT NoVotes[10} DIGITAL_INPUT AbstainVotes[10,5]; VALUE = 1; VALUE = on; VALUE = 0; VALUE = off; Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 57: Analog_Input

    ® Crestron SIMPL+ ANALOG_INPUT Name: ANALOG_INPUT Syntax: Description: Routes analog inputs from the outside SIMPL program into a SIMPL+ program with the specified variable names. ANALOG_INPUT values are 16-bit numbers. They are treated as signed or unsigned values inside of a SIMPL+ program depending on the operators or functions being used.
  • Page 58: Analog_Output

    For an array of ANALOG_OUTPUTs, the maximum value of SIZE is 65535. Valid indices are 1 through the specified size. ® SIMPL+ ANALOG_OUTPUT <var1>[,<var2>...]; ANALOG_OUTPUT <var[size]>; ANALOG_OUTPUT<var[size[,<min>]]>; Crestron SIMPL+ page page 31, and Declarations on Language Reference Guide - DOC. 5797G ®...
  • Page 59 ® Crestron SIMPL+ Example: Signifies that one analog input is being sent from the SIMPL+ program to the SIMPL program. Signifies that up to 25 analog outputs, referred to as LEVELS[1] through LEVELS[25] are being sent from the SIMPL+ program to the SIMPL program.
  • Page 60 SIMPL+ Version 2.00 for BUFFER_INPUT arrays and MAX_LENGTH to 65535. SIMPL+ Version 1.00 for everything else. ® SIMPL+ BUFFER_INPUT <var1[max_length]>[,<var2[max_length]>...]; BUFFER_INPUT <var[size][max_length]>; BUFFER_INPUT<var[size[,<min>]][max_length]>; BUFFER_INPUT FromComPort[100]; BUFFER_INPUT ComBuffers[2][100]; BUFFER_INPUT ComBuffers[2,2][100]; Crestron SIMPL+ page page 31, and Declarations on page Language Reference Guide - DOC. 5797G ®...
  • Page 61: Digital_Input

    ® Crestron SIMPL+ DIGITAL_INPUT Name: DIGITAL_INPUT Syntax: Description: Routes digital inputs from the outside SIMPL program into a SIMPL+ program under the specified variable names. DIGITAL_INPUT values are either 0 (digital low) or 1 (digital high). Refer to the discussion on arrays on NOTE: DIGITAL_INPUT variables may not be passed to functions in Version 3.00...
  • Page 62: Digital_Output

    For an array of DIGITAL_OUTPUTs, the maximum value of SIZE is 65535. Valid indices are 1 through the specified size. ® SIMPL+ DIGITAL_OUTPUT <var1>[,<var2>...]; DIGITAL_OUTPUT <var[size]>; DIGITAL_OUTPUT <var[size[,<min>]]>; page DIGITAL_OUTPUT State1; State1=1; State1=0; Crestron SIMPL+ page 31, and Declarations on Language Reference Guide - DOC. 5797G ®...
  • Page 63 ® Crestron SIMPL+ Example: Signifies that two digital signals are to be sent to a SIMPL program from this SIMPL+ program. NOTE: For example, if State1 is jammed high via a BUFFER from outside the SIMPL+ program, the value of State1 becomes 1 and should be handled accordingly in the SIMPL+ code.
  • Page 64: Integer

    #DEFAULT_VOLATILE or overridden using the nonvolatile or volatile keywords. NOTE: If no RETURN statement is encountered, the function automatically returns a 0. ® SIMPL+ INTEGER <var1>[,<var2>...]; INTEGER <var1>[size] [,<var2>[size]…]; INTEGER <var1>[rows1][columns1] [,<var2>[rows2][columns2]…]; Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 65 ® Crestron SIMPL+ Example: Specifies one locally declared INTEGER in this SIMPL+ program Specifies an array of three INTEGERS that can be referenced under the name CommandBytes. In pictorial form, it appears as: Specifies a two-dimensional array of integers five rows deep by four columns wide.
  • Page 66: Long_Integer

    NOTE: (2-Series) LONG_INTEGERs can be volatile or non-volatile. The default is defined using the compiler directives #DEFAULT_NONVOLATILE or #DEFAULT_VOLATILE or overridden using the nonvolatile or volatile keywords. ® SIMPL+ LONG_INTEGER <var1>[,<var2>...]; LONG_INTEGER <var1>[size] [,<var2>[size]…]; LONG_INTEGER <var1>[rows1][columns1] [,<var2>[rows2][columns2]…]; Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 67 ® Crestron SIMPL+ Example: Specifies one locally declared LONG_INTEGER in this SIMPL+ program Specifies an array of three LONG_INTEGERs that can be referenced under the name CommandBytes. In pictorial form, it appears as: CommandBytes[0] Specifies a two-dimensional array of LONG_INTEGERs five rows deep by four columns wide.
  • Page 68: Signed_Integer

    NOTE: (2-Series) SIGNED_INTEGERs can be volatile or non-volatile. The default is defined using the compiler directives #DEFAULT_NONVOLATILE or #DEFAULT_VOLATILE or overridden using the nonvolatile or volatile keywords. ® SIMPL+ SIGNED_INTEGER <var1>[,<var2>...]; SIGNED_INTEGER <var1>[size] [,<var2>[size]…]; SIGNED_INTEGER <var1>[rows1][columns1] [,<var2>[rows2][columns2]…]; Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 69 ® Crestron SIMPL+ Example: Specifies one locally declared SIGNED_INTEGER in this SIMPL+ program Specifies an array of three SIGNED_INTEGERS that can be referenced under the name CommandBytes. In pictorial form, it appears as: CommandBytes[0] Specifies a two-dimensional array of integers five rows deep by four columns wide.
  • Page 70: Signed_Long_Integer

    NOTE: (2-Series) SIGNED_LONG_INTEGERs can be volatile or non-volatile. The default is defined using the compiler directives #DEFAULT_NONVOLATILE or #DEFAULT_VOLATILE or overridden using the nonvolatile or volatile keywords. ® SIMPL+ SIGNED_LONG_INTEGER <var1>[,<var2>...]; SIGNED_LONG_INTEGER <var1>[size] [,<var2>[size]…]; SIGNED_LONG_INTEGER <var1>[rows1][columns1] [,<var2>[rows2][columns2]…]; Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 71 ® Crestron SIMPL+ Example: Specifies one locally declared SIGNED_LONG_INTEGER in this SIMPL+ program Specifies an array of three SIGNED_LONG_INTEGERs that can be referenced under the name CommandBytes. In pictorial form, it appears as: CommandBytes[0] Specifies a two-dimensional array of SIGNED_LONG_INTEGERs five rows deep by four columns wide.
  • Page 72: String

    NOTE: (2-Series) STRINGs can be volatile or non-volatile. The default is defined using the compiler directives #DEFAULT_NONVOLATILE or #DEFAULT_VOLATILE or overridden using the nonvolatile or volatile keywords. ® SIMPL+ STRING <var1[size1]>[,<var2[size2]>...]; STRING <var1[num_elements1][num_characters1]>[, <var2[num_elements2][num_characters2]>...]; Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 73 ® Crestron SIMPL+ Example: Signifies that one local STRING is declared in this SIMPL+ program. Signifies that three strings of 10 characters long have been allocated. To assign values, the following would be legal: Version: SIMPL+ Version 2.00 for SIZE and NUM_CHARACTER up to 65535.
  • Page 74: String_Input

    SIMPL+ Version 1.00 for everything else. ® SIMPL+ STRING_INPUT <var1[max_size1]>[,<var2[max_size2]>...]; STRING_INPUT <var[size][max_size]>; STRING_INPUT <var[size[,<min>]][max_size]>; STRING_INPUT FirstName[100], SecondName[25]; STRING_INPUT DataBaseNames[9][100]; STRING_INPUT Database Names [9,3][100]; Crestron SIMPL+ page page 31, and Declarations on page 45 Language Reference Guide - DOC. 5797G ®...
  • Page 75: String_Output

    ® Crestron SIMPL+ STRING_OUTPUT Name: STRING_OUTPUT Syntax: Description: Routes serial strings from the SIMPL+ program to the SIMPL program. A string length is not required as the output string buffer management is performed by the operating system. Refer to the discussion on arrays on NOTE: These outputs may be jammed with other serial string signals in the SIMPL program, although the value does not propagate back into the SIMPL+ symbol.
  • Page 76 SIMPL+ Version 3.00 - can no longer be passed to functions by reference. (2-Series Control Systems only) SIMPL+ Version 2.00 for STRING_OUTPUT arrays. SIMPL+ Version 1.00 for everything else. ® SIMPL+ STRING_OUTPUT TheName$; STRING_OUTPUT SortedNames$[5]; STRING_OUTPUT SortedNames$[5,5]; Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 77: Structures

    ® Crestron SIMPL+ STRUCTURES A structure is a collection of one or more variables grouped together under a single name. These variables, called structure fields or members, may consist of both integer and string datatypes. Structures help organize related data because they allow variables to be grouped together as a unit instead of as separate entities.
  • Page 78: Control System

    If ( OneEntry.Name = “David” ) Return; If ( Entry[5].Name = “David” ) Return; FUNCTION myFunction ( PhoneBookEntry argOneEntry, PhoneBookEntry argEntry[] ) if ( argOneEntry.Name = “David” ) return; if ( argEntry[5].Name = “David” ) return; Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 79 ® Crestron SIMPL+ Declaration Modifiers Volatile Name: Volatile Syntax: NOTE: This is not a declaration but a declaration modifier. It works only in conjunction with another declaration keyword. Description: Global integer and string program variables will not retain their value if hardware power is lost.
  • Page 80: Nonvolatile

    Example: Version: SIMPL+ Version 3.00 Control System: 2-series only. The X-generation processors will give a message that says all variables are non-volatile. ® SIMPL+ Nonvolatile Nonvolatile integer n; Nonvolatile string s[100]; Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 81: E-Mail Functions

    ® Crestron SIMPL+ E-mail Functions Important SendMail Considerations Language Reference Guide - DOC. 5797G 1. In the SIMPL+ function call to “Send Mail”, the parameters “Mailserv”, “To” and “From” fields are MANDATORY, whereas “cc”, “subject” and “message” are not. 2. Only the “SMTP AUTH” authentication type with “LOGIN”...
  • Page 82 SMTP_SEND_FAILURE SMTP FAILURES (RECOVERABLE ERRORS) ERROR CODE SMTP_FAILURE_TO_RCPT_COMMAND SMTP_FAILURE_CC_RCPT_COMMAND SMTP_FAILURE_DATA_COMMAND ® SIMPL+ Crestron SIMPL+ DESCRIPTION Success DESCRIPTION Any non-recoverable error from the e-mail module of the firmware (for example: if “mailserver”, “from” and “to” are empty). General internal error. Failure to connect to the mailserver.
  • Page 83: Sendmail

    ® Crestron SIMPL+ SendMail Name: SendMail Syntax: Description: Send an e-mail message using SMTP protocol. Parameters: Server - Required. Specifies address of the mail server. It can either be an IP address in dot-decimal notation (ex: 192.168.16.3) or a name to be resolved with a DNS server (ex: mail.myisp.com).
  • Page 84 = SendMail( “192.168.16.3”, “UserLogonName”, “UserLogonPassword”, “SenderEmailAddress@crestron.com”, “RecipientEmailAddress@crestron.com”, “ccEmailAddress@crestron.com”, “This is the subject”, “This is the message” ); if ( nErr < 0 ) Print( “Error sending e-mail\n” ); else Print( “SendMail successful!\n ); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 85: Events Overview

    ® Crestron SIMPL+ Events Events Overview SIMPL+ is an event driven language. There are four functions which deal with activating events in a given SIMPL+ program; CHANGE, EVENT, PUSH, and RELEASE. CHANGE Name: CHANGE Syntax: Description: <variable_name> may be either a DIGITAL_INPUT, ANALOG_INPUT, or STRING_INPUT type.
  • Page 86 STRING_INPUT some_data$[100]; ANALOG_OUTPUT level; CHANGE some_data$ level=48; ANALOG_INPUT ThingsToAdd[20]; ANALOG_OUTPUT Sum; INTEGER I, Total; CHANGE ThingsToAdd Total=0; FOR(I=0 to 20) if (IsSignalDefined (ThingsToAdd[I])) Total = Total + ThingsToAdd[I]; Sum = Total; Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 87: Event

    ® Crestron SIMPL+ EVENT Name: EVENT Syntax: Description: Executes the defined <statements> anytime one of the inputs to the SIMPL+ symbol changes. It is similar to having a CHANGE statement listed for every input, and each change is set up to execute a common block of code. Refer to “Stacked Events” on...
  • Page 88: Push

    PUSH <variable_name1> [, <variable_name2> ...] [Local Variable Definitions] <statements> for a method of detecting a change to an individual element. page DIGITAL_INPUT trigger; STRING_OUTPUT output$; PUSH trigger output$ = “Hello, World!”; Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 89: Release

    ® Crestron SIMPL+ Release Name: RELEASE Syntax: Description: <variable_name> is a DIGITAL_INPUT type. On the trailing edge of <variable_name>, the statements between the opening { and closing } are executed. When using DIGITAL_INPUT arrays, only a change in the entire array can be detected, not an individual element.
  • Page 90: Stacked Events

    CHANGE statements in the order they appear in the source EVENT statement PUSH var1, var2 // code STRING_INPUT A$[100]; DIGITAL_INPUT IN1, IN2, IN3, IN4; ANALOG_INPUT LEVEL; ANALOG_INPUT PRESETS[5]; PUSH IN1 PUSH IN2 CHANGE IN3, LEVEL, A$, PRESETS RELEASE IN3, IN4 // code Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 91 ® Crestron SIMPL+ Expressions & Statements An expression consists of operators and operands. i.e., Statements consist of function calls, expressions, assignments, or other instructions. There are two types of statements, Simple and Complex. A simple statement ends with a semicolon (;). Examples of simple statements are: A complex statement is a collection of simple statements that start with '{' and end with '}'.
  • Page 92 X after it is incremented to the computer port of the control system. Version: SIMPL+ Version 1.00 ® SIMPL+ <statements> [}] UNTIL (<expression>); INTEGER X; X=0; X = X + 1; PRINT(“X = %d\n”, X); UNTIL (X = 25); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 93: For

    ® Crestron SIMPL+ Name: Syntax: Description: This loop executes the <statements> while <variable> iterates from the value of <start_expression> to the value of <end_expression>. The variable is incremented by <step_expression> at the end of the loop, if STEP is specified, else it is incremented by 1.
  • Page 94 Version: SIMPL+ Version 1.00 ® SIMPL+ STRING_INPUT IN$[100]; INTEGER X; FOR (X = 1 TO LEN(IN$)) PRINT(“Character %d of String %s is %s\n”, X, IN$, MID(IN$, X, 1)); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 95: While

    ® Crestron SIMPL+ WHILE Name: WHILE Syntax: Description: This loop performs a set of <statements> as long as <expression> does not evaluate to zero. If only one statement is present in the body of the loop, then the { and } characters are not required, but may be used.
  • Page 96: Branching & Decision Constructs

    69. Otherwise, the loop will exit via the normal termination condition. Version: SIMPL+ Version 1.00 ® SIMPL+ BREAK; INTEGER X; ANALOG_INPUT Y; X=0; WHILE(X<25) IF(Y = 69) BREAK; X = X + 1; PRINT(“X=%d\n”, X); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 97: Cswitch

    ® Crestron SIMPL+ CSWITCH Name: CSWITCH Syntax: NOTE: In SIMPL+ v3.01.00 and later, the 'break' statement is required to terminate the case statement block that it resides within. If no 'break' statement exists, the program will continuing executing to the next case statement block or default statement block.
  • Page 98: Control System

    CASE (3): X = AIN; // continue executing to next case statement block ==> case(5) CASE (5): X = X + AIN + 1; break; DEFAULT: PRINT(“Unknown command %d!\n”, AIN); break; Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 99: If - Else

    ® Crestron SIMPL+ IF - ELSE Name: IF - ELSE Syntax: Since <statements> can be an IF construct, you can string out a series of IF-ELSE-IF statements of the form: NOTE: A final ELSE may be used to express default handling if none of the previous conditions were met.
  • Page 100 X=5; Y$ = IN$; ELSE X=6; Y$ = ““; IF (IN$ = “STRING1”) X=5; Y$ = IN$; ELSE IF (IN$=”STRING2”) X=6; Y$ = ““; ELSE X = 7; Y$ = “ZZZ”; Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 101: Switch

    ® Crestron SIMPL+ SWITCH Name: SWITCH Syntax: NOTE: Many CASE statements may be used in the body of the SWITCH. Description: SWITCH is a more direct method of writing a complex IF-ELSE-IF statement. In the SWITCH, if <expression> is equal to <expression1>, <statements1> is executed. If <expression>...
  • Page 102 SIMPL+ Version 1.00 with 32 CASE statements maximum ® SIMPL+ ANALOG_INPUT AIN; INTEGER X; SWITCH(AIN) CASE (2): X = 0; CASE (3): X = AIN; CASE (5): X = AIN + 1; DEFAULT: PRINT(“Unknown command %d!\n”, AIN); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 103: Array Operations

    ® Crestron SIMPL+ Array Operations Array Operations Overview Array Operations functions are used to perform generalized operations on arrays, such as getting bounds and setting the elements of an array to a known value in a given SIMPL+ program. GetLastModifiedArrayIndex...
  • Page 104 INTERLOCKED_LIGHT_SCENES[GetLastModifiedArrayIndex()] = DIGITAL_INPUT LIGHT_SCENES[10]; DIGITAL_OUTPUT INTERLOCKED_LIGHT_SCENES[10]; INTEGER I; PUSH LIGHT_SCENES,MORE_LIGHT_SCENES {//this PUSH statement will be called twice (once for LIGHT_SCENES and once for MORE_LIGHT_SCENES) FOR(I=1 to 10) INTERLOCKED_LIGHT_SCENES[I]=0 ProcessLogic(); INTERLOCKED_LIGHT_SCENES[GetLastModifiedArrayIndex()] = Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 105: Getnumarraycols

    ® Crestron SIMPL+ GetNumArrayCols Name: GetNumArrayCols Syntax: Description: Finds the number of columns in a two-dimensional array or the size of the array for a one-dimensional array. Parameters: ARRAY_NAME is the array as determined by the size. Return Value: For the data types in the table after this paragraph, the return value of GetNumArrayCols is shown.
  • Page 106 Software Example: In this example, Columns = 20 will be printed. Version: SIMPL+ Version 2.00 ® SIMPL+ DIGITAL_INPUT TEST; INTEGER My_Array[10][20]; PUSH TEST PRINT(“Columns = %d\n”, GetNumArrayCols(My_Array)); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 107: Getnumarrayrows

    ® Crestron SIMPL+ GetNumArrayRows Name: GetNumArrayRows Syntax: Description: Returns the number of rows for two-dimensional arrays. One-dimensional arrays return 0. Parameters: ARRAY_NAME is the array name as determined by the size. Return Value: For the data types in the table after this paragraph, the return value of GetNumArrayRows is shown.
  • Page 108: Setarray

    Each string in ARRAY_NAME is initialized to CHR (INIT_VALUE). STRING Each string in ARRAY_NAME is set equal to INIT_VALUE. IF INIT_VALUE is longer than the maximum size allowed in the array, it is truncated. Crestron SIMPL+ MEANING Language Reference Guide - DOC. 5797G ®...
  • Page 109 ® Crestron SIMPL+ Example: The first line initializes all elements of the integer array Levels to contain the integer The second line attempts to initialize the elements of the integer array Levels with a string value - an ATOI is done on the “3”, which returns a 3, so that the end result is the same as the first line.
  • Page 110: Bit & Byte Functions

    “c” in SOURCE). ® SIMPL+ INTEGER Bit(STRING SOURCE, INTEGER SOURCE_BYTE, INTEGER BIT_IN_BYTE); Actual Byte in SOURCE = (BIT_IN_BYTE / 8) + SOURCE_BYTE Actual Bit in Actual Byte = (BIT_IN_BYTE MOD 8) Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 111 ® Crestron SIMPL+ Example: This example takes an input string and creates an output string containing the elements of the input string that do not have the most significant bit (bit 7) set. Version: SIMPL+ Version 1.00 Language Reference Guide - DOC. 5797G STRING_INPUT SOURCE$[100];...
  • Page 112: Byte

    INTEGER Byte (STRING SOURCE, INTEGER SOURCE_BYTE); STRING_INPUT IN$[100]; CHANGE IN$ IF(BYTE(IN$,1) = 02) SWITCH(BYTE(IN$,2)) CASE (65): // Process Command type 65 (A) here. CASE (66): // Process Command type 66 (B) here. Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 113: High

    ® Crestron SIMPL+ High Name: High Syntax: Description: Returns the upper (most significant) 8-bits of an Integer. Parameters: VALUE is an integer containing the value of the most significant byte. Return Value: The upper 8-bits of the passed value. Example: This will print the input value and the upper 8-bits of the value in hexadecimal.
  • Page 114: Low

    VALUE is 0x1234, then the output is: Version: SIMPL+ Version 1.00 ® SIMPL+ INTEGER Low(INTEGER VALUE) ANALOG_INPUT VALUE; CHANGE VALUE PRINT(“The lower byte of %X is %X\n”, VALUE, LOW(VALUE)); The lower byte of 1234 is 34. Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 115: Rotateleft

    ® Crestron SIMPL+ RotateLeft Name: RotateLeft Syntax: Description: Rotate X to the left (more significant direction) by Y bits; full 16 bits used. Same as {{ operator. See RotateRight on Parameters: X is the INTEGER to have bits rotated Y is the amount of bits to rotate Return Value: An INTEGER containing the result of the rotated bits.
  • Page 116: Rotateright

    If X = 0x1234 and Y is 1 then result is 0x091A Version: SIMPL+ Version 3.01.06 ® SIMPL+ INTEGER RotateRight( INTEGER X, INTEGER Y ); INTEGER X, Y, result; result = RotateRight( X, Y ); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 117: Rotateleftlong

    ® Crestron SIMPL+ RotateLeftLong Name: RotateLeftLong Syntax: Description: Rotate X to the left by Y bits; full 32 bits used. Parameters: X is the LONG_INTEGER to have bits rotated Y is the amount of bits to rotate Return Value: A LONG_INTEGER containing the result of the rotated bits.
  • Page 118: Rotaterightlong

    A LONG_INTEGER containing the result of the rotated bits. Example: Version: SIMPL+ Version 3.01.06 ® SIMPL+ LONG_INTEGER RotateRightLong( LONG_INTEGER X, INTEGER Y LONG_INTEGER X, Y, result; result = RotateRightLong( X, Y ); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 119: Data Conversion Functions

    ® Crestron SIMPL+ Data Conversion Functions Data Conversion Functions Overview These functions take one form of data (integer or string) and convert it to the opposite type in a given SIMPL+ program. Usually, these functions are for converting number stored in strings to integers, or for converting numbers stored in integers to strings.
  • Page 120: Atol

    Version: SIMPL+ Version 3.00.02 Control System 2-Series Only ® SIMPL+ LONG_INTEGER Atol(STRING SOURCE); STRING_INPUT IN$[100]; LONG_INTEGER VAL; CHANGE IN$ VAL = ATOL(IN$); PRINT(“Value of %s after ATOL is %ld\n”, IN$, VAL); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 121: Chr

    ® Crestron SIMPL+ Name: Syntax: Description: Takes the integer value specified and returns the corresponding ASCII character as a one-byte string. Parameters: CODE contains a number from 0 to 255 to be converted into an ASCII string. Return Value: A string representing the code. If CODE is greater than 255, lower 8-bits of CODE are used in the computation.
  • Page 122: Itoa

    For example, if VALUE was equal to 25, Code$ would contain the string “25”. Version: SIMPL+ Version 1.00 ® SIMPL+ STRING ItoA(INTEGER CODE); out$ = itoa(CODE); makestring(out$, “%d”, CODE); STRING_OUTPUT Code$; ANALOG_INPUT VALUE; CHANGE VALUE Code$ = ITOA(VALUE); PRINT(“Code = %s\n”, Code$); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 123: Itohex

    ® Crestron SIMPL+ ItoHex Name: ItoHex Syntax: Description: Takes the value in CODE and creates a string containing the hexadecimal equivalent. The output string does not contain leading zeros and is expressed in uppercase. Parameters: CODE contains a number from 0 to 65535 to be converted into a hexadecimal string.
  • Page 124: Ltoa

    SIMPL+ Version 3.00.07 Control System 2-Series Only ® SIMPL+ STRING LtoA(LONG_INTEGER CODE); out$ = ltoa(CODE); makestring(out$, “%ld”, CODE); STRING_OUTPUT Code$; LONG_INTEGER VALUE; CHANGE VALUE Code$ = LTOA(VALUE); PRINT(“Code = %s\n”, Code$); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 125: Ltohex

    ® Crestron SIMPL+ LtoHex Name: LtoHex Syntax: Description: Takes the value in CODE and creates a string containing the hexadecimal equivalent. The output string does not contain leading zeros and is expressed in uppercase. Parameters: CODE contains a number from 0 to 2147483647 to be converted into a hexadecimal string.
  • Page 126: File Functions

    (This code will get called when the system starts up) ******************************************************/ Function Main() SIGNED_INTEGER nNumWritten; StartFileOperations(); nFileHandle = FileOpen ( “\\CF0\\MyFile”, _O_WRONLY ); if ( nFileHandle >= 0 ) sBuf = “Hello World!”; nNumWritten=FileWrite( nFileHandle, sBuf, 500 ); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 127: File Function Return Error Codes

    ® Crestron SIMPL+ File Function Return Error Codes KEYWORD FILE_BAD_USER FILE_NO_DISK FILE_LONGPATH FILE_INVNAME FILE_PEMFILE FILE_BADFILE FILE_ACCES FILE_NOSPC FILE_SHARE FILE_NOFILE FILE_EXIST FILE_NVALFP FILE_MAXFILE_SIZE FILE_NOEMPTY FILE_INVPARM FILE_INVPARCMB FILE_NO_MEMORY FILE_NO_BLOCK FILE_NO_FINODE FILE_NO_DROBJ FILE_IO_ERROR FILE_INTERNAL Language Reference Guide - DOC. 5797G if(nNumWritten<0) Print (“WriteError”);...
  • Page 128: Reading And Writing Data To A File

    PC and read on another, e.g. a Crestron control system, or vice versa. Most programmers are used to writing programs that are both written by a PC and read by a PC.
  • Page 129: Checkfordisk

    ® Crestron SIMPL+ CheckForDisk Name: CheckForDisk Syntax: Description: Tests whether or not a compact flash card is currently installed in the control system. Parameters: None. Return Value: Returns 1 if a compact flash card is currently installed in the control system. Refer to “WaitForNewDisk()”...
  • Page 130: Endfileoperations

    IF ( StartFileOperations() < 0 ); PRINT ( “Error in starting file ops\n” ); // various file operations IF ( EndFileOperations() < 0 ) PRINT ( “Error Occurred in ending file ops\n” ); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 131: Filebof

    ® Crestron SIMPL+ FileBOF Name: FileBOF Syntax: Description: Tests whether or not the current file pointer is at the beginning of the file. Parameters: HANDLE specifies the file handle of the previously opened file (from FileOpen). Return Value: Returns 1 if beginning of file or 0 if not end of file. Otherwise, file error code is returned.
  • Page 132: Fileclose

    IF (nFileHandle < 0) PRINT(“Error Opening File MyFile\n”); return; IF ( nFileHandle > 0 ) IF ( FileClose ( nFileHandle ) <> 0 ) PRINT ( “Error closing file\n” ); EndFileOperations(); Crestron SIMPL+ page 183. Language Reference Guide - DOC. 5797G ®...
  • Page 133: Filedate

    ® Crestron SIMPL+ FileDate Name: FileDate Syntax: Description: Returns a string corresponding to the current date of the specified file with the specified FORMAT. Parameters: INFO – structure containing the information about a found file (refer to "FindFirst" on page FORMAT is an integer describing the way to format the date for the return.
  • Page 134: Control System

    WHILE (Found = 0) TheDate$ = FileDate(FileInfo); PRINT ( “Date of file = %s\n”, TheDate$ ); Found = FindNext(FileInfo); IF ( FindClose() < 0 ) PRINT ( “Error in closing find operation\n” ); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 135: Fileday

    ® Crestron SIMPL+ FileDay Name: FileDay Syntax: Description: Returns the day of the week of the file as a STRING. Parameters: INFO – structure containing the information about a found file (refer to “FindFirst” on page Return Value: The day of the week of the file is returned in a string. Valid returns are Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, or Saturday.
  • Page 136: Filedelete

    SIMPL+ Version 3.00.02 or higher (Pro 2 only) Control System: 2-Series Only ® SIMPL+ SIGNED_INTEGER FileDelete (STRING filename) StartFileOperations(); IF ( FileDelete ( “MyFile” ) <> 0 ) PRINT ( “Error deleting file\n” ); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 137: Fileeof

    ® Crestron SIMPL+ FileEOF Name: FileEOF Syntax: Description: Tests whether or not the current file pointer is at the end of the file. Parameters: HANDLE specifies the file handle of the previously opened file (from FileOpen). Return Value: Returns 1 if end of file or 0 if not end of file. Otherwise, file error code is returned.
  • Page 138: Filegetdatenum

    NumDateOfMonth = FileGetDateNum(FileInfo); PRINT ( “Day of the month of file = %d\n”, NumDateOfMonth); Found = FindNext(FileInfo); IF ( FindClose() < 0 ) PRINT ( “Error in closing find operation\n” ); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 139: Filegetdayofweeknum

    ® Crestron SIMPL+ FileGetDayOfWeekNum Name: FileGetDayOfWeekNum Syntax: Description: Returns an integer corresponding to the day of the week of file. Parameters: INFO – structure containing the information about a found file (refer to "FindFirst" on page Return Value: The day of the week as an integer from 0 to 6; 0 represents Sunday to 6 representing Saturday.
  • Page 140: Filegethournum

    WHILE (Found = 0) NumHours = FileGetHourNum(FileInfo); PRINT ( “Hours of file time = %d\n”, NumHours); Found = FindNext(FileInfo); IF ( FindClose() < 0 ) PRINT ( “Error in closing find operation\n” ); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 141: Filegetminutesnum

    ® Crestron SIMPL+ FileGetMinutesNum Name: FileGetMinutesNum Syntax: Description: Returns an integer corresponding to the number of minutes in the file time. Parameters: INFO – structure containing the information about a found file (refer to "FindFirst" on page Return Value: The number of minutes from 0 to 59.
  • Page 142: Filegetmonthnum

    NumMonth = FileGetMonthNum(FileInfo); PRINT ( “Month of file date = %d\n”, NumMonth); Found = FindNext(FileInfo); IF ( FindClose() < 0 ) PRINT ( “Error in closing find operation\n” ); End File Operations() Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 143: Filegetsecondsnum

    ® Crestron SIMPL+ FileGetSecondsNum Name: FileGetSecondsNum Syntax: Description: Returns an integer corresponding to the number of seconds in the time of the file. Parameters: INFO – structure containing the information about a found file (refer to "FindFirst" on page Return Value: The number of seconds from 0 to 59.
  • Page 144: Filegetyearnum

    WHILE (Found = 0) NumYear = FileGetYearNum(FileInfo); PRINT ( “Year of file date = %d\n”, NumYear); Found = FindNext(FileInfo); IF ( FindClose() < 0 ) PRINT ( “Error in closing find operation\n” ); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 145: File_Info Structure

    ® Crestron SIMPL+ FILE_INFO Structure Use this structure to retrieve information about a file. File Attribute Bit Flags - KEYWORD ARDONLY AHIDDEN ASYSTEM AVOLUME ADIRENT ARCHIVE Version: SIMPL+ Version 3.00.02 or higher (Pro 2 only) NOTE: For an example of how and where to use the FILE_INFO structure, refer to the example code in "FindFirst"...
  • Page 146: Filelength

    IF ( nFileHandle > 0 ) PRINT ( “Length of file = %d\n”, FileLength ( nFileHandle ) ); IF ( FileClose ( nFileHandle ) <> 0 ) PRINT ( “Error closing file\n” ); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 147: Filemonth

    ® Crestron SIMPL+ FileMonth Name: FileMonth Syntax: Description: Returns the month of the file date as a string. Parameters: INFO – structure containing the information about a found file (refer to "FindFirst" on page Return Value: The current month is returned in a string. Valid returns are January, February, March, April, May, June, July, August, September, October, November, or December.
  • Page 148: Fileopen

    Open succeeds only if file doesn't already exist Truncates file. Mutually exclusive with _O_APPEND Open file for reading only Open file for both reading and writing Open file for writing only Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 149 ® Crestron SIMPL+ Examples: (Refer to "File Functions Overview"on page 116) Example 1: Open a read only file: Example 2: Open an existing file to log data to the end Example 3: Truncate an existing file and get rid of previous contents. If it does not exist, create it.
  • Page 150 Software Version: SIMPL+ Version 3.00.02 or higher (Pro 2 only) Control System: 2-Series Only ® SIMPL+ Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 151: Fileread

    ® Crestron SIMPL+ FileRead Name: FileRead Syntax: Description: Reads data from a file as a series of bytes into a buffer, starting at the current file position. Refer to the section entitled “Reading and Writing Data to a File” on page...
  • Page 152 IF (nFileHandle >= 0) WHILE (FileRead(nFileHandle, sBuf, 4096) > 0) PRINT ( “Read from file: %s\n”, sBuf ); IF ( FileClose ( nFileHandle ) <> 0 ) PRINT ( “Error closing file\n” ); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 153: Fileseek

    ® Crestron SIMPL+ FileSeek Name: FileSeek Syntax: Description: Positions the current file pointer. Parameters: HANDLE specifies the file handle of previously opened file (from FileOpen). OFFSET specifies the number of bytes to move relative to the origin. ORIGIN is on of the file seek flags in the following table.
  • Page 154: Other Examples

    2. Go to end of file: FileSeek (nFileHandle, O, SEEK_END) 3. Get current file position: CurrentBytePosition= FileSeek (nFileHandle,O, Version: SIMPL+ Version 3.00.02 or higher (Pro 2 only) Control System: 2-Series Only ® SIMPL+ SEEK_CUR) Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 155: Filetime

    ® Crestron SIMPL+ FileTime Name: FileTime Syntax: Description: Returns a string containing the current system time. Parameters: INFO – structure containing the information about a found file (refer to "FindFirst" on page Return Value: The return string contains the time in HH:MM:SS format, in 24-hour time. If a value is not two digits wide, it is padded with leading zeros.
  • Page 156 Number of bytes written to the file. If the return value is negative, it is an error code. ® SIMPL+ SIGNED_INTEGER FileWrite (INTEGER handle, STRING buffer, INTEGER count ) for a discussion of when to use this function and when to use the related functions Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 157 ® Crestron SIMPL+ Example: (Refer to "File Functions Overview"on page 116) Version: SIMPL+ Version 3.01 or higher (Pro 2 only) Control System: 2-Series Only Language Reference Guide - DOC. 5797G SIGNED_INTEGER nFileHandle; STRING sBuf [ 4096 ]; StartFileOperations(); sBuf = “Hello World!”;...
  • Page 158: Findclose

    Found = FindFirst(“*.dat”, FileInfo ); WHILE (Found = 0) PRINT ( “%s\n”, FileInfo.Name ); Found = FindNext(FileInfo); IF ( FindClose() < 0 ) PRINT ( “Error in closing find operation\n” ); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 159: Findfirst

    ® Crestron SIMPL+ FindFirst Name: FindFirst Syntax: Description: This command searches a directory for file(s) matching the given file specification. Always followed with a FindClose, refer to Requires StartFileOperations(), refer to Parameters: FILESPEC specifies the filename to look for. It can be a full path name or a relative path name with wildcards ( the ‘*’...
  • Page 160 ((FileInfo.File Attributes&ADIRENT) <>0) PRINT (“%s is a directory\n”, FileInfo.Name Else PRINT (“%s is a file\n”,FileInfo.Name Found = FindNext(FileInfo); IF ( FindClose() < 0 ) PRINT ( “Error in closing find operation\n” ); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 161: Findnext

    ® Crestron SIMPL+ FindNext Name: FindNext Syntax: Description: This command continues the current directory for file(s) matching the file specification in the "FindFirst" command. Parameters: INFO – structure containing the information about a found file (refer to "FindFirst" on page Return Value: Returns 0 if a file is found matching the specification and –1 if an error occurred.
  • Page 162: Getcurrentdirectory

    SIMPL+ Version 3.00.02 or higher (Pro 2 only) Control System: 2-Series Only ® SIMPL+ STRING GetCurrentDirectory() page 14 for a discussion of setting the current directory. PRINT( “The current directory = GetCurrentDirectory()); Crestron SIMPL+ %s\n”, Language Reference Guide - DOC. 5797G ®...
  • Page 163: Isdirectory

    ® Crestron SIMPL+ IsDirectory Name: IsDirectory Syntax: Description: This routine returns whether the specified file is a directory, equivalent to checking info;Attributes. Parameters: INFO – structure containing the information about a found file (refer to "FindFirst" Return Value: Returns 1 if file is a directory and 0 otherwise.
  • Page 164: Ishidden

    WHILE (Found = 0) if (IsHidden(FileInfo)) PRINT( “%s is hidden\n”, FileInfo.FileName ); Found = FindNext(FileInfo); IF ( FindClose() < 0 ) PRINT ( “Error in closing find operation\n” ); EndFileOperations(); Crestron SIMPL+ 135. Language Reference Guide - DOC. 5797G ®...
  • Page 165: Isreadonly

    ® Crestron SIMPL+ IsReadOnly Name: IsReadOnly Syntax: Description: This routine returns whether the specified file is marked as read-only. Equivalent to checking attributes in FILE_INFO. Refer to Parameters: INFO – structure containing the information about a found file (refer to "FindFirst"...
  • Page 166: Issystem

    WHILE (Found = 0) if (IsSystem(FileInfo)) PRINT( “%s is a system file\n”, FileInfo.Name ); Found = FindNext(FileInfo); IF ( FindClose() < 0 ) PRINT ( “Error in closing find operation\n” ); EndFileOperations(); Crestron SIMPL+ 135. Language Reference Guide - DOC. 5797G ®...
  • Page 167: Isvolume

    ® Crestron SIMPL+ IsVolume Name: IsVolume Syntax: Description: This routine returns whether the specified file is a volume label. Equivalent to checking attributes in FILE_INFO. Refer to Parameters: INFO – structure containing the information about a found file (refer to "FindFirst"...
  • Page 168: Makedirectory

    SIMPL+ Version 3.00.02 or higher (Pro 2 only) Control System: 2-Series Only ® SIMPL+ SIGNED_INTEGER MakeDirectory(STRING DirName) page 14. Requires StartFileOperations(), refer to IF( MakeDirectory(“NewDirect”) < 0) PRINT(“Error occurred creating directory\n”); Crestron SIMPL+ page 183. Language Reference Guide - DOC. 5797G ®...
  • Page 169: Readinteger

    ® Crestron SIMPL+ ReadInteger Name: ReadInteger Syntax: Description: Reads an integer from a file starting at the current file position. Two bytes are read, most significant byte first. Refer to the section entitled “Reading and Writing Data to a File” on page...
  • Page 170 = FileOpen ( “MyFile”, _O_RDONLY ); IF (nFileHandle >= 0) iErrorCode = ReadInteger(nFileHandle, i); if (iErrorCode > 0) PRINT ( “Read integer from file correctly.\n”); else PRINT ( “Error code %d\n”, iErrorCode); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 171: Readintegerarray

    ® Crestron SIMPL+ ReadIntegerArray Name: ReadIntegerArray Syntax: Description: Reads the array from a file starting at the current file position. Two bytes are read, most significant first containing the row dimension of the array, then two more bytes are read, containing the column dimension of the array. Then each integer is read as a two byte quantity, most significant byte first.
  • Page 172 = FileOpen ( “MyFile”, _O_RDONLY ); IF (nFileHandle >= 0) iErrorCode = ReadIntegerArray(nFileHandle, iArray); if (iErrorCode > 0) PRINT ( “Read array from file correctly.\n”); else PRINT ( “Error code %d\n”, iErrorCode); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 173: Readlonginteger

    ® Crestron SIMPL+ ReadLongInteger Name: ReadLongInteger Syntax: Description: Reads a long integer from a file starting at the current file position. Four bytes are read, most significant byte first and least significant byte last. Refer to the section entitled “Reading and Writing Data to a File” on page...
  • Page 174 = FileOpen ( “MyFile”, _O_RDONLY ); IF (nFileHandle >= 0) iErrorCode = ReadLongInteger(nFileHandle, li); if (iErrorCode > 0) PRINT ( “Read long integer from file correctly.\n”); else PRINT ( “Error code %d\n”, iErrorCode); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 175: Readlongintegerarray

    ® Crestron SIMPL+ ReadLongIntegerArray Name: ReadLongIntegerArray Syntax: Description: Reads the array from a file starting at the current file position. Two bytes are read, most significant first containing the row dimension of the array, then two more bytes are read, containing the column dimension of the array. Then each long integer is read as a four byte quantity, most significant byte first.
  • Page 176 = FileOpen ( “MyFile”, _O_RDONLY ); IF (nFileHandle >= 0) iErrorCode = ReadLongIntegerArray(nFileHandle, ilArray); if (iErrorCode > 0) PRINT ( “Read array from file correctly.\n”); else PRINT ( “Error code %d\n”, iErrorCode); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 177: Readsignedinteger

    ® Crestron SIMPL+ ReadSignedInteger Name: ReadSignedInteger Syntax: Description: Reads a signed integer from a file starting at the current file position. Two bytes are read, most significant first. Refer to the section entitled “Reading and Writing Data to a File” on page...
  • Page 178 = FileOpen ( “MyFile”, _O_RDONLY ); IF (nFileHandle >= 0) iErrorCode = ReadSignedInteger(nFileHandle, si); if (iErrorCode > 0) PRINT ( “Read signed integer from file correctly\n”); else PRINT ( “Error code %d\n”, iErrorCode); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 179: Readsignedintegerarray

    ® Crestron SIMPL+ ReadSignedIntegerArray Name: ReadSignedIntegerArray Syntax: Description: Reads the array from a file starting at the current file position. Two bytes are read, most significant first containing the row dimension of the array, then two more bytes are read, containing the column dimension of the array. Then each signed integer is read as a two byte quantity, most significant byte first.
  • Page 180 = FileOpen ( “MyFile”, _O_RDONLY ); IF (nFileHandle >= 0) iErrorCode = ReadSignedIntegerArray(nFileHandle, isArray); if (iErrorCode > 0) PRINT ( “Read array from file correctly.\n”); else PRINT ( “Error code %d\n”, iErrorCode); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 181 ® Crestron SIMPL+ ReadSignedLongInteger Name: ReadSignedLongInteger Syntax: Description: Reads data from a file starting at the current file position. Each element of the structure is read, without any padding bytes, that might actually be there in memory. Refer to the section entitled “Reading and Writing Data to a File” on page...
  • Page 182 = FileOpen ( “MyFile”, _O_RDONLY ); IF (nFileHandle >= 0) iErrorCode = ReadSignedLongInteger(nFileHandle, sli); if (iErrorCode > 0) PRINT ( “Read from file correctly.\n”); else PRINT ( “Error code %d\n”, iErrorCode); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 183: Readsignedlongintegerarray

    ® Crestron SIMPL+ ReadSignedLongIntegerArray Name: ReadSignedLongIntegerArray Syntax: Description: Reads the array from a file starting at the current file position. Two bytes are read, most significant first containing the row dimension of the array, then two more bytes are read, containing the column dimension of the array. Then each signed long integer is read as a four byte quantity, most significant byte first.
  • Page 184 = FileOpen ( “MyFile”, _O_RDONLY ); IF (nFileHandle >= 0) iErrorCode = ReadSignedLongIntegerArray(nFileHandle, sliArray); if (iErrorCode > 0) PRINT ( “Read array from file correctly.\n”); else PRINT ( “Error code %d\n”, iErrorCode); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 185: Readstring

    ® Crestron SIMPL+ ReadString Name: ReadString Syntax: Description: Reads a string from a file starting at the current file position. Internally, the string is stored as a 2-byte length, most significant byte first, then the actual string bytes. In the case of a string variable, the total number of bytes written is calculated from the size of the string, not the string allocation size.
  • Page 186 = FileOpen ( “MyFile”, _O_RDONLY ); IF (nFileHandle >= 0) iErrorCode = ReadString( nFileHandle, s); if (iErrorCode > 0) PRINT ( “Read string from file correctly.\n”); else PRINT ( “Error code %d\n”, iErrorCode); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 187: Readstringarray

    ® Crestron SIMPL+ ReadStringArray Name: ReadStringArray Syntax: Description: Reads a string from a file starting at the current file position. Internally, the string is stored with the first 2 bytes indicating the total number of string written, then each string follows as a 2-byte length, most significant byte first, then the actual string bytes.
  • Page 188 = FileOpen ( “MyFile”, _O_RDONLY ); IF (nFileHandle >= 0) iErrorCode = ReadStringArray( nFileHandle, s); if (iErrorCode > 0) PRINT ( “Read string from file correctly.\n”); else PRINT ( “Error code %d\n”, iErrorCode); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 189: Readstructure

    ® Crestron SIMPL+ ReadStructure Name: ReadStructure Syntax: Description: Reads data from a file starting at the current file position. Each element of the structure is read, without any padding bytes, that might actually be there in memory. Refer to the section entitled “Reading and Writing Data to a File” on page...
  • Page 190 < 0 ) PRINT ( “Error reading structure. nTotalBytesRead ); else PRINT ( “Read structure from file correctly. Total bytes read = %d\n”, nTotalBytesRead ); EndFileOperations(); Crestron SIMPL+ Error code = %d\n”, Language Reference Guide - DOC. 5797G ®...
  • Page 191: Removedirectory

    ® Crestron SIMPL+ RemoveDirectory Name: RemoveDirectory Syntax: Description: Removes the directory with the specified name. The path name can be a relative link or absolute, refer to page refer to page Parameters: DIRNAME – string containing the name of the desired directory.
  • Page 192: Setcurrentdirectory

    SIMPL+ Version 3.00.02 or higher (Pro 2 only) Control System: 2-Series Only ® SIMPL+ SIGNED_INTEGER SetCurrentDirectory(STRING DirName) page IF( SetCurrentDirectory(“NewDirect”) < 0) PRINT(“Error occurred creating directory\n”); PRINT(“Directory is now: %s\n”, GetCurrentDirectory()); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 193: Startfileoperations

    ® Crestron SIMPL+ StartFileOperations Name: StartFileOperations Syntax: Description: Signifies to the operating system that the current thread is starting its file operations. Parameters: None. Return Value: Returns 0 if successful and –1 if an error occurred. Example: (Refer to "File Functions Overview"on page 116) NOTE: StartFileOperations is required prior to any operation accessing a file.
  • Page 194: Waitfornewdisk

    SIMPL+ Version 3.00.02 or higher (Pro 2 only) Control System: 2-Series Only ® SIMPL+ SIGNED_INTEGER WaitForNewDisk() page 119. while(1) if ( WaitForNewDisk() < 0 ) break; // perform operations on the new disk. Read a file, etc. Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 195: Writeinteger

    ® Crestron SIMPL+ WriteInteger Name: WriteInteger Syntax: Description: Writes an integer from a file starting at the current file position. Two bytes are written, most significant byte first. Refer to the section entitled “Reading and Writing Data to a File” on page...
  • Page 196 = FileOpen ( “MyFile”, _O_WRONLY ); IF (nFileHandle >= 0) iErrorCode = WriteInteger(nFileHandle, i); if (iErrorCode > 0) PRINT ( “Written to file correctly.\n”); else PRINT ( “Error code %d\n”, iErrorCode); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 197: Writeintegerarray

    ® Crestron SIMPL+ WriteIntegerArray Name: WriteIntegerArray Syntax: Description: Writes the array from a file starting at the current file position. Two bytes are written, most significant first containing the row dimension of the array, then two more bytes are written, containing the column dimension of the array. Then each integer is written as a two byte quantity, most significant byte first.
  • Page 198 = FileOpen ( “MyFile”, _O_WRONLY ); IF (nFileHandle >= 0) iErrorCode = WriteIntegerArray(nFileHandle, iArray); if (iErrorCode > 0) PRINT ( “Array written to file correctly.\n”); else PRINT ( “Error code %d\n”, iErrorCode); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 199: Writelonginteger

    ® Crestron SIMPL+ WriteLongInteger Name: WriteLongInteger Syntax: Description: Writes a long integer from a file starting at the current file position. Four bytes are written, most significant byte first. Refer to the section entitled “Reading and Writing Data to a File” on page...
  • Page 200 = FileOpen ( “MyFile”, _O_WRONLY ); IF (nFileHandle >= 0) iErrorCode = WriteLongInteger(nFileHandle, li); if (iErrorCode > 0) PRINT ( “Written to file correctly.\n”); else PRINT ( “Error code %d\n”, iErrorCode); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 201: Writesignedinteger

    ® Crestron SIMPL+ WriteSignedInteger Name: WriteSignedInteger Syntax: Description: Writes a signed integer from a file starting at the current file position. Two bytes are written, most significant first. Refer to the section entitled “Reading and Writing Data to a File” on page...
  • Page 202 = FileOpen ( “MyFile”, _O_WRONLY ); IF (nFileHandle >= 0) iErrorCode = WriteSignedInteger(nFileHandle, si); if (iErrorCode > 0) PRINT ( “Written to file correctly\n”); else PRINT ( “Error code %d\n”, iErrorCode); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 203: Writesignedintegerarray

    ® Crestron SIMPL+ WriteSignedIntegerArray Name: WriteSignedIntegerArray Syntax: Description: Writes the array from a file starting at the current file position. Two bytes are written, most significant first containing the row dimension of the array, then two more bytes are Write, containing the column dimension of the array. Then each signed integer is written as a two byte quantity, most significant byte first.
  • Page 204 = FileOpen ( “MyFile”, _O_WRONLY ); IF (nFileHandle >= 0) iErrorCode = WriteSignedIntegerArray(nFileHandle, isArray); if (iErrorCode > 0) PRINT ( “Array written to file correctly.\n”); else PRINT ( “Error code %d\n”, iErrorCode); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 205: Writesignedlonginteger

    ® Crestron SIMPL+ WriteSignedLongInteger Name: WriteSignedLongInteger Syntax: Description: Writes data from a file starting at the current file position. Each element of the structure is written, without any padding bytes, that might actually be there in memory. Refer to the section entitled “Reading and Writing Data to a File” on page...
  • Page 206 Software Version: SIMPL+ Version 3.01 or higher (Pro 2 only) Control System: 2-Series Only ® SIMPL+ Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 207: Writesignedlongintegerarray

    ® Crestron SIMPL+ WriteSignedLongIntegerArray Name: WriteSignedLongIntegerArray Syntax: Description: Writes the array from a file starting at the current file position. Two bytes are written, most significant first containing the row dimension of the array, then two more bytes are written, containing the column dimension of the array. Then each signed long integer is written as a four byte quantity, most significant byte first.
  • Page 208 = FileOpen ( “MyFile”, _O_WRONLY ); IF (nFileHandle >= 0) iErrorCode = WriteSignedLongIntegerArray(nFileHandle, sliArray); if (iErrorCode > 0) PRINT ( “Array written to file correctly.\n”); else PRINT ( “Error code %d\n”, iErrorCode); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 209 ® Crestron SIMPL+ WriteString Name: WriteString Syntax: Description: Writes a string to a file starting at the current file position. Internally, the string is stored as a 2-byte length, most significant byte first, then the actual string bytes. In the case of a string variable, the total number of bytes written is the calculated from the size of the string, not the string allocation size.
  • Page 210 = FileOpen ( “MyFile”, _O_WRONLY ); IF (nFileHandle >= 0) iErrorCode = WriteString( nFileHandle, s); if (iErrorCode > 0) PRINT ( “String written to file correctly.\n”); else PRINT ( “Error code %d\n”, iErrorCode); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 211: Writestringarray

    ® Crestron SIMPL+ WriteStringArray Name: WriteStringArray Syntax: Description: Writes a string array to a file starting at the current file position. Internally, the string is stored with the first 2 bytes indicating the total number of strings written, then each string follows as a 2-byte length, most significant byte first, then the actual string bytes.
  • Page 212 = FileOpen ( “MyFile”, _O_WRONLY ); IF (nFileHandle >= 0) iErrorCode = WriteStringArray( nFileHandle, s); if (iErrorCode > 0) PRINT ( “String written to file correctly.\n”); else PRINT ( “Error code %d\n”, iErrorCode); EndFileOperations(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 213: Writestructure

    ® Crestron SIMPL+ WriteStructure Name: WriteStructure Syntax: Description: Writes data to a file starting at the current file position. Each element of the structure is written, without any padding bytes, that might actually be there in memory. Refer to the section entitled “Reading and Writing Data to a File” on page...
  • Page 214 < 0 ) PRINT ( “Error writing structure. nTotalBytesWritten ); else PRINT ( “Structure written to file correctly. bytes written = %d\n”, nTotalBytesWritten ); EndFileOperations(); Crestron SIMPL+ Error code = %d\n”, Total Language Reference Guide - DOC. 5797G ®...
  • Page 215: Mathematical Functions

    ® Crestron SIMPL+ Mathematical Functions Mathematical Functions Overview These functions perform general mathematical operations in a given SIMPL+ program by operating on one or more numerical arguments and returning an INTEGER as a result. Name: Syntax: Description: Takes the absolute value of SOURCE. If SOURCE is negative, a positive value is returned.
  • Page 216: Max

    Version: SIMPL+ Version 1.00 ® SIMPL+ INTEGER Max(INTEGER VAL1, INTEGER VAL2) INTEGER X, Y; FUNCTION MAIN() X = MAX(65535, 0); Y = MAX(25, 26); Crestron SIMPL+ for a further explanation of how the Language Reference Guide - DOC. 5797G ®...
  • Page 217: Min

    ® Crestron SIMPL+ Name: Syntax: Description: Determine the minimum of two values based on an unsigned comparison. Parameters: VAL1 and VAL2 are both INTEGER values on which the test is performed. Return Value: The minimum of Val1, Val2 after an unsigned comparison is performed. Refer to “Signed vs.
  • Page 218: Muldiv

    INTEGER MulDiv(INTEGER VAL1, INTEGER VAL2, INTEGER VAL3) INTEGER X, Y; FUNCTION MAIN() X = 1970; Y = 40; PRINT(“The result of (%d * %d)/25 = %d\n”, X, Y, MULDIV(X, Y, 25); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 219: Smax

    ® Crestron SIMPL+ SMAX Name: SMax Syntax: Description: Determine the maximum of two values based on a signed comparison. Parameters: VAL1 and VAL2 are both INTEGER values on which the test is performed. Return Value: The maximum of Val1, Val2 after a signed comparison is performed. Refer to “Signed vs.
  • Page 220: Smin

    Version: SIMPL+ Version 1.00 ® SIMPL+ INTEGER SMin(INTEGER VAL1, INTEGER VAL2) INTEGER X, Y; FUNCTION MAIN() X = SMIN(65535, 0); Y = SMIN(25, 26); Crestron SIMPL+ for a further explanation of how the Language Reference Guide - DOC. 5797G ®...
  • Page 221: Random Number Functions

    ® Crestron SIMPL+ Random Number Functions Random Number Functions Overview These functions allow a SIMPL+ program to generate a random number. Random Name: Random Syntax: Description: Generate a random number. Refer to “Seed” on Parameters: LowerBound is an INTEGER specifying the lower end of the range.
  • Page 222: Rnd

    An INTEGER from 0 to 65535. Example: Version: SIMPL+ Version 1.00 ® SIMPL+ INTEGER Rnd(); 211. INTEGER NUM; FUNCTION MAIN() NUM = RND(); PRINT(“The random number is: %d\n”, NUM); Crestron SIMPL+ page 213 and “Random” on Language Reference Guide - DOC. 5797G ®...
  • Page 223: Seed

    ® Crestron SIMPL+ Seed Name: Seed Syntax: Description: Provides a seed or origin for the random number generator so that the numbers returned by RND and RANDOM are pseudo-random numbers. SEED is not required for generating random numbers as the random number generator will be seed with a default value.
  • Page 224: String Formatting & Printing Functions

    NOTE: In the second form, the first argument may not be a variable containing 0, 1, 2. It must be the written as 0, 1, 2. Crestron is discouraging the use of the second form of MAKESTRING in favor of either the PRINT command or alternate methods for activating devices that do not require knowledge of Cresnet packets, which are subject to change.
  • Page 225 ® Crestron SIMPL+ Example: Version: SIMPL+ Version 2.00 for Console, Cresnet, and CPU destinations. SIMPL+ Version 1.00 for everything else. Language Reference Guide - DOC. 5797G INTEGER X; STRING Z[100], OUT[100]; X=10; Z=”Hello”; FUNCTION MAIN() // Puts “This is a string” followed by a CRLF onto OUT.
  • Page 226: Print

    Syntax: Description: The output of PRINT goes to the CONSOLE port of the control system and can be monitored in the Crestron Viewport. It can print simple text strings or complex formatted strings. Parameters: <Static Specification String> is a quoted string that contains text and formatting information.
  • Page 227 ® Crestron SIMPL+ also checks to make sure the format specifier matches the type of the variable being used (i.e. if %d is used, the variable being used should be INTEGER type). NOTE: If no format specifiers are used, then a simple quoted text string is printed.
  • Page 228: String Concatenation

    <Destination_string> = <String1 > [+ <String2> ...]; STRING A$[100], B$[100], C$[100]; B$=”Hello”; C$=”World!”; I=56; J=2; // This will output “Hello562World!” A$=B$+ITOA(I)+ITOA(J)+”xyz”+C$; PRINT(“%s”, A$); // This will output “VHello2World” A$=CHR(I)+B$+ITOA(J)+C$; PRINT(“%s”, A$); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 229: String Parsing & Manipulation Functions

    ® Crestron SIMPL+ String Parsing & Manipulation Functions String Parsing and Manipulation Functions Overview String parsing and manipulation functions are used where the contents of string variables need to be examined or modified. ClearBuffer Name: ClearBuffer Syntax: Description: Deletes the contents of the specified buffer. If a LEN is done on the buffer after a CLEARBUFFER, the return value will be 0.
  • Page 230: Find

    SIMPL+ Version 1.00 ® SIMPL+ INTEGER Find(STRING MATCH_STRING, STRING SOURCE_STRING [,INTEGER START_POSITION]); STRING_INPUT IN$[100]; INTEGER START_LOC; CHANGE IN$ START_LOC = FIND(“XYZ”, IN$); PRINT(“XYZ was found starting at position %d in %s\n”, START_LOC, IN$); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 231: Gather

    ® Crestron SIMPL+ Gather Name: Gather Syntax: Description: Concatenates the data from SOURCESTRING and issues it on the return string when the specified delimiter has been reached. Note that when GATHER is executed, if SOURCESTRING does not include the DELIMITER, then the equivalent of a PROCESSLOGIC is performed.
  • Page 232 In the X-Generation Control Systems, the CHANGE event would be called both times. Version: SIMPL+ Version 2.00 ® SIMPL+ BUFFER_INPUT COM$[100]; DIGITAL_INPUT trig; STRING IN$[100]; CHANGE COM$ IN$ = GATHER(“\n”, COM$); PRINT(“The value of IN$ is %s\n”, IN$); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 233: Getc

    ® Crestron SIMPL+ GetC Name: GetC Syntax: Description: Returns the value at position 1 of SOURCE string and shifts the rest of the buffer up by one. In this way, values may be picked out of a buffer for processing.
  • Page 234: Left

    Version: SIMPL+ Version 1.00 ® SIMPL+ STRING Left(STRING SOURCE, INTEGER NUM); STRING_INPUT Var$[100]; STRING Temp$[100]; CHANGE Var$ Temp$ = LEFT(Var$, 5); PRINT(“Left most 5 characters of %s are %s\n”, Var$, Temp$); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 235: Len

    ® Crestron SIMPL+ Name: Syntax: Description: Returns the length of the actual string, not the declared maximum length. Parameters: SOURCE is a string whose length is to be determined. Return Value: A value from 0 - 65535, which gives the number of characters in the string. An empty string returns a length of 0.
  • Page 236: Lower

    In this example, if IN$ contains “This is a Test 123!”, then LOWER$ will contain “this is a test 123!”. Version: SIMPL+ Version 1.00 ® SIMPL+ STRING Lower(STRING SOURCE); STRING_INPUT IN$[100]; STRING LOWER$[100]; CHANGE IN$ LOWER$ = LOWER(IN$); PRINT(“Lowercase version of %s is %s\n”,IN$, LOWER$); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 237: Mid

    ® Crestron SIMPL+ Name: Syntax: Description: Returns a string NUM characters long from SOURCE, starting at position START. Parameters: SOURCE is a STRING containing the input string. START is an INTEGER telling MID at which character position in SOURCE to start.
  • Page 238 ® SIMPL+ STRING Remove(STRING DELIMITER, STRING SOURCESTRING [, INTEGER POSITION]); BUFFER_INPUT SOURCE$[50]; STRING OUTPUT$[50]; CHANGE SOURCE$ OUTPUT$ = REMOVE(“abc”, SOURCE$); BUFFER_INPUT SOURCE$[50]; STRING OUTPUT$[50]; CHANGE SOURCE$ OUTPUT$ = REMOVE(“abc”, SOURCE$, 6); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 239: Reversefind

    ® Crestron SIMPL+ REVERSEFIND Name: ReverseFind Syntax: Description: Finds the position in SOURCE_STRING where MATCH_STRING last occurs. Parameters: MATCH_STRING is a STRING containing the searched for data. SOURCE_STRING is a STRING containing the data to be searched. START_POSITION is an INTEGER which tells REVERSEFIND at what character in the string to start the search, and is 1 based.
  • Page 240: Right

    Version: SIMPL+ Version 1.00 ® SIMPL+ STRING Right(STRING SOURCE, INTEGER NUM); STRING_INPUT Var$[100] STRING Temp$[100]; CHANGE Var$ Temp$ = RIGHT(Var$, 5); PRINT(“Right most 5 characters of %s are %s\n”, Var$, Temp$); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 241: Setstring

    ® Crestron SIMPL+ SetString Name: SetString Syntax: Description: Overwrites the bytes in DESTINATION with the bytes in SOURCE starting at POSITION in the DESTINATION string. Parameters: DESTINATION is a STRING containing the string to be modified. POSITION is an INTEGER referencing the starting byte to write at in DESTINATION.
  • Page 242 This would result in DESTINATION containing the string “Space ABCD To Fill”. If the return code were used, it would contain 18 (the string length). Version: SIMPL+ Version 1.00 ® SIMPL+ STRING DESTINATION$[100]; DESTINATION$ = :\”Space XXXX To Fill”; SETSTRING(“ABCD”, 7, DESTINATION$); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 243: Upper

    ® Crestron SIMPL+ Upper Name: Upper Syntax: Description: Takes a source string and converts characters with the values a-z (lowercase) to A-Z (uppercase). Parameters: SOURCE is a string to be converted to uppercase. SOURCE is not modified, unless it is also used as the return value, e.g., S$=UPPER(S$);...
  • Page 244: System Control Overview

    5-second delay. Return Value: None. Example: Version: SIMPL+ Version 1.00 ® SIMPL+ Delay(INTEGER TIME); page 265. // A delay of 525 hundredths of a second or 5.25 seconds #define_constant MY_DELAY 525 DELAY(MY_DELAY); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 245: Processlogic

    ® Crestron SIMPL+ ProcessLogic Name: ProcessLogic Syntax: Description: Forces a task switch away from the current SIMPL+ module, so that the SIMPL Windows program can process the outputs of the SIMPL+ module. Refer to the discussion on Task Switching on Parameters: None.
  • Page 246: Pulse

    This will execute immediately and output a pulse of 5.25 seconds to the digital output OutputToPulse. Version: SIMPL+ Version 1.00 ® SIMPL+ Pulse(TIME, DIGITAL_OUTPUT OUT); // A pulse of 525 hundredths of a second or 5.25 seconds #define_constant MY_PULSE_TIME 525 DIGITAL_OUTPUT OutputToPulse; PULSE(MY_PULSE_TIME, OutputToPulse); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 247: Terminateevent

    ® Crestron SIMPL+ TerminateEvent Name: TerminateEvent Syntax: Description: Exits a CHANGE, PUSH, or RELEASE event. It may also be used to exit a loop in the main() function if desired. TERMINATEEVENT cannot be used inside of a function. Example: In this example, the CHANGE event will terminate if the ANALOG_INPUT Y equals the value of 69.
  • Page 248: Generateusernotice

    216 for a list and description of valid Format Specifiers. Function MyFunc() STRING sNotice; sNotice = "Projector"; GenerateUserNotice( "The %s bulb has a total of %d hours", sNotice, 500 ); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 249: Generateuserwarning

    ® Crestron SIMPL+ GenerateUserWarning Name: GenerateUserWarning Syntax: Description: Places a warning message into the control system's error log Parameters: <Static Specification String> is a quoted string that contains text and formatting information. Format specifiers are of the form: %[[Pad]Width]specifier Refer to Return Value: None.
  • Page 250: Generateusererror

    “Print” on page 216 for a list and description of valid Format Specifiers. Function MyFunc() STRING sError; sError = "Projector"; GenerateUserError( "The %s bulb has exceeded %d hours", sError, 1000 ); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 251: Checkfornvramdisk

    ® Crestron SIMPL+ CheckForNVRAMDisk Name: CheckForNVRAMDisk Syntax: Description: Tests whether or not an NVRam Disk is currently installed in the control system. Parameters: None. Return Value: Returns 1 if an NVRam Disk is currently installed in the control system. Example:...
  • Page 252: Time & Date Functions

    Example: This would print a string such as “The date is 03/25/2002”. Version: SIMPL+ Version 1.00 ® SIMPL+ STRING Date(INTEGER FORMAT); STRING TheDate$[100]; FUNCTION MAIN() TheDate$=DATE(1); PRINT(“The date is %s\n”, TheDate$); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 253: Day

    ® Crestron SIMPL+ Name: Syntax: Description: Returns the day of the week as a STRING. Parameters: None. Return Value: The day of the week is returned in a string. Valid returns are Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, or Saturday.
  • Page 254: Getdatenum

    An example output of this would be “The current day of the month is 25”. Version: SIMPL+ Version 1.00 ® SIMPL+ INTEGER GetDateNum(); INTEGER NumDateOfMonth; FUNCTION MAIN() NumDateOfMonth = GetDateNum(); PRINT(“The current day of the month is %d\n”, NumDateOfMonth); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 255: Getdayofweeknum

    ® Crestron SIMPL+ GETDAYOFWEEKNUM Name: GetDayOfWeekNum Syntax: Description: Returns an integer corresponding to the current day of the week. Parameters: None. Return Value: The day of the week as an integer from 0 to 6; 0 represents Sunday to 6 representing Saturday.
  • Page 256: Gethournum

    An example output of this would be “The Number of hours on the clock is 22”. Version: SIMPL+ Version 1.00 ® SIMPL+ INTEGER GetHourNum(); INTEGER NumHours; FUNCTION MAIN() NumHours = GetHourNum(); PRINT(“The Number of hours on the clock is %d\n”, NumHours); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 257: Gethseconds

    ® Crestron SIMPL+ GETHSECONDS Name: GetHSeconds Syntax: Description: Returns an integer corresponding to the number of hundredths of a second based on the system clock. Typically, this function could be used for very fine timing, to determine if a specific amount of time has elapsed.
  • Page 258: Getminutesnum

    An example output of this would be “The Number of minutes on the clock is 33”. Version: SIMPL+ Version 1.00 ® SIMPL+ INTEGER GetMinutesNum(); INTEGER NumMinutes; FUNCTION MAIN() NumMinutes = GetMinutesNum(); PRINT(“The Number of minutes on the clock is %d\n”, NumMinutes); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 259: Getmonthnum

    ® Crestron SIMPL+ GETMONTHNUM Name: GetMonthNum Syntax: Description: Returns an integer corresponding to the current month of the year. Parameters: None. Return Value: The month of the year as an integer from 1 to 12. Example: An example output of this would be “The current month of the year is 9”.
  • Page 260: Getsecondsnum

    An example output of this would be “The Number of seconds on the clock is 25”. Version: SIMPL+ Version 1.00 ® SIMPL+ INTEGER GetSecondsNum(); INTEGER NumSeconds; FUNCTION MAIN() NumSeconds = GetSecondsNum(); PRINT(“The Number of seconds on the clock is %d\n”, NumSeconds); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 261: Getticks

    ® Crestron SIMPL+ GETTICKS Name: GetTicks Syntax: Description: Returns an integer corresponding to the number of system ticks. Each tick is 1/112.5 seconds on an X-generation control system, or 0.01 seconds on a 2-series control system. Typically, this function could be used for very fine timing, to determine if a specific amount of time has elapsed.
  • Page 262: Getyearnum

    An example output from this would be “The current year is 1999”. Version: SIMPL+ Version 1.00 ® SIMPL+ INTEGER GetYearNum(); INTEGER NumYear; FUNCTION MAIN() NumYear = GetYearNum(); PRINT(“The current year is %d\n”, NumYear); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 263: Month

    ® Crestron SIMPL+ MONTH Name: Month Syntax: Description: Returns the current month as a string. Parameters: None. Return Value: The current month is returned in a string. Valid returns are January, February, March, April, May, June, July, August, September, October, November, or December.
  • Page 264: Setclock

    Current Time is: 05:10:25. Version: SIMPL+ Version 2.00 ® SIMPL+ SetClock(INTEGER HOURS, INTEGER MINUTES, INTEGER SECONDS); ANALOG_INPUT Hours, Minutes, Seconds; CHANGE Hours, Minutes, Seconds SetClock(Hours, Minutes, Seconds); PRINT(“Current Time is: %s\n”, Time()); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 265: Setdate

    ® Crestron SIMPL+ SETDATE Name: SetDate Syntax: Description: Sets the system date. Parameters: MONTH is an integer containing the month to which the date is set. A valid range is 1 through 12, corresponding to January through December. DAY is an integer containing the day of the month to which the date is set. The range varies from month to month, but always starts at 1.
  • Page 266: Time

    Example: An example output from this would be “The Time is 14:25:32”. Version: SIMPL+ Version 1.00 ® SIMPL+ STRING TIME(); STRING TheTime$[100]; FUNCTION MAIN() TheTime$=TIME(); PRINT(“The Time is %s\n”, TheTime$); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 267: Wait Events

    ® Crestron SIMPL+ Software Wait Events Wait Events Overview When writing a SIMPL+ program, it is often desirable to have an event that will be processed a predetermined amount of time after it is triggered. The WAIT event allows a block of code to be executed after a specified amount of time. There are related functions which allow WAITS to be paused, resumed, cancelled, or have their times changed.
  • Page 268: Cancelallwait

    Wait list and will not get activated. Version: SIMPL+ Version 1.00 ® SIMPL+ CancelAllWait(); DIGITAL_INPUT Trig, KillWaits; PUSH Trig WAIT(1000, FirstWait) PRINT(“Wait 1 Triggered!\n”); WAIT(2000, SecondWait) PRINT(“Wait 2 Triggered!\n”); PUSH KillWaits CancelAllWait(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 269: Cancelwait

    ® Crestron SIMPL+ CancelWait Name: CancelWait Syntax: Description: Cancels a specified named WAIT event in the current SIMPL+ program. When an event is cancelled, it is removed from the wait list and will not activate. There is no effect if the wait event has finished running.
  • Page 270: Pauseallwait

    Version: SIMPL+ Version 1.00 ® SIMPL+ PauseAllWait(); DIGITAL_INPUT Trig, PauseWaits; PUSH Trig WAIT(1000, FirstWait) PRINT(“Wait 1 Triggered!\n”); WAIT(2000, SecondWait) PRINT(“Wait 2 Triggered!\n”; PUSH PauseWaits PauseAllWaits(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 271: Pausewait

    ® Crestron SIMPL+ PauseWait Name: PauseWait Syntax: Description: Pauses a specified named WAIT event in the current SIMPL+ program. When an event is paused, the timer for it freezes and may later be resumed, retimed, or cancelled. When a wait is resumed, it executes the remaining time from when it was paused until the defined wait time.
  • Page 272 SecondWait will have 15-seconds more to execute. Version: SIMPL+ Version 1.00 ® SIMPL+ ResumeAllWait(); DIGITAL_INPUT Trig, PauseWaits, ResumeWaits; PUSH Trig WAIT(1000, FirstWait) PRINT(“Wait 1 Triggered!\n”); WAIT(2000, SecondWait) PRINT(“Wait 2 Triggered!\n”; PUSH PauseWaits PauseAllWait(); PUSH ResumeWaits ResumeAllWaits(); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 273 ® Crestron SIMPL+ ResumeWait Name: ResumeWait Syntax: Description: Resumes the specified named WAIT event in the current SIMPL+ program that has been previously paused. The WAIT will execute from the time when it was paused until the specified wait time has elapsed.
  • Page 274: Retimewait

    5-seconds. If FirstWait has expired, no action will be taken. Version: SIMPL+ Version 1.00 ® SIMPL+ RetimeWait(INTEGER TIME, NAME); DIGITAL_INPUT Trig, ChangeWaitTime; PUSH Trig WAIT(1000, FirstWait) PRINT(“Wait 1 Triggered!\n”); PUSH ChangeWaitTime RetimeWait(500, FirstWait); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 275: Wait

    ® Crestron SIMPL+ Wait Name: Wait Syntax: Description: NOTE: There is no semicolon after a WAIT statement because it has a clause or block following it. Adds an event to a list to be executed in TIME hundredths of a second. Giving a WAIT a name is optional, but to cancel, pause, resume, or retime a wait, a name must be specified.
  • Page 276 ( 1 ) // statements (will keep executing during the wait statement) Wait( 500 ) // statements (execute once for each wait statement occurence) // statements (will keep executing during the wait statement) Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 277: User Defined Functions

    ® Crestron SIMPL+ User Defined Functions User Defined Functions Overview A SIMPL+ program may have functions that are defined by users. Typically, a function is defined to modularize code to make repetitive tasks easier to perform or make code easier to read.
  • Page 278: Function Parameters

    The function refers to the passed variable as <variable_name>. Note that for a one- dimensional array, the syntax is <variable_name>[] and for a two-dimensional array the syntax is <variable_name>[][]. ® SIMPL+ [ByRef | ByVal] <INTEGER | LONG_INTEGER | SIGNED_INTEGER | SIGNED_LONG_INTEGER | STRUCTURE> <variable_name> Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 279: Byref, Byval, Readonlybyref

    ® Crestron SIMPL+ ByRef, ByVal, ReadOnlyByRef NOTE: Passing STRINGs with BYVAL an BYREF is not allowed in the 2-Series Control System. All STRINGs are passed by referenced in the 2-Series Control System. NOTE: Passing I/O datatype variables (DIGITAL_INPUT, ANALOG_INPUT and STRING_INPUT) is not allowed in the 2-Series Control System.
  • Page 280 SIGNED_LONG_INTEGER SIGNED_LONG_INTEGER array SIGNED_LONG_INTEGER array element STRING STRING array STRING array element STRING_INPUT STRING_INPUT array STRING_INPUT array element STRING_OUTPUT ® SIMPL+ Crestron SIMPL+ ByVal ByRef ReadOnlyByRef [LOCAL [SOURCE] COPY] R, W R, (E1) R, (E1) R, W R, W R, W...
  • Page 281 ® Crestron SIMPL+ VARIABLE TYPE STRING_OUTPUT array STRING_OUTPUT array element STRUCTURE STRUCTURE element (INTEGER) STRUCTURE element (LONG_INTEGER) STRUCTURE element (SIGNED_INTEGER) STRUCTURE element (SIGNED_LONG_INTEGER) STRUCTURE element (STRING) R: Read access allowed. W: Write access allowed. (E1): Generates a RunTime Error, not allowed to be write to INPUT values. The ReadOnlyByRef generates a compile error instead of a RunTime Error.
  • Page 282: Returning A Value

    INTEGER_FUNCTION MyIntegerFn ( ) IF (1) RETURN (1); RETURN (0); LONG_INTEGER_FUNCTION MyLongIntFn ( ) IF (1) SIGNED_INTEGER_FUNCTION MySignedIntFn ( ) IF (1) RETURN (1); RETURN (0); SIGNED_LONG_ INTEGER_FUNCTION MySignedLongIntFn ( ) Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 283 ® Crestron SIMPL+ Software IF (1) RETURN (1); RETURN (0); STRING_FUNCTION MyStringFn ( ) IF (1) RETURN (“abc”); RETURN (“def”); FUNCTION MyFn ( ) IF (1) return; EVENT if (1) return; PUSH if (1) return; RELEASE if (1) return; CHANGE if (1) return;...
  • Page 284: Calling A Function

    INTEGER X, ANALOG1, ANALOG2; STRING Q$[20], B$[50]; X = ComputeChecksum(Analog1, Analog2); Q$ = DoSomething(Analog1, B$); <CALL> <function_name>([argument_list]); CALL DoSomethingElse(); DoSomethingElse() ; (2-Series only) CALL Print( str, “abc” ); Crestron SIMPL+ (X-Generation or 2-Series) // Illegal Language Reference Guide - DOC. 5797G ®...
  • Page 285: Function Libraries

    ® Crestron SIMPL+ Function Libraries NOTE: A function may be placed in the same body of code as the caller. In some cases, the same function needs to be used across several different modules. Although the code could be rewritten in all modules (as was the case with SIMPL+ Version 1.00), SIMPL+ Version 2.00 supports function libraries.
  • Page 286: Program Structure

    2. Input/Output definitions From/To a SIMPL Program 3. Global declarations for the module, including STRING, INTEGER, arrays, structures, etc. 4. FUNCTION declarations 5. PUSH/RELEASE/CHANGE statements 6. FUNCTION MAIN FUNCTION MAIN() MyVar=0; For(I=1 to 10) B[I] = I; Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 287: Common Runtime Errors

    Common Runtime Errors Overview The following errors will occur at runtime. In order for these error messages to be seen, the Crestron Viewport must be open and communications with the control system (via Ethernet or the computer port) must be established.
  • Page 288 200 bytes. If this message is received, reduce the number of variables. If string or buffers have been declared overly large, this is an easy place to reduce memory requirements. ® SIMPL+ Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 289: Example Programs

    ® Crestron SIMPL+ Software Example Programs Example 1: Hello, World! // A digital input from the SIMPL program DIGITAL_INPUT TRIG; // Upon the digital signal TRIG going high or low, the Hello, // World! message is printed. CHANGE TRIG PRINT(“Hello, World!\n”);...
  • Page 290: Example 2: 8-Level Switch On A Pesa Switcher

    Software Crestron SIMPL+ ® Example 2: 8-Level switch on a Pesa switcher #SYMBOL_NAME “Pesa Switcher - 8 Levels” #HINT “Creates Pesa CPU-Link H command for Switching” ************************************************************ ****** DIGITAL, ANALOG and SERIAL INPUTS and OUTPUTS ************************************************************ ******/ // Digital trigger from the SIMPL program - this sends the command // string out.
  • Page 291 ® Crestron SIMPL+ Software // temporary buffer. A Command looks like H{out}{l1}{l2}...{l8} // {2 byte checksum}{CR}{LF} where {out} and {l1}..{l8} are 3 // digit ASCII bytes with leading zeros. An example is // H001001002003004005006007008{2 bytes checksum}{CR}{LF} makestring(PESABUF,”H%03d%03d%03d%03d%03d%03d%03d%03d%03d”, // OUTPUT, LEVEL1, LEVEL2, LEVEL3, LEVEL4, LEVEL5, LEVEL6, // LEVEL7, LEVEL8);...
  • Page 292: Example 3: Computing The Number Of Days In A Month

    CASE( 6): Days = 30; // June CASE( 9): Days = 30; // September CASE(11): Days = 30; // November Default: Days = 31; // All others Return(Days); CHANGE MONTH DAYS = ComputeDaysInMonth(MONTH); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 293: Example 4: Computing The Number Of Days In A Month

    ® Crestron SIMPL+ Example 4: Computing the Number of Days in a Month (Using Function Libraries) The following code would be saved as, in this example, “My Function Library.USL”. The following code can be saved as any filename: Language Reference Guide - DOC. 5797G...
  • Page 294 Number of bytes written to the file. If the return value is negative, it is an error code. ® SIMPL+ SIGNED_INTEGER WriteLongIntegerArray ( INTEGER file_handle, LONG_INTEGER ilArray[m][n] ) Crestron SIMPL+ for a discussion of when to use this Language Reference Guide - DOC. 5797G ®...
  • Page 295 ® Crestron SIMPL+ Example: (Refer to "File Functions Overview"on page 116) Version: SIMPL+ Version 3.01 or higher (Pro 2 only) Control System: 2-Series Only Language Reference Guide - DOC. 5797G INTEGER nFileHandle, iErrorCode; LONG_INTEGER ilArray[10]; nFileHandle = FileOpen ( “MyFile”, _O_RDONLY );...
  • Page 296: Compiler Errors And Warnings

    Invalid numeric expression: '<expression>' Errors Invalid string expression Invalid expression: '<expression>' 1201 Invalid \\x sequence Invalid \\x sequence: '<expression>' ® SIMPL+ Crestron SIMPL+ PAGE page 289 page 290 page 292 page 293 page 293 page 294 page 294 page 295...
  • Page 297 ® Crestron SIMPL+ CATEGORY NUMBER MESSAGE TEXT Declaration 1300 Array size missing Errors Array size invalid 1301 Invalid array index 1302 Variable name, ‘<identifier>’, exceeds maximum length of <max> characters 1303 Declaration type not allowed within structure: '<identifier>' Structure cannot contain String Arrays or Structure variables: Structure...
  • Page 298 'TerminateEvent' statement will only terminate current Wait statement's function scope 1802 #CATEGORY_NAME defined more than once. Using: #CATEGORY_NAME "<number>" 1803 Possible data loss: LONG_INTEGER to INTEGER assignment ® SIMPL+ Crestron SIMPL+ PAGE page 326 page 326 page 327 page 328 page 329 page 329 page 330...
  • Page 299: Syntax Errors (Compiler Errors 1000 To 1013)

    ® Crestron SIMPL+ Syntax Errors (Compiler Errors 1000 to 1013) Compiler Error 1000 syntax error: '<identifier>' already defined The specified identifier was declared more than once. A variable can only be declared once within it’s function scope. The same identifier cannot be used for more than one declaration type.
  • Page 300: Compiler Error 1001

    = 4; struct.structMember = 5; notation struct.structMember[1] = 6; notation structArr[1].structMember = 7; notation Crestron SIMPL+ // ok // ok // ok // ok – proper ‘dot’ // ok – proper ‘dot’ // ok – proper ‘dot’ Language Reference Guide - DOC. 5797G...
  • Page 301 ® Crestron SIMPL+ Language Reference Guide - DOC. 5797G structArr[1].structArrMember[2] = 8; // ok – proper ‘dot’ notation j = 2; // error – j is not declared structMember = 10; // error – improper ‘dot’ notation structMember[1] = 11;...
  • Page 302: Compiler Error 1002

    ( x = 4 ) return 5; // error – should be return (5); return (6); // ok Crestron SIMPL+ structure definition not specified should be Print (“abc” ); next statement statement Language Reference Guide - DOC. 5797G...
  • Page 303: Compiler Error 1003

    ® Crestron SIMPL+ Compiler Error 1003 syntax error: Incorrect type '<decl_type>', expected type(s): '<decl_type1[,decl_type2] [,decl_typen]>' Incorrect type, expected type(s): '<decl_type1[,decl_type2][,decl_typen]>' A specific variable or type was expected and not found. Examples are variables of one type being used in place of another, and incorrect variable types within function arguments.
  • Page 304: Compiler Error 1005

    #DEFINE_CONSTANT MyVarConst substitutions are #DEFINE_CONSTANT MyExprConst are not #DEFINE_CONSTANT MyFuncConst #DEFINE_CONSTANT MyFuncConst Crestron SIMPL+ // ok // error – MyIntConst be in quotes – this will be evaluated as a literal string // ok “abc” // ok (1+2) // error – expressions not allowed // error –...
  • Page 305: Compiler Error 1007

    ® Crestron SIMPL+ Compiler Error 1007 syntax error: Missing array index: '<identifier>' A variable declared as an array is being used within an expression without the array index being specified. For two-dimensional arrays, both indices must be specified. When passing entire arrays as function arguments, no index is needed.
  • Page 306: Compiler Error 1008

    // error – ‘j’ has not been declared x = j; for ( s = “a” to “z” ) // error – strings are not allowed Crestron SIMPL+ // ok // error – should be struct.x = j; Language Reference Guide - DOC. 5797G...
  • Page 307: Compiler Error 1009

    ® Crestron SIMPL+ Compiler Error 1009 syntax error: Missing structure member: '<identifier>' Variables contained within structures are required when using structures within an expression or statement. When using structures, the ‘dot’ notation is required to specify a structure’s variable. The notation is as follows: <structure_name>.<member_variable>...
  • Page 308: Compiler Error 1010

    // ok else if ( x=3 ) return (); // error – no value or expression is given return (x); // ok Crestron SIMPL+ // ok // ok // error cannot return a value and must return a value Language Reference Guide - DOC. 5797G...
  • Page 309: Compiler Error 1012

    ® Crestron SIMPL+ Compiler Error 1012 syntax error: Unterminated string constant A literal string was used and was not contained within quotes. If a quotation character is needed within a literal string, a backslash should be placed before the quotation character (i.e.: \). This will indicate to the compiler that the quotation character is not the terminating quote for the literal string.
  • Page 310: Fatal Errors (Compiler Errors 1100 To 1101)

    // construct (i.e.: if-else, while, etc) INTEGER x; INTEGER y; Print( “outside of everything” ); // error – statement is FUNCTION MyFunc() Crestron SIMPL+ // ok 2; // error – semicolon is not another function or event does nothing), and is not contained...
  • Page 311: Compiler Error 1101

    ® Crestron SIMPL+ Compiler Error 1101 fatal error: Abort - Error count exceeded <max_errors> When compiling, if the error count is too large, the compiler will terminate the compile process prematurely. This can not only be a tremendous time saver, but also help reduce the aggravation and stress levels of the programmer.
  • Page 312 ( str = MyFunc(1) ) while ( str < “abc” ) // ok x = (x + ); break; return (1); Crestron SIMPL+ // ok // error – cannot add an integer and string // error – cannot compare an and string // error –...
  • Page 313: Compiler Error 1201

    ® Crestron SIMPL+ Compiler Error 1201 expression error: Invalid \\x sequence A hexadecimal sequence within a literal string contained an invalid format. Characters represented by a hexadecimal number must follow the format: \xXX, where ‘\x’ signifies that a hexadecimal sequence is to follow and XX is the 2 digit hexadecimal value.
  • Page 314: Declaration Errors (Compiler Errors 1300 To 1312)

    STRING str[myFunc()]; FUNCTION myFunc( STRING sArg, STRING sArgArr[] ) // Crestron SIMPL+ // ok – str has a length of 100 // ok – strIn has a length of // ok – bufIn has a length of // ok – 51 strings of length 100 // ok - 51 strings of length // ok –...
  • Page 315: Compiler Error 1301

    ® Crestron SIMPL+ Compiler Error 1301 declaration error: Invalid array index An index is required when accessing any element of an array. Two dimensional arrays require both indices of the array to be specified. This index must be a valid numeric expression.
  • Page 316: Compiler Error 1302

    Call MyStrFunc( str, strArr ); str[1] = “a”; // error – s is a string, not an array sLocal = str[1]; // error – individual characters within maximum length of <max> characters Crestron SIMPL+ arrays are passed by reference // ok // ok...
  • Page 317: Compiler Error 1303

    ® Crestron SIMPL+ Compiler Error 1303 declaration error: Declaration type not allowed within Structure datatypes can only be defined globally. Variables of a defined structure datatype may be declared both globally and locally and passed as function arguments. INTEGER, LONG_INTEGER, SIGNED_INTEGER, SIGNED_LONG_INTEGER and STRING are the only SIMPL+ datatypes allowed to be used as structure member fields.
  • Page 318: Compiler Error 1304

    // error – if-statement block cannot FUNCTION MyFunc() // ok – MyFunc is global FUNCTION MyLocalFunc() // error – MyLocalFunc is local to MyFunc Crestron SIMPL+ // ok // ok // error contain local variables Language Reference Guide - DOC. 5797G...
  • Page 319: Compiler Error 1306

    ® Crestron SIMPL+ Compiler Error 1306 declaration error: Declaration type can only be used globally: I/O declarations must be defined globally; they cannot be declared as local variables inside of a function or library file. The following are examples of this error: Language Reference Guide - DOC.
  • Page 320: Compiler Error 1307

    DIGITAL_OUTPUT do2; // ok ANALOG_INPUT aiArr2[20]; // ok – multiple arrays are allowed DIGITAL_INPUT di5; // error – cannot define after diArr1 ANALOG_INPUT ai2; // error – cannot define after aiArr2 Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 321: Compiler Error 1308

    ® Crestron SIMPL+ Compiler Error 1308 declaration error: Global variable declaration cannot be I/O declarations and global variables can only be defined in a SIMPL+ module (.usp file). Libraries files (.usl files) are files that only contain functions. Local functions variables, function arguments and function that return values are permitted within library files.
  • Page 322: Compiler Error 1309

    #DEFAULT_VOLATILE // error – global variables have already been FUNCTION MyFunc() //////////////////////////////////////////////////////////// ////// // Example 3 #DEFAULT_VOLATILE // ok – compiler directive exists before Crestron SIMPL+ all global variables declared within this module Language Reference Guide - DOC. 5797G ®...
  • Page 323: Compiler Error 1310

    ® Crestron SIMPL+ Compiler Error 1310 declaration error: Compiler directive cannot be in function Compiler directives cannot be used locally within functions. They can only be used at a global level and the directive applies to the entire SIMPL+ module.
  • Page 324: Compiler Error 1311

    CancelWait( AnotherWaitLabel ); // ok PauseWait( MyWaitLabel ); ResumeWait( MyFunc ); valid ResumeWait( someLabel ); not exist Crestron SIMPL+ // ok // error – MyWaitLabel has not been declared yet // ok – Label is not required // ok – MyWaitLabel is unique // error –...
  • Page 325: Compiler Error 1312

    ® Crestron SIMPL+ Compiler Error 1312 declaration error: Array boundary exceeded maximum size The maximum number of indices for an array is 65535. The following are examples of this error: Compiler Error 1313 declaration error: Minimum array size invalid The minimum array size cannot exceed the total size of the array. The minimum array size must be between 1 and the total size of the array.
  • Page 326: Compiler Error 1314

    ANALOG_INPUT anlgIn2[10,5]; // ok – no other ANALOG_INPUT has been array size INTEGER x[10]; INTEGER y[10,5]; // error – INTEGER is not an Input or Crestron SIMPL+ // ok // ok – minimum size is 5 variable, digIn2, has already been declared with a minimum array size...
  • Page 327: Assignment Errors (Compiler Errors 1400 To 1402)

    ® Crestron SIMPL+ Assignment Errors (Compiler Errors 1400 to 1402) Compiler Error 1400 assignment error: Illegal Assignment Assignments in SIMPL+ require that the value being assigned to a variable must equate to the same type as that variable. Integer variables can only be assigned integer values and string variables can only be assigned a string value.
  • Page 328: Compiler Error 1401

    Print( “str = %s”, str ); written Print( “sOut = %s”, sOut ); // error – the value of sOut is unknown Crestron SIMPL+ // ok // ok – STRINGs can be read and Language Reference Guide - DOC. 5797G...
  • Page 329: Function Argument Errors (Compiler Errors 1500 To 1508)

    ® Crestron SIMPL+ Function Argument Errors (Compiler Errors 1500 to 1508) Compiler Error 1500 function argument error: Argument <arg_num> cannot be A variable was being passed that can either only have a value assigned to it, or it’s value be copied into another variable or used within an expression. An example of this is trying to pass a STRING_INPUT variable as a function argument;...
  • Page 330: Compiler Error 1501

    FUNCTION MyFunc( ByVal STRING strArr[] ) cannot be FUNCTION MyFunc( ByVal INTEGER intArr[][] ) // error – arrays cannot be FUNCTION MyFunc( ByVal STRING strArr[][] ) cannot be Crestron SIMPL+ // ok cannot be passed by reference // error – arrays passed by value // error –...
  • Page 331: Compiler Error 1502

    ® Crestron SIMPL+ Compiler Error 1502 function argument error: Function contains incomplete When calling a functions that contain parameter lists, the number of arguments passed to the function must match the number of parameters defined for that function. The following are examples of this error:...
  • Page 332: Compiler Error 1504

    Print( “My name is %s. My age is %d”, “David” ); error – // %d format specifier does not have a Crestron SIMPL+ or Output signal // error – ‘i’ is not or Output signal // error – ‘5’ is not or Output signal My age is %d”, str, x );...
  • Page 333: Compiler Error 1505

    ® Crestron SIMPL+ Compiler Error 1505 function argument error: Format string contains invalid An invalid format specifier was used within a format string. Format strings contain specifications that determine the output format for the arguments. The format argument consists of ordinary characters, escape sequences, and (if arguments follow format) format specifications Format Specifications always begin with a percent sign (%) and are read left to right.
  • Page 334: Compiler Error 1506

    SetArray( x, 1 ); Call MyFunc( x, StrArr ); // ok SetArray( i, 1 ); Call MyFunc( 1, “abc” ); Crestron SIMPL+ // error – 2 arguments are expected // error – argument 2 is missing // ok // error – i is not an array // error –...
  • Page 335: Compiler Error 1508

    ® Crestron SIMPL+ Compiler Error 1508 function argument error: I/O variable cannot be passed to Read file functions (ReadInteger, ReadString, etc.) cannot contain Input or Output variables for the function’s resulting read buffer. The following are examples of this error: Language Reference Guide - DOC.
  • Page 336: Construct Errors (Compiler Errors 1600 To 1608)

    CSwitch( x ) case (1): // ok – 1 has not been used yet case (2): // ok – 2 has not been used yet Crestron SIMPL+ // ok // error – Main() cannot a value a parameter list Language Reference Guide - DOC. 5797G...
  • Page 337: Compiler Error 1602

    ® Crestron SIMPL+ Compiler Error 1602 construct error: Switch statement contains 'default' without The Switch and CSwitch constructs must contain ‘case’ statements if the ‘default’ statement is to be used. The ‘default’ statement is optional. The following are examples of this error: Language Reference Guide - DOC.
  • Page 338: Compiler Error 1603

    // error – the category number should #CATEGORY 99 #DEFINE_CONSTANT MyCategory 6 #CATEGORY MyCategory category Crestron SIMPL+ // ok – “6” is the category number for Lighting // error – the category number, should be used instead of the category symbol name be enclosed in quotation marks // error –...
  • Page 339: Compiler Error 1604

    ® Crestron SIMPL+ Compiler Error 1604 construct error: 'EVENT' already has a body The EVENT statement can only be defined once per SIMPL+ module. A previously defined definition of EVENT was already encountered by the compiler. The following are examples of this error:...
  • Page 340: Compiler Error 1606

    // ok } until (1); if (1) break; // error – break cannot exist within an ‘if’ statement EVENT break; // error – TerminateEvent should be used instead Crestron SIMPL+ an event function Language Reference Guide - DOC. 5797G ®...
  • Page 341: Compiler Error 1607

    ® Crestron SIMPL+ Compiler Error 1607 construct error: GetLastModifiedArrayIndex may return an ambiguous signal index If an event function (EVENT, PUSH, CHANGE, RELEASE) is acting on more than one input array signal, the specific array will not be able to be determined based on the index returned from GetLastModifiedArrayIndex().
  • Page 342: File Errors (Compiler Errors 1700 To 1702)

    • Make sure the latest version of the Crestron Database is installed. • Make sure the path for the Crestron Database and User SIMPL+ files have been specified within SIMPL Windows. • Make sure the file does not exist with a Read-Only attribute.
  • Page 343: Compiler Warnings (Compiler Errors 1800 To 1803)

    ® Crestron SIMPL+ Compiler Warnings (Compiler Errors 1800 to 1803) Compiler Warning 1800 compiler warning: 'Return' statement will only terminate A ‘Return’ statement within a Wait Statement’s block of code will cause the Wait Statement to terminate. It will NOT terminate the current function that the Wait Statement resides within.
  • Page 344: Compiler Warning 1802

    #CATEGORY “1” #CATEGORY “2” FUNCTION MyFunc() #CATEGORY “3” // this is the resulting category number // for this SIMPL+ module FUNCTION AnotherFunc() Crestron SIMPL+ the Wait Statent, MyLabel2. MyLabel1 will continue to execute Language Reference Guide - DOC. 5797G ®...
  • Page 345: Compiler Warning 1803

    ® Crestron SIMPL+ Compiler Warning 1803 compiler warning: Possible data loss: LONG_INTEGER to A LONG_INTEGER result was assigned to an INTEGER variable or passed to a function for an INTEGER parameter. The 32-bit LONG_INTEGER will be truncated to 16-bit value and assigned to the integer, resulting in a loss of data.
  • Page 346: Simpl+ Revisions

    Software SIMPL+ Revisions For the latest revisions to SIMPL Windows, refer to the release notes installed with the program. This can be accessed in the Start Menu, under Programs | Crestron | SIMPL Windows ® SIMPL+ Crestron SIMPL+ Language Reference Guide - DOC. 5797G...
  • Page 347: System Interfacing - Cresnet And Cpu

    CIPID is an INTEGER containing the ID of the CIP device to query. JOIN_NUMBER is an INTEGER containing the Join number to get the status. For touchpanels, the join number is identical to the press/feedback number. For other devices, contact Crestron customer service. TYPE is one of several predefined constants: din:...
  • Page 348: Getcresnet

    CRESNET_ID is an INTEGER containing the ID of the Cresnet Network device to query. JOIN_NUMBER is an INTEGER containing the Join number to get the status. For touchpanels, the join number is identical to the press/feedback number. For other devices, contact Crestron customer service. ® SIMPL+ SetSlot(1,2,dout) = GetCIP(0x03,18,din);...
  • Page 349: Getslot

    ® Crestron SIMPL+ TYPE is one of several predefined constants: din: ain: dout: aout: NOTE: Access to serial signals is not supported. Return Value: An Integer. For Digital values, a non-zero value indicates a logic high and a 0 value indicates a logic low.
  • Page 350: Issignaldefined

    Digital inputs from device (symbol output list) Analog inputs from device (symbol output list) Digital outputs to device (symbol input list) Analog outputs to device (symbol input list) SetSlot(1,2,dout) = GetSlot(2,1,din); INTEGER IsSignalDefined <input/output signal>; Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 351: Sendcresnetpacket

    ® Crestron SIMPL+ Description: Retrieves the current SIMPL signal number associated with a particular input or output. This is generally used to determine if a particular input or output on a gate is being used, and generally used with arrayed inputs or outputs. This can be used to build a gate of a predetermined maximum size, and allow the user to add and subtract signals on the input or output of the gate (i.e., the program would be written to iterate...
  • Page 352: Sendpackettocpu

    SIMPL Windows symbol “Send Message to CPU (Speedkey: TMSG).” This function is not used in general programming. Parameters: PACKET is a string containing the command to send to the CPU. Return Value: None. ® SIMPL+ SendCresnetPacket(“\xFF\x03\x02”); SendPacketToCPU(STRING PACKET); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 353: Setcip

    This example will turn the Super Debugger on, which shows all network transitions on the console port of the control system. This command would normally be typed in manually through the Crestron Viewport, since it is for debugging only. Version: SIMPL+ Version 2.00...
  • Page 354: Setcresnet

    Digital inputs from device (symbol output list) Analog inputs from device (symbol output list) Digital outputs to device (symbol input list) Analog outputs to device (symbol input list) SetCresnet(0x07,69,dout) = GetCresnet(0x07,42,din); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 355: Setslot

    ® Crestron SIMPL+ Control System: X-Generation only SetSlot Name: SetSlot Syntax: Description: Sets the state of the join number on a particular card slot. Note that the device must be defined in SIMPL Windows and the join number to use must have a signal tied to it for this function to work.
  • Page 356 Here, SIG1 and SIG2 still reference Join #1 and Join #2, but SIG3 has been changed to reference Join #20, and SIG4 references Join #21. Version: SIMPL+ Version 2.00 ® SIMPL+ #ANALOG_INPUT_JOIN<constant> ANALOG_INPUT SIG1, SIG2, SIG3, SIG4; ANALOG_INPUT SIG1, SIG2; #ANALOG_INPUT_JOIN 20 ANALOG_INPUT SIG3, SIG4; Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 357: Analog_Output_Join

    ® Crestron SIMPL+ #ANALOG_OUTPUT_JOIN Name: #ANALOG_OUTPUT_JOIN Syntax: Description: Changes the join number starting with the next ANALOG_OUTPUT definition to the join number specified by <constant>. Example: In this example, SIG1 references Join #1, SIG2 references Join #2, SIG3 references Join #3, and SIG4 references Join #4.
  • Page 358: Digital_Output_Join

    Join #20, and SIG4 references Join #21. Version: SIMPL+ Version 2.00 #STRING_INPUT_JOIN Name: #STRING_INPUT_JOIN Syntax: ® SIMPL+ #DIGITAL_INPUT_JOIN 20 DIGITAL_INPUT SIG3, SIG4; #DIGITAL_OUTPUT_JOIN<constant> DIGITAL_OUTPUT SIG1, SIG2, SIG3, SIG4; DIGITAL_OUTPUT SIG1, SIG2; #DIGITAL_OUTPUT_JOIN 20 DIGITAL_OUTPUT SIG3, SIG4; #STRING_INPUT_JOIN<constant> Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 359: String_Output_Join

    ® Crestron SIMPL+ Description: Changes the join number starting with the next STRING_INPUT or BUFFER_INPUT definition to the join number specified by <constant>. Example: In this example, SIG1 references Join #1, SIG2 references Join #2, SIG3 references Join #3, SIG4 references Join #4, and B1$ references Join#5.
  • Page 360: Cen-Oem-Specific Definitions

    It is treated the same as a DIGITAL_OUTPUT. Example: Version: SIMPL+ Version 2.00 ® SIMPL+ _OEM_BREAK = <expression>; _OEM_BREAK = 1; // Generate A Short Break Crestron SIMPL+ // Write to Variable Language Reference Guide - DOC. 5797G ®...
  • Page 361: Oem_Cts

    ® Crestron SIMPL+ _OEM_CD Name: _OEM_CD Syntax: Any expression that can use a variable as part of its contents. Description: This variable is treated as a DIGITAL_INPUT and may be read from only. CD is the acronym for Carrier Detect. When a modem is hooked up to an RS-232 port and a connection (carrier) is made, the modem typically drives this pin high to let the connected hardware know that a data connection is present.
  • Page 362: Oem_Dtr

    The above example will pulse the DTR pin for 5-seconds when the CTS line goes high. Version: SIMPL+ Version 2.00 ® SIMPL+ PUSH _OEM_CTS PRINT(“CTS Pin has gone high!\n”); _OEM_DTR = <value>; PUSH _OEM_CTS PULSE(500, _OEM_DTR); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 363: Oem_Long_Break

    ® Crestron SIMPL+ _OEM_LONG_BREAK Name: _OEM_LONG_BREAK Syntax: or any expression that can use a variable as part of its contents. Description: When set to a non-zero value, causes the start of a break being transmitted on the port. A break is continuous logic low being generated on the port. In order to stop break generation, the variable should be set to 0.
  • Page 364: Oem_Pacing

    Version: SIMPL+ Version 2.00 ® SIMPL+ _OEM_MAX_STRING = 1000; _OEM_PACING = <expression>; CHANGE _OEM_STR_IN IF(_OEM_STR_IN = “\x01\x02”) _OEM_STR_OUT = “\x02ACK\x03”; CLEARSTRING(_OEM_STR_IN); FUNCTION MAIN() _OEM_PACING = 10; Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 365: Oem_Str_In

    ® Crestron SIMPL+ _OEM_RTS Name: _OEM_RTS Syntax: or any expression that can use a variable as part of its contents. Description: This variable is treated the same as DIGITAL_OUTPUT. In a program where hardware handshaking is not being used, the program may control the RTS pin for its own application.
  • Page 366: Oem_Str_Out

    SIMPL+ INTEGER I; CHANGE _OEM_STR_IN FOR(I=1 to len(_OEM_STR_IN)) IF(byte(_OEM_STR_IN, I) = 0x7F _OEM_STR_OUT = “\x15”; CLEARSTRING(_OEM_STR_IN); INTEGER I; CHANGE _OEM_STR_OUT FOR(I=1 to len(_OEM_STR_OUT)) IF(byte(_OEM_STR_OUT, I) = 0x7F _OEM_STR_IN = “\x15”; CLEARSTRING(_OEM_STR_OUT); Crestron SIMPL+ Language Reference Guide - DOC. 5797G ®...
  • Page 367: Index

    Compiler Directives, ...33 Compiler Directives Overview, ...33 Compiler Errors and Warnings Overview, ...286 COMPILER WARNINGS, ...333 CONSTRUCT ERRORS, ...326 Conventions Used, ...13 Converting from an X-Generation to a 2-Series Target, ...7 CRESTRON Limited Warranty, ...367 CSWITCH, ...87 Software ® SIMPL+...
  • Page 368 FileGetMonthNum, ... 132 FileGetSecondsNum, ... 133 FileGetYearNum, ... 134 FileLength, ... 136 FileMonth, ... 137 ® SIMPL+ Crestron SIMPL+ FileOpen, ... 138 FileRead, ... 141 FileSeek, ... 143 FileTime, ... 145 FileWrite, ... 146 Find, ... 220 FindClose, ... 148 FindFirst, ...
  • Page 369 ® Crestron SIMPL+ Introduction, ... 1 IsDirectory, ... 153 IsHidden, ... 154 IsReadOnly, ... 155 IsSignalDefined, ... 340 IsSystem, ... 156 IsVolume, ... 157 ItoA, ... 112 ItoHex, ... 113 Language Constructs & Functions, ... 29 Language Constructs & Functions Overview, ... 29 Left, ...
  • Page 370 SYNTAX ERRORS, ... 289 System Control, ... 234 System Interfacing, ... 238 ® SIMPL+ Crestron SIMPL+ Target Selection, ... 8 Task Switching for 2-Series Control Systems, ... 25 TerminateEvent, ... 237 TIME, ... 256 Time & Date Functions, ... 242 Trademark Information, ...
  • Page 371: Software License Agreement

    This Agreement may only be modified by a writing signed by an autho- rized officer of Crestron. Updates may be licensed to You by Crestron with additional or different terms. This is the entire agreement between Crestron and You relating to the Software and it supersedes any prior representations, discussions, undertakings, communica- tions or advertising relating to the Software.
  • Page 372 (90) days from the date of receipt, and (b) that any hardware accompanying the Software will be subject to its own lim- ited warranty as stated in its accompanying written material. Crestron shall, at its option, repair or replace or refund the license fee for any Software found defective by Crestron if notified by you within the warranty period.
  • Page 373: Return And Warranty Policies

    CRESTRON shall not be liable to honor the terms of this warranty if the product has been used in any application other than that for which it was intended, or if it has been subjected to misuse, accidental dam- age, modification, or improper installation procedures.
  • Page 374 Crestron Electronics, Inc. Language Reference Guide – DOC. 5797G 15 Volvo Drive Rockleigh, NJ 07647 04.03 Tel: 888.CRESTRON Fax: 201.767.7576 Specifications subject to www.crestron.com change without notice...

Table of Contents

Save PDF