Crestron SIMPL+® Software Language Reference Guide
This document was prepared and written by the Technical Documentation department at: Crestron Electronics, Inc. 15 Volvo Drive Rockleigh, NJ 07647 1-888-CRESTRON All brand names, product names and trademarks are the property of their respective owners. ©2003 Crestron Electronics, Inc.
Crestron SIMPL+® Software Contents SIMPL+ Language Reference Guide Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Software Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Licensing of SIMPL+ Cross Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 What's New . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Software Crestron SIMPL+ ® #DEFAULT_VOLATILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 #DEFINE_CONSTANT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 #HELP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 #HELP_BEGIN … #HELP_END . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 #HINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Crestron SIMPL+® Software File Function Return Error Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Reading and Writing Data to a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CheckForDisk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . EndFileOperations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . FileBOF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Software Crestron SIMPL+ WriteSignedLongIntegerArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . WriteStringArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . WriteStructure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Max . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Crestron SIMPL+® Software Calling a Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Function Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Example 2: 8-Level switch on a Pesa switcher . . . . . . . . . . . . . . . . . . . . . . Example 3: Computing the Number of Days in a Month (Using Functions) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Software Crestron SIMPL+ Compiler Error 1501 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Compiler Error 1502 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Compiler Error 1503 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Compiler Error 1504 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Compiler Error 1505 . . . . . . . . . . . . . . . . . . . . . . . . .
Crestron SIMPL+® Software _OEM_RTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 _OEM_STR_IN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 _OEM_STR_OUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Software Crestron SIMPL+ ® This page intentionally left blank. viii z Contents Language Reference Guide - DOC.
Crestron SIMPL+® Software Introduction SIMPL+® is a language extension that enhances SIMPL Windows by using a procedural “C-like” language to code elements of the program that were difficult, or impossible, with SIMPL alone. This help system provides specific information about the SIMPL+ language syntax, and can be used as a reference manual. For a tutorial on SIMPL+ programming, consult the SIMPL+ Programming Guide (Doc. 5789).
Software Crestron SIMPL+ ® Licensing of SIMPL+ Cross Compiler Crestron SIMPL+ Cross-Compiler Version 1.1 is simply an Installshield-installed version of the Coldfire GNU C Compiler, which is available on Crestron's FTP site in the SIMPL Windows directory as directory GNUSOURCE in ftp:// ftp.crestron.com/Simpl_Windows and in the \GNUSource directory of the Programming Tools CD. It includes and references code that is available from www.cygwin.com/cvs.
Crestron SIMPL+® Software When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
Software Crestron SIMPL+ ® itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works.
Crestron SIMPL+® Software distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
Software Crestron SIMPL+ ® If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software that everyone can redistribute and change under these terms. To do so, attach the following notices to the program.
Crestron SIMPL+® Software What's New Converting from an X-Generation to a 2-Series Target • Select 2-Series Target within SIMPL+ environment (From the SIMPL+ application menu, select Build | 2-Series Control System Target. The XGeneration Target may be deselected if no longer needed). • Recompile the SIMPL+ program. X-Generation Target and 2-Series Target Differences • I/O Datatypes (DIGITAL_INPUT, etc.) can no longer be passed to functions as arguments.
Software Crestron SIMPL+ ® Programming Environment Programming Environment Overview While running SIMPL Windows, select File | New SIMPL+ and the SIMPL+ programming environment appears. This section describes the environment for SIMPL+ Version 3.00. The SIMPL+ Module Information template is filled with commented code that makes it easy to remember the language syntax and structure. Simply locate the necessary lines, uncomment them, and add the appropriate code.
Crestron SIMPL+® Software NOTE: In previous versions of SIMPL+, the settings for the target types were system-wide. Those settings applied to all SIMPL+ modules that were opened and not specific to the active module being edited. In version 3.00, the target type setting is specific only to the active module being edited and saved within that module. The toolbar buttons reflect the target type of the active module within the SIMPL+ environment.
Software Crestron SIMPL+ ® Text Editor Tab Font - Used to select font to be used in SIMPL+ Text Editor's main window. Cursor Positioning, Auto-Indent - When the 'enter' key is pressed, the cursor will automatically indent to the same initial tab position as in the current line. • • To manually indent a block of text, highlight the block and press TAB. • If you have manually inserted spaces for tabs, then pressing SHIFT TAB will only outdent by only one space.
Crestron SIMPL+® Software Target Devices Tab Execute SIMPL+ Cross Compiler - After target files are compiled, the cross compiler can be launched from the SIMPL+ environment. This will enable you to generate the target file that will be uploaded to the operating system. Normally, the SIMPL Windows environment will handle this, since it is responsible for uploading the target file to the operating system.
Software Crestron SIMPL+ ® Insert #CATEGORY Toolbar Pull-Down Menu in SIMPL+ Symbol Tree Category Pop-Up Window Category Selection Insertion Box 12 z SIMPL+® Language Reference Guide - DOC.
Crestron SIMPL+® Software General Information Conventions Used Variable names are placed in <> when discussing syntax. For example, PUSH . Optional parameters are placed in [ ]. For example, when a list has many parameters, it would be described as [, ...] When discussing array notation, [ ] is used for array subscripting and is not used to mark optional code. Examples are placed in a Computer Style font, i.e.
Software Crestron SIMPL+ ® // printed is hello, // world. The second form of comment characters are the block comments. /* starts a block comment and */ ends a block comment. This is useful for commenting out large sections of code or writing large sections of documentation. Note that nested comments are not supported. Also, if /* or */ appear inside of a quoted string such as in an PRINT statement, they are not considered comments but part of the string.
Crestron SIMPL+® Software Operators Operators Overview SIMPL+ operators perform functions between two or more variables. SIMPL+ operators consist of Arithmetic, Bitwise, and Rational Operators. Arithmetic Operators OPERATOR NAME EXAMPLE EXPLANATION - Negation -X Negate the value of X (2’s Complement of X). * Multiplication X *Y Multiply X by Y (signed arithmetic). / Unsigned Division X/Y Divide X by Y, truncates result (unsigned arithmetic).
Software Crestron SIMPL+ ® Relational Operators OPERATOR NAME EXAMPLE EXPLANATION = Comparison X=Y True if X is equal to Y, False otherwise. = Assignment X=Y Assigns the contents in Y to X. The assignment operator cannot be used within expressions. ! Complement !X If X = 0, X changes to 1. If X is different from 0, evaluates to 0. <> Not Equal To X <> Y X is not equal to Y. < Unsigned Less Than X
Crestron SIMPL+® Software String Operators OPERATOR = NAME Assignment* EXAMPLE A$ = B$ EXPLANATION Assigns the value in B$ to A$. *NOTE: Not allowed in expressions because of possible confusion with comparison. = Comparison A$ = B$ A$ equal B$ <> Not Equal To A$ <> B$ A$ is not equal to B$ < Less Than A$ < B$ A$ is less than B$ > Greater Than A$ > B$ A$ is greater than B$ For less than and greater than operations, the string is evaluated in ASCII order.
Software Crestron SIMPL+ ® Signed vs Unsigned Arithmetic ANALOG_INPUT, ANALOG_OUTPUTs, and INTEGER in SIMPL+ are 16-bit quantities. A 16-bit quantity can range from 0 - 65535 when it is treated without having a sign (positive or negative). If a 16-bit number is treated as signed in SIMPL+, the range becomes -32768 to 32767. The range from -32768 to -1 maps into 32768 to 65535. Expressed mathematically, the mapping is 65536 AbsoluteValue(Number).
Crestron SIMPL+® Software Datatype Conversions SOURCE DESTINATION ACTION INTEGER LONG_INTEGER Lower 2 bytes of destination = source. Upper 2 bytes cleared. INTEGER SIGNED_INTEGER The 2 bytes of source moved to destination. 2 byte number now treated as signed. INTEGER SIGNED_LONG_INTEGER Lower 2 bytes of destination = source. Upper 2 bytes cleared. LONG_INTEGER INTEGER Lower 2 bytes of source moved to destination, treated as unsigned.
Software Crestron SIMPL+ ® Operator Precedence & Grouping In an expression where many operators are present, some operators have “priority” over others. Operators with the same precedence level are evaluated strictly left to right. Grouping is used to change the way an expression is evaluated.
Crestron SIMPL+® Software 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. Example: INTEGER I; I=123; // Specify Decimal constant.
Software Crestron SIMPL+ ® Task Switching Task Switching for X-Generation (CNX) Control Systems Each SIMPL+ module runs as a separate task in the X-Generation (CEN-TVAV, CNMSX-AV/PRO, CNRACKX/-DP) Control System. In order to insure that no SIMPL+ program takes up too much time, each task is allotted a certain amount of time to run. If the task exceeds this time limit, the system will switch out and allow other tasks (including the SIMPL program) to run.
Crestron SIMPL+® Software 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, there would be many outputs, indicating each time the FOR loop exceeded the allotted time, the SIMPL program would be given time to run and the TEST2 symbol would post the results.
Software Crestron SIMPL+ ® { Running = 1; FOR(I = 0 TO 32000) { // code } Running = 0; } } FUNCTION MAIN() { Running = 0; } In this case, a new variable, Running is declared and set to 0 on system startup in the MAIN. When the event is triggered, if Running is 0, then it will be set to 1, and the FOR loop will execute. Assume now the event has a task switch. If trig is hit again, the event will start, but will immediately exit because IF statement evaluates to false.
Crestron SIMPL+® Software 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. To insure that no SIMPL+ program takes too much time, each task is allotted a certain amount of time to run. If the task exceeds this time limit, the system will switch out and allow other tasks (including the SIMPL program) to run.
Software Crestron SIMPL+ ® PUSH trig { j=0; FOR(j=0 to 32000) { q = j; } i = q; } This program output would only show the final result; the TEST2 would be triggered once with the value 32000. The system will still perform whatever task switching required. As with the X-Generation series, re-entrance can still be a problem. When an event has task switched away, the event may be retriggered and a new copy of the event will start running. Therefore, SIMPL+ events are considered to be re-entrant.
Crestron SIMPL+® Software 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. The programmer who writes the MAIN() function should also be aware that the MAIN() function begins running when the SIMPL Windows program is initializing.
Software Crestron SIMPL+ ® One more operational difference between the X-Generation and 2-Series control systems is the event interaction.
Crestron SIMPL+® Software 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. Syntax: The SIMPL+ specific language requirements for this particular construct or function. This section demonstrates exactly how to enter the statement in a SIMPL+ program.
Software Crestron SIMPL+ ® Return Value (applies to functions only): Values placed in the return variable include error conditions. Error conditions are results that occur if one or more of the input values does not have values that are legal for that function. Example: A code example of how this function is typically used. Version: The version of SIMPL+ in which the construct or function was made available and any revision notes about differences between various versions of SIMPL+.
Crestron SIMPL+® Software 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. Do not confuse the declaration of the length of STRINGs with the declaration of arrays. E.g.
Software Crestron SIMPL+ ® Declaration Examples: 32 z SIMPL+® DECLARATION MEANING DIGITAL_INPUT in[10]; 10 digital inputs, in[1] to in[10] INTEGER MyArray[10][20]; 11 rows by 21 columns of data, from MyArray[0][0] to MyArray[10][20] STRING PhoneNumbers[100][32]; 101 strings that are a maximum of 32 characters long, e.g. PhoneNumbers[0] to PhoneNumbers[100] STRING_INPUT in$[32]; One input string called in$ that is 32 characters long.
Crestron SIMPL+® Software 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: #CATEGORY “” Description: A Category is the name of the folder in the Logic Symbols library tree where the module is shown.
Software Crestron SIMPL+ ® #CRESTRON_LIBRARY Name: #CRESTRON_LIBRARY Syntax: #CRESTRON_LIBRARY “” 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: #CRESTRON_LIBRARY “Special Integer Functions” Directs the compiler to include the Crestron Library “Special Integer Functions.CSL” from the Crestron SIMPL+ Archive. Version: SIMPL+ Version 3.
Crestron SIMPL+® Software #DEFAULT_NONVOLATILE Name: #DEFAULT_NONVOLATILE Syntax: #DEFAULT_NONVOLATILE 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 #DEFAULT_VOLATILE on page 36. Example: #DEFAULT_NONVOLATILE Version: SIMPL+ Version 3.00 Control System: 2-Series only Language Reference Guide - DOC.
Software Crestron SIMPL+ ® #DEFAULT_VOLATILE Name: #DEFAULT_VOLATILE Syntax: #DEFAULT_VOLATILE Description: Program variables will not retain their value if hardware power is lost. The compiler will default all variables declared within the SIMPL+ module as volatile. Individual variables can use the Nonvolatile keyword to override this default. See also #DEFAULT_NONVOLATILE on page 35. Example: #DEFAULT_VOLATILE Version: SIMPL+ Version 3.00 Control System: 2-Series only.
Crestron SIMPL+® Software #DEFINE_CONSTANT Name: #DEFINE_CONSTANT Syntax: #DEFINE_CONSTANT Description: Define a that will be substituted anywhere in the current source file where is used. Example: #DEFINE_CONSTANT ETX 0x03 INTEGER I; I=ETX; Assigns the value of 0x03 to the variable I. Version: SIMPL+ Version 1.00 Language Reference Guide - DOC.
Software Crestron SIMPL+ ® #HELP Name: #HELP Syntax: #HELP “” Description: Several #HELP lines can be specified. 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. If this directive or the #HELP_BEGIN … #HELP_END directive is not present, the help text shown is “NO HELP AVAILABLE”.
Crestron SIMPL+® Software #HELP_BEGIN … #HELP_END Name: #HELP_BEGIN … #HELP_END Syntax: #HELP_BEGIN Help Text Line 1 Help Text Line 2 etc. #HELP_END 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. If this directive or #HELP is not present, the help text shown is “NO HELP AVAILABLE”.
Software Crestron SIMPL+ ® #HINT Name: #HINT Syntax: #HINT “Hint Text” Description: 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. The text shows up as the symbol name as it is stored on disk, followed by a colon, followed by the text.
Crestron SIMPL+® Software #IF_DEFINED … #ENDIF Name: #IF_DEFINED … #ENDIF Syntax: #IF_DEFINED #ENDIF Description: Results in compilation of the only if 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.
Software Crestron SIMPL+ ® #SYMBOL_NAME Name: #SYMBOL_NAME Syntax: #SYMBOL_NAME “” Description: By specifying , this name will show up on the header of the symbol in the detail view as well as in the USER SIMPL+ section of the Symbol Library. If this directive is not present, the default name shown in the Symbol Library/Program View/Detail view is the name of the USP file as saved on disk. For example, if the file is saved as “Checksum Program.
Crestron SIMPL+® Software #USER_LIBRARY Name: #USER_LIBRARY Syntax: #USER_LIBRARY “” 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).
Software Crestron SIMPL+ ® #IF_NOT_DEFINED … #ENDIF Name: #IF_NOT_DEFINED … #ENDIF Syntax: #IF_NOT_DEFINED #ENDIF Description: Results in compilation of the only if has not been previously 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.
Crestron SIMPL+® Software 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. The outputs are shown in the order of DIGITAL_OUTPUTs, ANALOG_OUTPUTs, STRING_OUTPUTs.
Software Crestron SIMPL+ ® Fixed and Variable Size Arrays Although SIMPL+ symbols can only handle one variable size DIGITAL_INPUT array, one variable-size DIGITAL_OUTPUT array, one variable-size ANALOG/ STRING/BUFFER input array, and one variable size ANALOG/STRING/OUTPUT array, it is convenient to be able to refer to other inputs and outputs with array notation.
Crestron SIMPL+® Software ANALOG_INPUT Name: ANALOG_INPUT Syntax: ANALOG_INPUT [,...]; ANALOG_INPUT ; ANALOG_INPUT ]]> 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.
Software Crestron SIMPL+ ® ANALOG_OUTPUT Name: ANALOG_OUTPUT Syntax: ANALOG_OUTPUT [,...]; ANALOG_OUTPUT ; ANALOG_OUTPUT]]>; Description: Routes a value from the SIMPL+ program to the SIMPL program as an analog value. ANALOG_OUTPUT 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. Refer to the discussion on Arrays on page 46.
Crestron SIMPL+® Software Example: ANALOG_OUTPUT LEVEL; Signifies that one analog input is being sent from the SIMPL+ program to the SIMPL program. ANALOG_OUTPUT LEVELS[25]; 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. ANALOG_OUTPUT LEVELS[25,5]; Signifies same as above, except that a minimum of 5 are shown at any time.
Software Crestron SIMPL+ ® BUFFER_INPUT Name: BUFFER_INPUT Syntax: BUFFER_INPUT [,...]; BUFFER_INPUT ; BUFFER_INPUT]][max_length]>; Description: Routes serial inputs from the outside SIMPL program into a SIMPL+ program under the specified variable names. This is used when a serial string coming from a communications port needs to be processed by a SIMPL+ program.
Crestron SIMPL+® Software DIGITAL_INPUT Name: DIGITAL_INPUT Syntax: DIGITAL_INPUT [,...]; DIGITAL_INPUT ; DIGITAL_INPUT ; 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 page 46. NOTE: DIGITAL_INPUT variables may not be passed to functions in Version 3.
Software Crestron SIMPL+ ® DIGITAL_OUTPUT Name: DIGITAL_OUTPUT Syntax: DIGITAL_OUTPUT [,...]; DIGITAL_OUTPUT ; DIGITAL_OUTPUT ]]>; Description: Routes a value from the SIMPL+ program to a SIMPL program. If a value different from 0 is placed on a DIGITAL_OUTPUT, the digital signal in the SIMPL program is set high when the control system processes the logic. Refer to the discussion on arrays on page 46.
Crestron SIMPL+® Software Example: DIGITAL_OUTPUT State1, State2; 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. DIGITAL_OUTPUT state_bits[3]; Signifies that up to three digital signals are to be sent to a SIMPL program from this SIMPL+ program.
Software Crestron SIMPL+ ® INTEGER Name: INTEGER Syntax: INTEGER [,...]; INTEGER [size] [,[size]…]; INTEGER [rows1][columns1] [,[rows2][columns2]…]; Description: The first form declares an integer value that is local to this SIMPL+ program. INTEGER values are 16-bit quantities and are treated the same as ANALOG_INPUT values and range from 0-65535. The second form declares a one-dimensional array of INTEGER values.
Crestron SIMPL+® Software Example: INTEGER temp_level; Specifies one locally declared INTEGER in this SIMPL+ program INTEGER CommandBytes[2]; Specifies an array of three INTEGERS that can be referenced under the name CommandBytes. In pictorial form, it appears as: CommandBytes[0] CommandBytes[1] CommandBytes[2] INTEGER Matrix[4][3]; Specifies a two-dimensional array of integers five rows deep by four columns wide.
Software Crestron SIMPL+ ® LONG_INTEGER Name: LONG_INTEGER Syntax: LONG_INTEGER [,...]; LONG_INTEGER [size] [,[size]…]; LONG_INTEGER [rows1][columns1] [,[rows2][columns2]…]; Description: The first form declares a long value that is local to this SIMPL+ program. LONG_INTEGER values are 32-bit quantities ranging from 0-4294967296. The second form declares a one-dimensional array of LONG_INTEGER values.
Crestron SIMPL+® Software Example: LONG_INTEGER temp_level; Specifies one locally declared LONG_INTEGER in this SIMPL+ program LONG_INTEGER CommandBytes[2]; Specifies an array of three LONG_INTEGERs that can be referenced under the name CommandBytes. In pictorial form, it appears as: CommandBytes[0] CommandBytes[1] CommandBytes[2] LONG_INTEGER Matrix[4][3]; Specifies a two-dimensional array of LONG_INTEGERs five rows deep by four columns wide.
Software Crestron SIMPL+ ® SIGNED_INTEGER Name: SIGNED_INTEGER Syntax: SIGNED_INTEGER [,...]; SIGNED_INTEGER [size] [,[size]…]; SIGNED_INTEGER [rows1][columns1] [,[rows2][columns2]…]; Description: The first form declares an integer value that is local to this SIMPL+ program. SIGNED_INTEGER values are 32-bit quantities ranging from -32678 to 32767. The second form declares a one-dimensional array of SIGNED_INTEGER values.
Crestron SIMPL+® Software Example: SIGNED_INTEGER temp_level; Specifies one locally declared SIGNED_INTEGER in this SIMPL+ program SIGNED_INTEGER CommandBytes[2]; Specifies an array of three SIGNED_INTEGERS that can be referenced under the name CommandBytes. In pictorial form, it appears as: CommandBytes[0] CommandBytes[1] CommandBytes[2] SIGNED_INTEGER Matrix[4][3]; Specifies a two-dimensional array of integers five rows deep by four columns wide.
Software Crestron SIMPL+ ® SIGNED_LONG_INTEGER Name: SIGNED_LONG_INTEGER Syntax: SIGNED_LONG_INTEGER [,...]; SIGNED_LONG_INTEGER [size] [,[size]…]; SIGNED_LONG_INTEGER [rows1][columns1] [,[rows2][columns2]…]; Description: The first form declares a long value that is local to this SIMPL+ program. SIGNED_LONG_INTEGER values are 32-bit quantities ranging from 2,147,483,647 to 2,147,483,647. The second form declares a one-dimensional array of SIGNED_LONG_INTEGER values.
Crestron SIMPL+® Software Example: SIGNED_LONG_INTEGER temp_level; Specifies one locally declared SIGNED_LONG_INTEGER in this SIMPL+ program SIGNED_LONG_INTEGER CommandBytes[2]; Specifies an array of three SIGNED_LONG_INTEGERs that can be referenced under the name CommandBytes. In pictorial form, it appears as: CommandBytes[0] CommandBytes[1] CommandBytes[2] SIGNED_LONG_INTEGER Matrix[4][3]; Specifies a two-dimensional array of SIGNED_LONG_INTEGERs five rows deep by four columns wide.
Software Crestron SIMPL+ ® STRING Name: STRING Syntax: STRING [,...]; STRING [, ...]; Description: Declares a string that is local to this SIMPL+ program. Strings are of arbitrary length, so a maximum size must be specified. When a STRING variable has new data assigned to it, the old data is lost. NOTE: Strings in Version 3.00 for the 2-Series Control Systems may not be passed by value to a function.
Crestron SIMPL+® Software Example: STRING temp$[10]; Signifies that one local STRING is declared in this SIMPL+ program. STRING temp$[2][10]; Signifies that three strings of 10 characters long have been allocated. To assign values, the following would be legal: temp$[0]=”Val1”; temp$[1]=”Val2”; temp$[2]=”Val3”; Version: SIMPL+ Version 2.00 for SIZE and NUM_CHARACTER up to 65535. SIMPL+ Version 1.00 for everything else. Language Reference Guide - DOC.
Software Crestron SIMPL+ ® STRING_INPUT Name: STRING_INPUT Syntax: STRING_INPUT [,...]; STRING_INPUT ; STRING_INPUT ]][max_size]>; Description: Routes serial inputs from the outside SIMPL program into a SIMPL+ program under the specified variable names. Strings are of arbitrary length, so a maximum size must be specified. Upon receiving new data, the value is cleared and the new string is put in.
Crestron SIMPL+® Software STRING_OUTPUT Name: STRING_OUTPUT Syntax: STRING_OUTPUT [,...]; STRING_OUTPUT ; STRING_OUTPUT ]][size]>; 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 page 46.
Software Crestron SIMPL+ ® Example: STRING_OUTPUT TheName$; Signifies one string called TheName$ that is generated by the SIMPL+ program and sent to the SIMPL program. STRING_OUTPUT SortedNames$[5]; Specifies five strings that are generated by the SIMPL+ program and sent to the SIMPL program. The names are referred to as SortedNames[1] through SortedNames[5]. STRING_OUTPUT SortedNames$[5,5]; Same as above except all five are always shown. Version: SIMPL+ Version 3.
Crestron SIMPL+® Software 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. Structure datatypes can only be defined globally.
Software Crestron SIMPL+ ® The variable, Entry, is then defined to be an array of the datatype, PhoneBookEntry consisting of 501 individual instances, namely Entry[0] to Entry[500]. To access a structure’s field, the structure’s declared variable name is used, followed by a period (also known as the ‘dot’ or ‘dot operator’), then followed by a structure member variable name. From the example above, accessing the Name field from the declared variable would be written as follows: OneEntry.Name or Entry[5].
Crestron SIMPL+® Software Declaration Modifiers Volatile Name: Volatile Syntax: Volatile 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. Example: Volatile integer n; Volatile string s[100]; Version: SIMPL+ Version 3.00 Control System 2-Series Only .
Software Crestron SIMPL+ ® Nonvolatile Name: Nonvolatile Syntax: Nonvolatile 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 retain their value if hardware power is lost. Example: Nonvolatile integer n; Nonvolatile string s[100]; Version: SIMPL+ Version 3.00 Control System: 2-series only.
Crestron SIMPL+® Software E-mail Functions Important SendMail Considerations 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” authentication scheme is supported for now. 3. Questions for the ISP/e-mail service provider to determine compatibility with the SEND MAIL feature. A. Does the ISP/service provider support NON-WEB clients? B.
Software Crestron SIMPL+ ® E-mail Function Return Error Codes ERROR CODE # DESCRIPTION SMTP_OK 0 Success ERROR CODE # DESCRIPTION SMTP_ERROR_FATAL -1 Any non-recoverable error from the e-mail module of the firmware (for example: if “mailserver”, “from” and “to” are empty). SMTP_ERROR_ILLEGAL_CMD -2 General internal error. SMTP_ERROR_CONNECT -3 Failure to connect to the mailserver. SMTP_ERROR_SEND -4 Internal error while actually sending out e-mail.
Crestron SIMPL+® Software SendMail Name: SendMail Syntax: SIGNED_INTEGER SendMail( STRING Server, STRING UserLogonName, STRING UserLogonPassword, STRING From, STRING To, STRING CC, STRING Subject, STRING Message ) 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).
Software Crestron SIMPL+ ® a@b.com format. Multiple recipients may be specified delimited with a “;”. Maximum field length: 65535. Subject - Optional, but use an empty string to indicate that there is no subject. Specifies the subject of the e-mail message. Maximum field length: 989. Message - Optional, but use an empty string to indicate that there is no message. Specifies the body of the e-mail message. An empty string indicates an empty message. Maximum field length: 65535.
Crestron SIMPL+® Software 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: CHANGE [, ...] { [Local Variable Definitions] } Description: may be either a DIGITAL_INPUT, ANALOG_INPUT, or STRING_INPUT type.
Software Crestron SIMPL+ ® Example: STRING_INPUT some_data$[100]; ANALOG_OUTPUT level; CHANGE some_data$ { level=48; } When the STRING_INPUT changes, the ANALOG_OUTPUT level will have the value 48 put into it. If the same data comes in on some_data$, the CHANGE block is executed again.
Crestron SIMPL+® Software EVENT Name: EVENT Syntax: EVENT { [Local Variable Definitions] } Description: Executes the defined 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 80.
Software Crestron SIMPL+ ® PUSH Name: PUSH Syntax: PUSH [, ...] { [Local Variable Definitions] } Description: is a DIGITAL_INPUT type. On the rising edge of , 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.
Crestron SIMPL+® Software Release Name: RELEASE Syntax: RELEASE [, ...] { [Local Variable Definitions] } Description: is a DIGITAL_INPUT type. On the trailing edge of , 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.
Software Crestron SIMPL+ ® Stacked Events Stacked Events refers to multiple CHANGE, PUSH or RELEASE functions followed by a single block of code (complex statement). NOTE: Only CHANGE, PUSH, or RELEASE functions are used in stacked events. If necessary, refer to the descriptions of each function for details. NOTE: An input signal can be used in more than one event function. The order execution is as follows: The order for a PUSH: PUSH statements in the order they appear in the source.
Crestron SIMPL+® Software Expressions & Statements An expression consists of operators and operands. i.e., 5 * 6 or (VAL1 + 5) / 30 or (26 + BYTE(THESTRING$,1)) MOD Z = 25 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: X = Z/10; // Simple assignment statement using // operators.
Software Crestron SIMPL+ ® Looping Constructs Looping Constructs Overview Loops are used to perform a section of code zero or more times in a row in a given SIMPL+ program. The body of the loop can consist of statements, expressions, function calls, or other loops. DO - UNTIL Name: DO - UNTIL Syntax: DO [{] [}] UNTIL (); Description: This loop performs a set of at least one time and will terminate when evaluates to true.
Crestron SIMPL+® Software FOR Name: FOR Syntax: FOR ( = TO [STEP ]) [{] [}] Description: This loop executes the while iterates from the value of to the value of . The variable is incremented by at the end of the loop, if STEP is specified, else it is incremented by 1. The can be negative which will result in the loop counting down.
Software Crestron SIMPL+ ® Example: 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)); } In this example, the loop will iterate through each character of a string and print out the string and its position in the original string. Version: SIMPL+ Version 1.00 84 z SIMPL+® Language Reference Guide - DOC.
Crestron SIMPL+® Software WHILE Name: WHILE Syntax: WHILE() [{] [}] Description: This loop performs a set of as long as 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. If more than one statement is present in the loop body, then the { and } characters are mandatory. Note that depending on , the body of the loop may never be executed.
Software Crestron SIMPL+ ® Branching & Decision Constructs BREAK Name: BREAK Syntax: BREAK; Description: Terminates the innermost DO-UNTIL, FOR, or WHILE loop before the exit condition is met. Execution resumes after the end of the bop. Example: INTEGER X; ANALOG_INPUT Y; X=0; WHILE(X<25) { IF(Y = 69) BREAK; X = X + 1; PRINT(“X=%d\n”, X); } In this example, the WHILE loop will terminate if the ANALOG_INPUT Y equals the value of 69. Otherwise, the loop will exit via the normal termination condition.
Crestron SIMPL+® Software CSWITCH Name: CSWITCH Syntax: CSWITCH () { CASE (): [{] [break;] [}] CASE (): [{] [break;] [}] [DEFAULT: [{] [break;] [}] } NOTE: In SIMPL+ v3.01.00 and later, the 'break' statement is required to terminate the case statement block that it resides within.
Software Crestron SIMPL+ ® blocks are only a single statement, the { and } characters on the CASE may be omitted. If no condition is met in the CASE statements, the DEFAULT case, if specified, is used. CSWITCH has the restriction that the case statement only contains unique integer constants. CSWITCH differs from SWITCH in that the operating system is able to evaluate and execute the CSWITCH statement faster.
Crestron SIMPL+® Software IF - ELSE Name: IF - ELSE Syntax: IF ( ) [{] [}] [ELSE] [{] [}]] Since can be an IF construct, you can string out a series of IF-ELSE-IF statements of the form: IF () [{] [}] [ELSE] IF () [{] [}]] NOTE: A final ELSE may be used to express default handling if none of the previous conditions were met.
Software Crestron SIMPL+ ® Description: Executes a piece of code only if its associated evaluates to true. Many expressions can be tested if the IF-ELSE-IF construct is used. Note that only one block in an IF-ELSE or IF-ELSE-IF construct is executed. In any section of the construct, if is only a single statement, then the { and } characters may be omitted.
Crestron SIMPL+® Software SWITCH Name: SWITCH Syntax: SWITCH () { CASE (): [{] [}] CASE (): [{] [}] [DEFAULT: [{] [}] } 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 is equal to , is executed. If is equal to , is executed.
Software Crestron SIMPL+ ® Example: 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); } In this example, if the value of AIN is 2, X is set equal to 0. If AIN is 3, X is set equal to AIN. If AIN is 5, X is set equal to AIN+1. If AIN is any other value, an error message is printed. Version: SIMPL+ Version 2.00 - removes CASE restriction SIMPL+ Version 1.
Crestron SIMPL+® Software 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 Name: GetLastModifiedArrayIndex Syntax: INTEGER GetLastModifiedArrayIndex (); Description: Determines the specific index number of an input list array that has changed.
Software Crestron SIMPL+ ® Example 1 - Correct Use: DIGITAL_INPUT LIGHT_SCENES[10], MORE_LIGHT_SCENES[10}; DIGITAL_OUTPUT INTERLOCKED_LIGHT_SCENES[10]; INTEGER I; PUSH LIGHT_SCENES { FOR(I=1 to 10) INTERLOCKED_LIGHT_SCENES[I] = 0; ProcessLogic(); INTERLOCKED_LIGHT_SCENES[GetLastModifiedArrayIndex()] = 1; } Example 2 - Incorrect Use: 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 f
Crestron SIMPL+® Software GetNumArrayCols Name: GetNumArrayCols Syntax: INTEGER GetNumArrayCols(STRING | INTEGER ARRAY_NAME); 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.
Software Crestron SIMPL+ ® Example: DIGITAL_INPUT TEST; INTEGER My_Array[10][20]; PUSH TEST { PRINT(“Columns = %d\n”, GetNumArrayCols(My_Array)); } In this example, Columns = 20 will be printed. Version: SIMPL+ Version 2.00 96 z SIMPL+® Language Reference Guide - DOC.
Crestron SIMPL+® Software GetNumArrayRows Name: GetNumArrayRows Syntax: INTEGER GetNumArrayRows(STRING | INTEGER ARRAY_NAME); 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.
Software Crestron SIMPL+ ® SetArray Name: SetArray Syntax: SetArray (ARRAY_NAME, INTEGER | STRING INIT_VALUE); Description: Sets every element of ARRAY_NAME to the INIT_VALUE. Parameters: ARRAY_NAME is the name of the array to be initialized. It may be any array type. The INIT_VALUE may be a INTEGER or STRING.
Crestron SIMPL+® Software Example: DIGITAL_INPUT InitializeArrays; INTEGER Levels[10]; STRING Names[5][5]; PUSH InitializeArrays { SetArray(Levels, 3); SetArray(Levels, “3”); SetArray(Names, “xyz”); SetArray(Names, 0x41); } The first line initializes all elements of the integer array Levels to contain the integer 3.
Software Crestron SIMPL+ ® Bit & Byte Functions Bit & Byte Functions Overview These functions perform bit and byte masking operations in a given SIMPL+ program. Bit Name: Bit Syntax: INTEGER Bit(STRING SOURCE, INTEGER SOURCE_BYTE, INTEGER BIT_IN_BYTE); Description: Determine the state of a specified bit in a particular byte of a given string. Parameters: SOURCE contains a STRING in which a bit of one byte is to be examined. Each character in SOURCE is considered one byte.
Crestron SIMPL+® Software 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. STRING_INPUT SOURCE$[100]; STRING_OUTPUT OUT$; STRING TEMP$[100]; INTEGER I; CHANGE SOURCE$ { FOR(I = 1 to LEN(SOURCE$)) { IF(BIT(SOURCE$, I, 7) = 0) { MAKESTRING(TEMP$, “%s%s”, TEMP$, MID(SOURCE$, I, 1)); } } OUT$ = TEMP$; } Version: SIMPL+ Version 1.00 Language Reference Guide - DOC.
Software Crestron SIMPL+ ® Byte Name: Byte Syntax: INTEGER Byte (STRING SOURCE, INTEGER SOURCE_BYTE); Description: Returns the integer equivalent of the byte at position SOURCE_BYTE within a SOURCE string. Parameters: SOURCE is a STRING of characters. Each character in SOURCE is considered one byte. SOURCE_BYTE references a character in the SOURCE string. The leftmost character in SOURCE is considered 1.
Crestron SIMPL+® Software High Name: High Syntax: INTEGER High(INTEGER VALUE); 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: ANALOG_INPUT VALUE; CHANGE VALUE { PRINT(“The upper byte of %X is %X\n”, VALUE, HIGH(VALUE)) } This will print the input value and the upper 8-bits of the value in hexadecimal.
Software Crestron SIMPL+ ® Low Name: Low Syntax: INTEGER Low(INTEGER VALUE) Description: Returns the lower (least significant) 8-bits of an Integer. Parameters: VALUE is an integer containing the value of the least significant byte. Return Value: The lower (least significant) 8-bits of the passed value. Example: ANALOG_INPUT VALUE; CHANGE VALUE { PRINT(“The lower byte of %X is %X\n”, VALUE, LOW(VALUE)); } This will print the input value and the lower 8-bits of the value in hexadecimal.
Crestron SIMPL+® Software RotateLeft Name: RotateLeft Syntax: INTEGER RotateLeft( INTEGER X, INTEGER Y ); Description: Rotate X to the left (more significant direction) by Y bits; full 16 bits used. Same as {{ operator. See RotateRight on page 106. 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. Example: INTEGER X, Y, result; result = RotateLeft( X, Y ); Version: SIMPL+ Version 3.01.
Software Crestron SIMPL+ ® RotateRight Name: RotateRight Syntax: INTEGER RotateRight( INTEGER X, INTEGER Y ); Description: Rotate X to the right by Y bits; full 16 bits used. Same as }} operator. e.g.: Each bit takes the value of the bit that is Y bits more significant than it is. The most significant bit(s) are set from the least significant bits. 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.
Crestron SIMPL+® Software RotateLeftLong Name: RotateLeftLong Syntax: LONG_INTEGER RotateLeftLong( LONG_INTEGER X, INTEGER Y ); 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. Example: LONG_INTEGER X, Y, result; result = RotateleftLong( X, Y ); Version: SIMPL+ Version 3.01.06 Language Reference Guide - DOC.
Software Crestron SIMPL+ ® RotateRightLong Name: RotateRightLong Syntax: LONG_INTEGER RotateRightLong( LONG_INTEGER X, INTEGER Y ); Description: Rotate X to the right 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. Example: LONG_INTEGER X, Y, result; result = RotateRightLong( X, Y ); Version: SIMPL+ Version 3.01.
Crestron SIMPL+® Software 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. Atoi Name: Atoi Syntax: INTEGER Atoi(STRING SOURCE); Description: Converts a STRING to an INTEGER value.
Software Crestron SIMPL+ ® Atol Name: Atol Syntax: LONG_INTEGER Atol(STRING SOURCE); Description: Converts a STRING to an LONG_INTEGER value. The conversion looks for the first valid character (0-9), and then reads until it finds the first invalid character. The resulting string of valid characters is then converted. The “-” is ignored, hence the output is an unsigned number [i.e., ATOL(“-1”) would yield 1 as the output]. If no valid value to convert is found, 0 is returned.
Crestron SIMPL+® Software Chr Name: Chr Syntax: STRING Chr(INTEGER CODE); 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.
Software Crestron SIMPL+ ® ItoA Name: ItoA Syntax: STRING ItoA(INTEGER CODE); Description: Takes the value in CODE and creates a string containing the string equivalent of that integer. The output string does not contain leading zeros. Parameters: CODE contains a number from 0 to 65535 to be converted into a string. CODE is treated as an unsigned number. Return Value: A string representing the code. If CODE is greater than 65535, lower 16-bits of CODE are used in the computation.
Crestron SIMPL+® Software ItoHex Name: ItoHex Syntax: STRING ITOHEX(INTEGER CODE); 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. CODE is treated as an unsigned number. Return Value: A string representing the code.
Software Crestron SIMPL+ ® LtoA Name: LtoA Syntax: STRING LtoA(LONG_INTEGER CODE); Description: Takes the value in CODE and creates a string containing the string equivalent of that LONG_INTEGER. The output string does not contain leading zeros. Parameters: CODE contains a number from 0 to 2147483647 to be converted into a string. CODE is treated as an unsigned number. Return Value: A string representing the code.
Crestron SIMPL+® Software LtoHex Name: LtoHex Syntax: STRING LTOHEX(LONG_INTEGER CODE); 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. CODE is treated as an unsigned number. Return Value: A string representing the code.
Software Crestron SIMPL+ ® File Functions File Functions Overview File Functions perform file handle access from SIMPL+. Because of the overhead involved with maintaining current directory and file positions, there are restrictions on file I/O. Each SIMPL+ thread (main loop or event handler) that requires file operations must first identify itself with the operating system. This is done with the function, StartFileOperations. Before terminating the thread, the function EndFileOperations must be called.
Crestron SIMPL+® Software if(nNumWritten<0) Print (“WriteError”); FileClose( nFileHandle ); } EndFileOperations(); } File Function Return Error Codes KEYWORD VALUE FUNCTION FILE_BAD_USER -3000 Calling task is not a file user. Use StartFileOperations() first. FILE_NO_DISK -3004 Disk is removed. FILE_LONGPATH -3017 Path or directory name too long. FILE_INVNAME -3018 Path or filename includes invalid character. FILE_PEMFILE -3019 No file descriptors available (Too many files open).
Software Crestron SIMPL+ ® Reading and Writing Data to a File Reading and writing data to a file that is moved from one kind of a system to another has special programming considerations because it will likely be written on one kind of system, e.g. a 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.
Crestron SIMPL+® Software CheckForDisk Name: CheckForDisk Syntax: INTEGER CheckForDisk() 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()” on page 184. Example: (Refer to “File Functions Overview” on page 116) IF ( CheckForDisk () = 1 ) PRINT ( “compact flash card found” ); Version: SIMPL+ Version 3.00.
Software Crestron SIMPL+ ® EndFileOperations Name: EndFileOperations Syntax: SIGNED_INTEGER EndFileOperations() Description: Signifies to the operating system that the current thread has completed its file operations. Parameters: None. Return Value: Returns 0 if successful and –1 if an error occurred.
Crestron SIMPL+® Software FileBOF Name: FileBOF Syntax: SIGNED_INTEGER FileBOF (INTEGER handle) 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.
Software Crestron SIMPL+ ® FileClose Name: FileClose Syntax: SIGNED_INTEGER FileClose (INTEGER handle) Description: Closes a file opened previously by FileOpen. You MUST close a file that was opened, you won’t be able to open it again, or eventually the control system may hang or reboot. A reboot clears all open files. Files must be opened and closed during a single thread of operation. Refer to “StartFileOperations()” on page 183.
Crestron SIMPL+® Software FileDate Name: FileDate Syntax: STRING FileDate(FILE_INFO Info, INTEGER FORMAT); 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 149 for description). FORMAT is an integer describing the way to format the date for the return. Valid formats are 1 through 4.
Software Crestron SIMPL+ ® Example: (Refer to "File Functions Overview"on page 116) STRING TheDate$[100]; FILE_INFO FileInfo; SIGNED_INTEGER Found; StartFileOperations(); Found = FindFirst(“*.dat”, FileInfo ); 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(); This would print a string such as “Date of file = 03/25/2003”.
Crestron SIMPL+® Software FileDay Name: FileDay Syntax: STRING FileDay(FILE_INFO Info); 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 149 for description). 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.
Software Crestron SIMPL+ ® FileDelete Name: FileDelete Syntax: SIGNED_INTEGER FileDelete (STRING filename) Description: Deletes the specified file from the file system. Parameters: FILENAME specifies the name of the file to delete. Can contain wildcards (*) if a full path is not given. Return Value: Returns 0 if successful. Otherwise, file error code is returned.
Crestron SIMPL+® Software FileEOF Name: FileEOF Syntax: SIGNED_INTEGER FileEOF (INTEGER handle) 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.
Software Crestron SIMPL+ ® FileGetDateNum Name: FileGetDateNum Syntax: SIGNED_INTEGER FileGetDateNum(FILEINFO Info); Description: Returns an integer corresponding to the day of the month of the file. Parameters: INFO – structure containing the information about a found file (refer to "FindFirst" on page 149 for description). Return Value: The day of the month as an integer from 1 to 31.
Crestron SIMPL+® Software FileGetDayOfWeekNum Name: FileGetDayOfWeekNum Syntax: SIGNED_INTEGER FileGetDayOfWeekNum(FILEINFO Info); 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 149 for description). Return Value: The day of the week as an integer from 0 to 6; 0 represents Sunday to 6 representing Saturday.
Software Crestron SIMPL+ ® FileGetHourNum Name: FileGetHourNum Syntax: SIGNED_INTEGER FileGetHourNum(FILEINFO Info); Description: Returns an integer corresponding to the number of hours in the time of the file. Parameters: INFO – structure containing the information about a found file (refer to "FindFirst" on page 149 for description). Return Value: The number of hours from 0 to 23 (24-hour time format).
Crestron SIMPL+® Software FileGetMinutesNum Name: FileGetMinutesNum Syntax: SIGNED_INTEGER FileGetMinutesNum(FILEINFO Info); 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 149 for description). Return Value: The number of minutes from 0 to 59.
Software Crestron SIMPL+ ® FileGetMonthNum Name: FileGetMonthNum Syntax: SIGNED_INTEGER FileGetMonthNum(FILEINFO Info); Description: Returns an integer corresponding to the month of the year of file. Parameters: INFO – structure containing the information about a found file (refer to "FindFirst" on page 149). Return Value: The month of the year as an integer from 1 to 12.
Crestron SIMPL+® Software FileGetSecondsNum Name: FileGetSecondsNum Syntax: SIGNED_INTEGER FileGetSecondsNum(FILEINFO Info); 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 149 for description). Return Value: The number of seconds from 0 to 59.
Software Crestron SIMPL+ ® FileGetYearNum Name: FileGetYearNum Syntax: SIGNED_INTEGER FileGetYearNum(FILEINFO Info); Description: Returns an integer corresponding to the year of the file. Parameters: INFO – structure containing the information about a found file (refer to "FindFirst" on page 149 for description). Return Value: The year as an integer. The full year is specified. For example, the year 2000 will return the integer 2000.
Crestron SIMPL+® Software FILE_INFO Structure Use this structure to retrieve information about a file.
Software Crestron SIMPL+ ® FileLength Name: FileLength Syntax: LONG_INTEGER FileLength (INTEGER handle) Description: Returns the length of a file. Parameters: HANDLE specifies the file handle of the previously opened file (from FileOpen). Return Value: Number of bytes if successful. Otherwise, file error code is returned.
Crestron SIMPL+® Software FileMonth Name: FileMonth Syntax: STRING FileMonth(FILEINFO Info); 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 149 for description). 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.
Software Crestron SIMPL+ ® FileOpen Name: FileOpen Syntax: SIGNED_INTEGER FileOpen (STRING filename, INTEGER flags) Description: Opens a file. Parameters: FILENAME specifies the full path name or relative path name (link) of the file to open/create. FLAGS – File Open Flags. Can be combined using the Bitwise OR operator (|) NOTE: One of the following flags must be specified: _O_RDONLY, _O_WRONLY, or _O_RDWR KEYWORD FUNCTION _O_TEXT Unused _O_BINARY Unused _O_APPEND Writes done at the end of file.
Crestron SIMPL+® Software Examples: (Refer to "File Functions Overview"on page 116) Example 1: Open a read only file: SIGNED_INTEGER nFileHandle; StartFileOperations(); nFileHandle = FileOpen ( “MyFile”, _O_RDONLY ); IF (nFileHandle < 0) { PRINT(“Error Opening File MyFile\n”); } EndFileOperations(); Example 2: Open an existing file to log data to the end SIGNED_INTEGER nFileHandle; StartFileOperations(); nFileHandle = FileOpen ( “MyFile”, _O_WDONLY | _O_APPEND); IF (nFileHandle < 0) { PRINT(“Error Opening
Software Crestron SIMPL+ ® Version: SIMPL+ Version 3.00.02 or higher (Pro 2 only) Control System: 2-Series Only 140 z SIMPL+® Language Reference Guide - DOC.
Crestron SIMPL+® Software FileRead Name: FileRead Syntax: SIGNED_INTEGER FileRead (INTEGER handle, STRING buffer, INTEGER count ) Description: Reads data from a file as a series of bytes into a buffer, starting at the current file position.
Software Crestron SIMPL+ ® Example: (Refer to "File Functions Overview"on page 116) SIGNED_INTEGER nFileHandle; STRING sBuf [ 100 ]; StartFileOperations(); nFileHandle = FileOpen ( “MyFile”, _O_RDONLY ); 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(); Version: SIMPL+ Version 3.
Crestron SIMPL+® Software FileSeek Name: FileSeek Syntax: SIGNED_INTEGER FileSeek (INTEGER handle, LONG_INTEGER offset, INTEGER origin ) 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.
Software Crestron SIMPL+ ® Other Examples: 1. Go to beginning of file: FileSeek (nFileHandle, O, SEEK_SET) 2. Go to end of file: FileSeek (nFileHandle, O, SEEK_END) 3. Get current file position: CurrentBytePosition= FileSeek (nFileHandle,O, SEEK_CUR) Version: SIMPL+ Version 3.00.02 or higher (Pro 2 only) Control System: 2-Series Only 144 z SIMPL+® Language Reference Guide - DOC.
Crestron SIMPL+® Software FileTime Name: FileTime Syntax: STRING FileTime(FILEINFO Info); Description: Returns a string containing the current system time. Parameters: INFO – structure containing the information about a found file (refer to "FindFirst" on page 149 for description). 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.
Software Crestron SIMPL+ ® FileWrite Name: FileWrite Syntax: SIGNED_INTEGER FileWrite (INTEGER handle, STRING buffer, INTEGER count ) Description: Writes data from a file as a series of bytes into a buffer, starting at the current file position.
Crestron SIMPL+® Software Example: (Refer to "File Functions Overview"on page 116) SIGNED_INTEGER nFileHandle; STRING sBuf [ 4096 ]; StartFileOperations(); sBuf = “Hello World!”; nFileHandle = FileOpen ( “MyFile”, _O_WRONLY ); IF (nFileHandle >= 0) { if( FileWrite(nFileHandle, sBuf, 4096) > 0 ) PRINT ( “Written to file: %s\n”, sBuf ); IF ( FileClose ( nFileHandle ) <> 0 ) PRINT ( “Error closing file\n” ); } EndFileOperations(); Version: SIMPL+ Version 3.
Software Crestron SIMPL+ ® FindClose Name: FindClose Syntax: SIGNED_INTEGER FindClose() Description: Signifies to the operating system that the find operation has ended. Parameters: None. Return Value: Returns 0 if successful and –1 if an error occurred. Example: (Refer to "File Functions Overview"on page 116) FILE_INFO FileInfo; SIGNED_INTEGER Found; StartFileOperations(); Found = FindFirst(“*.dat”, FileInfo ); WHILE (Found = 0) { PRINT ( “%s\n”, FileInfo.
Crestron SIMPL+® Software FindFirst Name: FindFirst Syntax: SIGNED_INTEGER FindFirst(STRING filespec, FILE_INFO info) Description: This command searches a directory for file(s) matching the given file specification. Always followed with a FindClose, refer to page 148. Requires StartFileOperations(), refer to page 183. Parameters: FILESPEC specifies the filename to look for. It can be a full path name or a relative path name with wildcards ( the ‘*’ character), refer to page 14.
Software Crestron SIMPL+ ® Example: (Refer to "File Functions Overview"on page 116) FILE_INFO FileInfo; SIGNED_INTEGER Found; StartFileOperations(); Found = FindFirst(“*.dat”, FileInfo ); WHILE (Found = 0) { if ((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(); NOTE: FindFirst must be followed by a FindClose.
Crestron SIMPL+® Software FindNext Name: FindNext Syntax: SIGNED_INTEGER FindNext(FILE_INFO info) 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 149 for description). Return Value: Returns 0 if a file is found matching the specification and –1 if an error occurred.
Software Crestron SIMPL+ ® GetCurrentDirectory Name: GetCurrentDirectory Syntax: STRING GetCurrentDirectory() Description: Returns the complete path name of the current working directory. Refer to “Relative Path Names” on page 14 for a discussion of setting the current directory. Parameters: None. Return Value: String containing the current directory. If an error occurs, string length equals 0.
Crestron SIMPL+® Software IsDirectory Name: IsDirectory Syntax: INTEGER IsDirectory(FILE_INFO info) 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" on page 149 for a description). Return Value: Returns 1 if file is a directory and 0 otherwise.
Software Crestron SIMPL+ ® IsHidden Name: IsHidden Syntax: INTEGER IsHidden(FILE_INFO info) Description: This routine returns whether the specified file is hidden. Equivelent to checking attributes in FILE_INFO. Refer to page 135. Parameters: INFO – structure containing the information about a found file (refer to "FindFirst" on page 149 for description). Return Value: Returns 1 if file is hidden and 0 if otherwise.
Crestron SIMPL+® Software IsReadOnly Name: IsReadOnly Syntax: INTEGER IsReadOnly(FILE_INFO info) Description: This routine returns whether the specified file is marked as read-only. Equivalent to checking attributes in FILE_INFO. Refer to page 135. Parameters: INFO – structure containing the information about a found file (refer to "FindFirst" on page 149 for description). Return Value: Returns 1 if file is read-only and 0 if otherwise.
Software Crestron SIMPL+ ® IsSystem Name: IsSystem Syntax: INTEGER IsSystem(FILE_INFO info) Description: This routine returns whether the specified file is a system file. Equivalent to checking attributes in FILE_INFO. Refer to page 135. Parameters: INFO – structure containing the information about a found file (refer to "FindFirst" on page 149 for description). Return Value: Returns 1 if file is a system file and 0 if otherwise.
Crestron SIMPL+® Software IsVolume Name: IsVolume Syntax: INTEGER IsVolume(FILE_INFO info) Description: This routine returns whether the specified file is a volume label. Equivalent to checking attributes in FILE_INFO. Refer to page 135. Parameters: INFO – structure containing the information about a found file (refer to "FindFirst" on page 149 for description). Return Value: Returns 1 if file is a volume label and 0 if otherwise.
Software Crestron SIMPL+ ® MakeDirectory Name: MakeDirectory Syntax: SIGNED_INTEGER MakeDirectory(STRING DirName) Description: Creates a directory with the specified name. The path name can be relative or absolute, refer to page 14. Requires StartFileOperations(), refer to page 183. Parameters: DIRNAME – string containing the name of the desired directory. Return Value: Returns 0 if successful and –1 if an error occurred.
Crestron SIMPL+® Software ReadInteger Name: ReadInteger Syntax: SIGNED_INTEGER ReadInteger ( INTEGER file_handle, INTEGER i ) Description: Reads an integer from a file starting at the current file position. Two bytes are read, most significant byte first.
Software Crestron SIMPL+ ® Example: (Refer to "File Functions Overview"on page 116) SIGNED_INTEGER nFileHandle, iErrorCode; INTEGER i; StartFileOperations(); nFileHandle = 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(); Version: SIMPL+ Version 3.00.
Crestron SIMPL+® Software ReadIntegerArray Name: ReadIntegerArray Syntax: SIGNED_INTEGER ReadIntegerArray( INTEGER file_handle, INTEGER iArray[m][n] ) 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.
Software Crestron SIMPL+ ® Example: (Refer to "File Functions Overview"on page 116) SIGNED_INTEGER nFileHandle, iErrorCode; INTEGER iArray[10]; StartFileOperations(); nFileHandle = 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(); Version: SIMPL+ Version 3.00.
Crestron SIMPL+® Software ReadLongInteger Name: ReadLongInteger Syntax: SIGNED_INTEGER ReadLongInteger ( INTEGER file_handle, LONG_INTEGER li ) 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.
Software Crestron SIMPL+ ® Example: (Refer to "File Functions Overview"on page 116) SIGNED_INTEGER nFileHandle, iErrorCode; LONG_INTEGER li; StartFileOperations(); nFileHandle = 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(); Version: SIMPL+ Version 3.00.
Crestron SIMPL+® Software ReadLongIntegerArray Name: ReadLongIntegerArray Syntax: SIGNED_INTEGER ReadLongIntegerArray ( INTEGER file_handle, LONG_INTEGER ilArray[m][n] ) 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.
Software Crestron SIMPL+ ® Example: (Refer to "File Functions Overview"on page 116) SIGNED_INTEGER nFileHandle, iErrorCode; LONG_INTEGER ilArray[10]; StartFileOperations(); nFileHandle = 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(); Version: SIMPL+ Version 3.00.
Crestron SIMPL+® Software ReadSignedInteger Name: ReadSignedInteger Syntax: SIGNED_INTEGER ReadSignedInteger ( INTEGER file_handle, SIGNED_INTEGER si ) Description: Reads a signed integer from a file starting at the current file position. Two bytes are read, most significant first.
Software Crestron SIMPL+ ® Example: (Refer to "File Functions Overview"on page 116) SIGNED_INTEGER nFileHandle, iErrorCode; SIGNED_INTEGER si; StartFileOperations(); nFileHandle = 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(); Version: SIMPL+ Version 3.00.
Crestron SIMPL+® Software ReadSignedIntegerArray Name: ReadSignedIntegerArray Syntax: SIGNED_INTEGER ReadSignedIntegerArray ( INTEGER file_handle, SIGNED_INTEGER isArray[m][n] ) 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.
Software Crestron SIMPL+ ® Example: (Refer to "File Functions Overview"on page 116) SIGNED_INTEGER nFileHandle, iErrorCode; SIGNED_INTEGER isArray[10][5]; StartFileOperations(); nFileHandle = 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(); Version: SIMPL+ Version 3.00.
Crestron SIMPL+® Software ReadSignedLongInteger Name: ReadSignedLongInteger Syntax: SIGNED_INTEGER ReadSignedLongInteger ( INTEGER file_handle, SIGNED_LONG_INTEGER sli ) 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.
Software Crestron SIMPL+ ® Example: (Refer to "File Functions Overview"on page 116) SIGNED_INTEGER nFileHandle, iErrorCode; SIGNED_LONG_INTEGER sli; StartFileOperations(); nFileHandle = 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(); Version: SIMPL+ Version 3.00.
Crestron SIMPL+® Software ReadSignedLongIntegerArray Name: ReadSignedLongIntegerArray Syntax: SIGNED_INTEGER ReadSignedLongIntegerArray ( INTEGER file_handle, SIGNED_LONG_INTEGER sliArray[m][n] ) 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.
Software Crestron SIMPL+ ® Example: (Refer to "File Functions Overview"on page 116) SIGNED_INTEGER nFileHandle, iErrorCode; SIGNED_LONG_INTEGER sliArray[10][5]; StartFileOperations(); nFileHandle = 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(); Version: SIMPL+ Version 3.00.
Crestron SIMPL+® Software ReadString Name: ReadString Syntax: SIGNED_INTEGER ReadString ( INTEGER file_handle, STRING s ) 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.
Software Crestron SIMPL+ ® Example: (Refer to "File Functions Overview"on page 116) SIGNED_INTEGER nFileHandle, iErrorCode; STRING s[100]; StartFileOperations(); nFileHandle = 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(); Version: SIMPL+ Version 3.00.
Crestron SIMPL+® Software ReadStringArray Name: ReadStringArray Syntax: SIGNED_INTEGER ReadStringArray ( INTEGER file_handle, STRING s[] ) 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.
Software Crestron SIMPL+ ® Example: (Refer to "File Functions Overview"on page 116) SIGNED_INTEGER nFileHandle, iErrorCode; STRING s[100][100]; StartFileOperations(); nFileHandle = 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(); Version: SIMPL+ Version 3.00.
Crestron SIMPL+® Software ReadStructure Name: ReadStructure Syntax: ReadStructure ( INTEGER nFileHandle, STRUCTURE struct [, INTEGER nTotalBytesRead] ) 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.
Software Crestron SIMPL+ ® Example: (Refer to "File Functions Overview"on page 116) SIGNED_INTEGER nFileHandle, nTotalBytesRead; STRUCTURE PhoneBookEntry { STRING Name[50]; STRING Address[100]; STRING PhoneNumber[20]; }; PhoneBookEntry OneEntry; StartFileOperations(); nFileHandle = FileOpen ( “MyFile.txt”, _O_RDONLY ); if (nFileHandle >= 0) { ReadStructure( nFileHandle, PhoneBookEntry, nTotalBytesRead ); if( nTotalBytesRead < 0 ) PRINT ( “Error reading structure.
Crestron SIMPL+® Software RemoveDirectory Name: RemoveDirectory Syntax: SIGNED_INTEGER RemoveDirectory(STRING DirName) Description: Removes the directory with the specified name. The path name can be a relative link or absolute, refer to page page 14. Must be empty. Requires StartFileOperations(), refer to page page 183. Parameters: DIRNAME – string containing the name of the desired directory. Return Value: Returns 0 if successful and –1 if an error occurred.
Software Crestron SIMPL+ ® SetCurrentDirectory Name: SetCurrentDirectory Syntax: SIGNED_INTEGER SetCurrentDirectory(STRING DirName) Description: Changes the working directory to the specified name. Refer to “Relative Path Names” on page 14. Parameters: DIRNAME – string containing the name of the desired directory. Return Value: Returns 0 if successful and –1 if an error occurred.
Crestron SIMPL+® Software StartFileOperations Name: StartFileOperations Syntax: SIGNED_INTEGER StartFileOperations() 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.
Software Crestron SIMPL+ ® WaitForNewDisk Name: WaitForNewDisk Syntax: SIGNED_INTEGER WaitForNewDisk() Description: Waits for a compact flash card to be inserted into the control system. Refer to “CheckForDisk” on page 119. Parameters: None. Return Value: Returns 0 when a new compact flash card is installed into the control system, <0 if an error occurs. Example: (Refer to "File Functions Overview"on page 116) while(1) { if ( WaitForNewDisk() < 0 ) break; // perform operations on the new disk.
Crestron SIMPL+® Software WriteInteger Name: WriteInteger Syntax: SIGNED_INTEGER WriteInteger ( INTEGER file_handle, INTEGER i ) Description: Writes an integer from a file starting at the current file position. Two bytes are written, most significant byte first.
Software Crestron SIMPL+ ® Example: (Refer to "File Functions Overview"on page 116) SIGNED_INTEGER nFileHandle, iErrorCode; INTEGER i; StartFileOperations(); nFileHandle = 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(); Version: SIMPL+ Version 3.00.
Crestron SIMPL+® Software WriteIntegerArray Name: WriteIntegerArray Syntax: SIGNED_INTEGER WriteIntegerArray( INTEGER file_handle, INTEGER iArray[m][n] ) 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.
Software Crestron SIMPL+ ® Example: (Refer to "File Functions Overview"on page 116) SIGNED_INTEGER nFileHandle, iErrorCode; INTEGER iArray[10]; StartFileOperations(); nFileHandle = 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(); Version: SIMPL+ Version 3.00.
Crestron SIMPL+® Software WriteLongInteger Name: WriteLongInteger Syntax: SIGNED_INTEGER WriteLongInteger ( INTEGER file_handle, LONG_INTEGER li ) Description: Writes a long integer from a file starting at the current file position. Four bytes are written, most significant byte first.
Software Crestron SIMPL+ ® Example: (Refer to "File Functions Overview"on page 116) SIGNED_INTEGER nFileHandle, iErrorCode; LONG_INTEGER li; StartFileOperations(); nFileHandle = 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(); Version: SIMPL+ Version 3.00.
Crestron SIMPL+® Software WriteSignedInteger Name: WriteSignedInteger Syntax: SIGNED_INTEGER WriteSignedInteger ( INTEGER file_handle, SIGNED_INTEGER si ) Description: Writes a signed integer from a file starting at the current file position. Two bytes are written, most significant first.
Software Crestron SIMPL+ ® Example: (Refer to "File Functions Overview"on page 116) SIGNED_INTEGER nFileHandle, iErrorCode; SIGNED_INTEGER si; StartFileOperations(); nFileHandle = 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(); Version: SIMPL+ Version 3.00.
Crestron SIMPL+® Software WriteSignedIntegerArray Name: WriteSignedIntegerArray Syntax: SIGNED_INTEGER WriteSignedIntegerArray ( INTEGER file_handle, SIGNED_INTEGER isArray[m][n] ) 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.
Software Crestron SIMPL+ ® Example: (Refer to "File Functions Overview"on page 116) SIGNED_INTEGER nFileHandle, iErrorCode; SIGNED_INTEGER isArray[10][5]; StartFileOperations(); nFileHandle = 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(); Version: SIMPL+ Version 3.00.
Crestron SIMPL+® Software WriteSignedLongInteger Name: WriteSignedLongInteger Syntax: SIGNED_INTEGER WriteSignedLongInteger ( INTEGER file_handle, SIGNED_LONG_INTEGER sli ) 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.
Software Crestron SIMPL+ ® Version: SIMPL+ Version 3.01 or higher (Pro 2 only) Control System: 2-Series Only 196 z SIMPL+® Language Reference Guide - DOC.
Crestron SIMPL+® Software WriteSignedLongIntegerArray Name: WriteSignedLongIntegerArray Syntax: SIGNED_INTEGER WriteSignedLongIntegerArray ( INTEGER file_handle, SIGNED_LONG_INTEGER sliArray[m][n] ) 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.
Software Crestron SIMPL+ ® Example: (Refer to "File Functions Overview"on page 116) SIGNED_INTEGER nFileHandle, iErrorCode; SIGNED_LONG_INTEGER sliArray[10][5]; StartFileOperations(); nFileHandle = 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(); Version: SIMPL+ Version 3.00.
Crestron SIMPL+® Software WriteString Name: WriteString Syntax: SIGNED_INTEGER WriteString ( INTEGER file_handle, STRING s ) 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.
Software Crestron SIMPL+ ® Example: (Refer to "File Functions Overview"on page 116) SIGNED_INTEGER nFileHandle, iErrorCode; STRING s[100]; StartFileOperations(); nFileHandle = 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(); Version: SIMPL+ Version 3.00.
Crestron SIMPL+® Software WriteStringArray Name: WriteStringArray Syntax: SIGNED_INTEGER WriteStringArray ( INTEGER file_handle, STRING s[] ) 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.
Software Crestron SIMPL+ ® Example: (Refer to "File Functions Overview"on page 116) SIGNED_INTEGER nFileHandle, iErrorCode; STRING s[100][100]; StartFileOperations(); nFileHandle = 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(); Version: SIMPL+ Version 3.00.
Crestron SIMPL+® Software WriteStructure Name: WriteStructure Syntax: WriteStructure ( INTEGER nFileHandle, STRUCTURE struct [, INTEGER nTotalBytesWritten] ) 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.
Software Crestron SIMPL+ ® Example: (Refer to "File Functions Overview"on page 116) SIGNED_INTEGER nFileHandle, nTotalBytesWritten; STRUCTURE PhoneBookEntry { STRING Name[50]; STRING Address[100]; STRING PhoneNumber[20]; }; PhoneBookEntry OneEntry; StartFileOperations(); nFileHandle = FileOpen ( “MyFile.txt”, _O_WRONLY ); if (nFileHandle >= 0) { WriteStructure( nFileHandle, PhoneBookEntry, nTotalBytesWritten ); if( nTotalBytesWritten < 0 ) PRINT ( “Error writing structure.
Crestron SIMPL+® Software 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. Abs Name: Abs Syntax: INTEGER Abs(INTEGER SOURCE); INTEGER Abs(SIGNED_INTEGER or SOURCE); Description: Takes the absolute value of SOURCE. If SOURCE is negative, a positive value is returned. If SOURCE is already positive, the same value is returned.
Software Crestron SIMPL+ ® Max Name: Max Syntax: INTEGER Max(INTEGER VAL1, INTEGER VAL2) Description: Determine the maximum 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 maximum of Val1, Val2 after an unsigned comparison is performed. Refer to “Signed vs. Unsigned Arithmetic” on page 21 for a further explanation of how the values are compared.
Crestron SIMPL+® Software MIN Name: Min Syntax: INTEGER Min(INTEGER VAL1, INTEGER VAL2) 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. Unsigned Arithmetic” for a further explanation of how the values are compared.
Software Crestron SIMPL+ ® MulDiv Name: MulDiv Syntax: INTEGER MulDiv(INTEGER VAL1, INTEGER VAL2, INTEGER VAL3) Description: Computes the result (VAL1 * VAL2)/VAL3. Parameters: VAL1, VAL2, and VAL3 are INTEGER values. Return Value: A 16-bit integer is returned based on the above equation. The arithmetic operations are performed using unsigned arithmetic. Note that 32-bit math is used internally, so that if VAL1*VAL2 is greater than a 16-bit number, accuracy is maintained.
Crestron SIMPL+® Software SMAX Name: SMax Syntax: INTEGER SMax(INTEGER VAL1, INTEGER VAL2) 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. Unsigned Arithmetic” for a further explanation of how the values are compared.
Software Crestron SIMPL+ ® SMin Name: SMin Syntax: INTEGER SMin(INTEGER VAL1, INTEGER VAL2) Description: Determine the minimum 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 minimum of Val1, Val2 after a signed comparison is performed. Refer to “Signed vs. Unsigned Arithmetic” on page 21 for a further explanation of how the values are compared.
Crestron SIMPL+® Software Random Number Functions Random Number Functions Overview These functions allow a SIMPL+ program to generate a random number. Random Name: Random Syntax: INTEGER Random(INTEGER LowerBound, INTEGER UpperBound); Description: Generate a random number. Refer to “Seed” on page 213 and “Rnd” on page 212. Parameters: LowerBound is an INTEGER specifying the lower end of the range. UpperBound is an INTEGER specifying the upper end of the range.
Software Crestron SIMPL+ ® Rnd Name: Rnd Syntax: INTEGER Rnd(); Description: Generate a random number. Refer to “Seed” on page 213 and “Random” on page 211. Parameters: None. Return Value: An INTEGER from 0 to 65535. Example: INTEGER NUM; FUNCTION MAIN() { NUM = RND(); PRINT(“The random number is: %d\n”, NUM); } Version: SIMPL+ Version 1.00 212 z SIMPL+® Language Reference Guide - DOC.
Crestron SIMPL+® Software Seed Name: Seed Syntax: Seed(INTEGER SeedValue); 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. This default value is issued at control system restart, not program restart.
Software Crestron SIMPL+ ® String Formatting & Printing Functions String Formatting & Printing Functions Overview The printing functions are used to take INTEGER and STRING type arguments in a SIMPL+ program, format them in a user specified way, and send the output to either the COMPUTER port of the control system or to another STRING. MakeString Name: MakeString Syntax: MakeString(STRING DESTINATION, [, ...
Crestron SIMPL+® Software Example: INTEGER X; STRING Z[100], OUT[100]; X=10; Z=”Hello”; FUNCTION MAIN() { // Puts “This is a string” followed by a CRLF onto OUT. MAKESTRING(OUT, “This is string\n”); // Puts “The value of X is 10 in decimal, 0A in hex” // followed by CRLF onto OUT. MAKESTRING(OUT, “The value of X is %u in decimal, %02X in hex\n”, X, X); // Puts “The String value is Hello” onto OUT. MAKESTRING(OUT, “The String value is %s”, Z); } Version: SIMPL+ Version 2.
Software Crestron SIMPL+ ® Print Name: Print Syntax: PRINT( [, ...]); 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: is a quoted string that contains text and formatting information.
Crestron SIMPL+® Software 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. In the , certain values may be printed using “escape sequences”. Escape sequences start with the \ character and have a variable number of characters following.
Software Crestron SIMPL+ ® String Concatenation String concatenation can be performed either using the + operator or by using MAKESTRING or PRINT functions. It is easier to use the + operator in general usage, although the formatting options of the MAKESTRING and PRINT functions give greater flexibility. The + operator for strings is used the same way as in mathematical expressions. String concatenation may only be used as a standalone statement.
Crestron SIMPL+® Software 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: ClearBuffer(STRING BUFFERNAME); 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.
Software Crestron SIMPL+ ® Find Name: Find Syntax: INTEGER Find(STRING MATCH_STRING, STRING SOURCE_STRING [,INTEGER START_POSITION]); Description: Finds the position in SOURCE_STRING where MATCH_STRING first occurs. Parameters: MATCH_STRING is a STRING containing the data to be searched. SOURCE_STRING is a STRING containing the data to be searched. START_POSITION is an INTEGER which tells FIND at what character in the string to start the search, and is 1 based. If not specified, it defaults to 1.
Crestron SIMPL+® Software Gather Name: Gather Syntax: STRING Gather(STRING DELIMITER, STRING SOURCESTRING); 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. When the system returns to the GATHER, it will once again check for the proper delimiter.
Software Crestron SIMPL+ ® Example: 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$); } In the 2-Series Control System processors, a GATHER that is waiting for data will use up the next change of the BUFFER_INPUT until the terminating character is encountered. That is, any CHANGE event handler for the BUFFER_INPUT will not be called.
Crestron SIMPL+® Software GetC Name: GetC Syntax: INTEGER GetC(BUFFER_INPUT SOURCE); 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. Parameters: SOURCE is typically from a BUFFER_INPUT statement. It may be defined as a STRING or STRING_INPUT, but since GETC removes characters from SOURCE, the result is destructive to the source string.
Software Crestron SIMPL+ ® Left Name: Left Syntax: STRING Left(STRING SOURCE, INTEGER NUM); Description: Takes the leftmost NUM characters of SOURCE and returns them in an output string. Parameters: SOURCE is a STRING containing the source string. NUM is an INTEGER that tells LEFT how many characters to use in the computation. Return Value: A string representing the leftmost NUM characters of SOURCE. If NUM is greater than the number of characters in SOURCE, then the return is identical to SOURCE.
Crestron SIMPL+® Software Len Name: Len Syntax: INTEGER Len(STRING SOURCE); 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.
Software Crestron SIMPL+ ® Lower Name: Lower Syntax: STRING Lower(STRING SOURCE); 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 lowercase. SOURCE is not modified, unless it is also used as the return value, e.g., S$=LOWER(S$); Return Value: A STRING containing the lowercase version of SOURCE. Characters that do not fall into the range A-Z are not modified and will stay as specified.
Crestron SIMPL+® Software Mid Name: Mid Syntax: STRING Mid(STRING SOURCE, INTEGER START, INTEGER NUM); 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. The first character of SOURCE is considered 1. NUM is an INTEGER telling MID how many characters to use from SOURCE.
Software Crestron SIMPL+ ® Remove Name: Remove Syntax: STRING Remove(STRING DELIMITER, STRING SOURCESTRING [, INTEGER POSITION]); Description: Begins searching a string for the at the specified position, then removes all characters from the beginning of the string up to and including the delimiter. Returns a string containing all of the removed characters. Parameters: DELIMITER is a string containing the string to match for.
Crestron SIMPL+® Software REVERSEFIND Name: ReverseFind Syntax: INTEGER ReverseFind(STRING MATCH_STRING, STRING SOURCE_STRING [, INTEGER START_POSITION]); 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.
Software Crestron SIMPL+ ® Right Name: Right Syntax: STRING Right(STRING SOURCE, INTEGER NUM); Description: Takes the rightmost NUM characters of SOURCE and returns them in an output string. Parameters: SOURCE is a STRING containing the source string. NUM is an INTEGER that tells RIGHT how many characters to use in the computation. Return Value: A string representing the rightmost NUM characters of SOURCE.
Crestron SIMPL+® Software SetString Name: SetString Syntax: INTEGER SetString(STRING SOURCE, INTEGER POSITION, STRING DESTINATION); 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. 1 is the first byte of the string.
Software Crestron SIMPL+ ® Example: STRING DESTINATION$[100]; DESTINATION$ = :\”Space XXXX To Fill”; SETSTRING(“ABCD”, 7, DESTINATION$); 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 232 z SIMPL+® Language Reference Guide - DOC.
Crestron SIMPL+® Software Upper Name: Upper Syntax: STRING Upper(STRING SOURCE); 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$); Return Value: A STRING containing the uppercase version of SOURCE. Characters that do not fall into the range a-z are not modified and will stay as specified.
Software Crestron SIMPL+ ® System Control System Control Overview These constructs control system behavior and may change the resultant flow of the given SIMPL+ program. Delay Name: Delay Syntax: Delay(INTEGER TIME); Description: Forces a task switch and starts a timer for the hundredths of a second specified by TIME. The system continues with the statements after a delay when the delay time has expired. Refer to “WAIT” on page 265. Parameters: TIME is the number of hundredths of a second to delay.
Crestron SIMPL+® Software ProcessLogic Name: ProcessLogic Syntax: ProcessLogic(); 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 page 25. Parameters: None. Return Value: None. Example: INTEGER X; ANALOG_OUTPUT I; FOR(X=0 TO 25) { I = X; PROCESSLOGIC(); } In this example, the analog output I is updated every pass through the loop.
Software Crestron SIMPL+ ® Pulse Name: Pulse Syntax: Pulse(TIME, DIGITAL_OUTPUT OUT); Description: Pulses the output high then low for the specified length of time (in hundredths of a second). When the pulse starts, a task switch is performed so other logic can be processed. If the output is already high, the SIMPL Windows logic processor will not see a change and no further actions will be triggered. Parameters: TIME is the number of hundredths of a second to pulse.
Crestron SIMPL+® Software TerminateEvent Name: TerminateEvent Syntax: TerminateEvent; 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: INTEGER X; ANALOG_INPUT Y; CHANGE Y { X=0; WHILE(X<25) { IF(Y = 69) TerminateEvent; X = X + 1; PRINT(“X=%d\n”, X); } } In this example, the CHANGE event will terminate if the ANALOG_INPUT Y equals the value of 69.
Software Crestron SIMPL+ ® System Interfacing System Interfacing Overview These functions control the way the SIMPL+ program communicates with Cresnet network devices and the CPU. GenerateUserNotice Name: GenerateUserNotice Syntax: GenerateUserNotice( [, ...]); Description: Places a notification message into the control system's error log Parameters: is a quoted string that contains text and formatting information.
Crestron SIMPL+® Software GenerateUserWarning Name: GenerateUserWarning Syntax: GenerateUserWarning( [, ...]); Description: Places a warning message into the control system's error log Parameters: is a quoted string that contains text and formatting information. Format specifiers are of the form: %[[Pad]Width]specifier Refer to “Print” on page 216 for a list and description of valid Format Specifiers. Return Value: None.
Software Crestron SIMPL+ ® GenerateUserError Name: GenerateUserError Syntax: GenerateUserError( [, ...]); Description: Places an error message into the control system's error log Parameters: is a quoted string that contains text and formatting information. Format specifiers are of the form: %[[Pad]Width]specifier Refer to “Print” on page 216 for a list and description of valid Format Specifiers. Return Value: None.
Crestron SIMPL+® Software CheckForNVRAMDisk Name: CheckForNVRAMDisk Syntax: INTEGER CheckForNVRAMDisk() 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: (Refer to “File Functions Overview” on page 116) IF ( CheckForNVRAMDisk() = 1 ) PRINT ( "NVRAM Disk found" ); Version: SIMPL+ Version 3.01.
Software Crestron SIMPL+ ® Time & Date Functions Time and Date Functions Overview Time and Date functions in a given SIMPL+ program are used to retrieve information about the current date and time from the system clock. Values can be retrieved as either text strings i.e. “January” or as integer values. Typically, integer values are used if computations need to be performed (i.e. when the date is the 25th, perform a specific action).
Crestron SIMPL+® Software Day Name: Day Syntax: STRING Day(); 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. Example: STRING TheDay$[100]; FUNCTION MAIN() { TheDay$=DAY(); PRINT(“The day of the week is %s\n”, TheDay$); } An example output of this would be “The day of the week is Monday”. Version: SIMPL+ Version 1.
Software Crestron SIMPL+ ® GETDATENUM Name: GetDateNum Syntax: INTEGER GetDateNum(); Description: Returns an integer corresponding to the current day of the month. Parameters: None. Return Value: The day of the month as an integer from 1 to 31. Example: INTEGER NumDateOfMonth; FUNCTION MAIN() { NumDateOfMonth = GetDateNum(); PRINT(“The current day of the month is %d\n”, NumDateOfMonth); } An example output of this would be “The current day of the month is 25”. Version: SIMPL+ Version 1.
Crestron SIMPL+® Software GETDAYOFWEEKNUM Name: GetDayOfWeekNum Syntax: INTEGER GetDayOfWeekNum(); 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.
Software Crestron SIMPL+ ® GETHOURNUM Name: GetHourNum Syntax: INTEGER GetHourNum(); Description: Returns an integer corresponding to the number of hours in the current time. Parameters: None. Return Value: The number of hours from 0 to 23 (24-hour time format). Example: INTEGER NumHours; FUNCTION MAIN() { NumHours = GetHourNum(); PRINT(“The Number of hours on the clock is %d\n”, NumHours); } An example output of this would be “The Number of hours on the clock is 22”. Version: SIMPL+ Version 1.
Crestron SIMPL+® Software GETHSECONDS Name: GetHSeconds Syntax: INTEGER GetHSeconds(); 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. Parameters: None. Return Value: The number of hundredths of a second based on the system clock.
Software Crestron SIMPL+ ® GETMINUTESNUM Name: GetMinutesNum Syntax: INTEGER GetMinutesNum(); Description: Returns an integer corresponding to the number of minutes in the current time. Parameters: None. Return Value: The number of minutes from 0 to 59. Example: INTEGER NumMinutes; FUNCTION MAIN() { NumMinutes = GetMinutesNum(); PRINT(“The Number of minutes on the clock is %d\n”, NumMinutes); } An example output of this would be “The Number of minutes on the clock is 33”. Version: SIMPL+ Version 1.
Crestron SIMPL+® Software GETMONTHNUM Name: GetMonthNum Syntax: INTEGER GetMonthNum(); 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: INTEGER NumMonth; FUNCTION MAIN() { NumMonth = GetMonthNum(); PRINT(“The current month of the year is %d\n”, NumMonth); } An example output of this would be “The current month of the year is 9”. Version: SIMPL+ Version 1.
Software Crestron SIMPL+ ® GETSECONDSNUM Name: GetSecondsNum Syntax: INTEGER GetSecondsNum(); Description: Returns an integer corresponding to the number of seconds in the current time. Parameters: None. Return Value: The number of seconds from 0 to 59. Example: INTEGER NumSeconds; FUNCTION MAIN() { NumSeconds = GetSecondsNum(); PRINT(“The Number of seconds on the clock is %d\n”, NumSeconds); } An example output of this would be “The Number of seconds on the clock is 25”. Version: SIMPL+ Version 1.
Crestron SIMPL+® Software GETTICKS Name: GetTicks Syntax: INTEGER GetTicks(); 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. The use of this function is discouraged, GetHSeconds() should be used instead. Parameters: None.
Software Crestron SIMPL+ ® GETYEARNUM Name: GetYearNum Syntax: INTEGER GetYearNum(); Description: Returns an integer corresponding to the current year. Parameters: None. Return Value: The year as an integer. The full year is specified. For example, the year 2000 will return the integer 2000. Example: INTEGER NumYear; FUNCTION MAIN() { NumYear = GetYearNum(); PRINT(“The current year is %d\n”, NumYear); } An example output from this would be “The current year is 1999”. Version: SIMPL+ Version 1.
Crestron SIMPL+® Software MONTH Name: Month Syntax: STRING Month(); 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. Example: STRING TheMonth$[100]; FUNCTION MAIN() { TheMonth$=MONTH(); PRINT(“The Month is %s\n”, TheMonth$); } An example output of this would be “The Month is September”.
Software Crestron SIMPL+ ® SETCLOCK Name: SetClock Syntax: SetClock(INTEGER HOURS, INTEGER MINUTES, INTEGER SECONDS); Description: Sets the system clock. Parameters: HOURS is an integer containing the hour portion of the time to which the clock is set. HOURS is expressed in 24-hour format, which can range from 0 to 23. MINUTES is an integer containing the minutes portion of the time to which the clock is set. MINUTES range from 0 to 59.
Crestron SIMPL+® Software SETDATE Name: SetDate Syntax: SetDate(INTEGER MONTH, INTEGER DAY, INTEGER YEAR); 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. YEAR is an integer containing the year to which the date is set.
Software Crestron SIMPL+ ® TIME Name: Time Syntax: STRING TIME(); Description: Returns a string containing the current system time. Parameters: None. 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. Example: STRING TheTime$[100]; FUNCTION MAIN() { TheTime$=TIME(); PRINT(“The Time is %s\n”, TheTime$); } An example output from this would be “The Time is 14:25:32”. Version: SIMPL+ Version 1.
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.
Software Crestron SIMPL+ ® CancelAllWait Name: CancelAllWait Syntax: CancelAllWait(); Description: Cancels all WAIT events for the current SIMPL+ program. When an event is cancelled, it is removed from the wait list and will not activate. There is no effect on wait events that have finished running. Parameters: None. Return Value: None.
Crestron SIMPL+® Software CancelWait Name: CancelWait Syntax: CancelWait(NAME); 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. Parameters: NAME is a name of a previously defined and named WAIT event. Return Value: None.
Software Crestron SIMPL+ ® PauseAllWait Name: PauseAllWait Syntax: PauseAllWait(); Description: Pauses all WAIT events for 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. Parameters: None. Return Value: None.
Crestron SIMPL+® Software PauseWait Name: PauseWait Syntax: PauseWait(NAME); 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. Parameters: NAME is a name of a previously defined and named WAIT event. Return Value: None.
Software Crestron SIMPL+ ® ResumeAllWait Name: ResumeAllWait Syntax: ResumeAllWait(); Description: Resumes all WAIT events for the current SIMPL+ program that had been previously paused. The WAIT will execute when the time from when it was frozen until the specified wait time has elapsed. Parameters: None. Return Value: None.
Crestron SIMPL+® Software ResumeWait Name: ResumeWait Syntax: ResumeWait(NAME); 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. Parameters: NAME is a name of a previously defined and named WAIT event. Return Value: None.
Software Crestron SIMPL+ ® RetimeWait Name: RetimeWait Syntax: RetimeWait(INTEGER TIME, NAME); Description: Changes the time for a wait event in progress. When a WAIT is retimed, the WAIT is restarted. For example, if a 5-second wait is 3-second in, and it is retimed to 10second, a full 10-seconds must elapse before the WAIT triggers. Parameters: TIME is an integer that specifies the new wait time in hundredths of a second. If time is set to 0, the event will occur immediately.
Crestron SIMPL+® Software Wait Name: Wait Syntax: Wait(INTEGER TIME[, NAME]) [{] [}] 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. A currently running WAIT will finish before being entered into the WAIT list again.
Software Crestron SIMPL+ ® Example: INTEGER WaitTime; DIGITAL_INPUT StopVCR; ANALOG_INPUT SysWait; STRING_OUTPUT VCR$; PUSH StopVCR { WAIT (SysWait, VCR_Stop) { VCR$ = “\x02STOP\x03”; } } FUNCTION MyFunc() { while ( 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) } } In this example, a VCR is triggered to go into STOP, but the STOP command is del
Crestron SIMPL+® Software 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. Function Definition ([argument list]) { [RETURN ;] } The following table demonstrates what may be, what it means, and what data may be returned to the caller.
Software Crestron SIMPL+ ® Function Parameters NOTE: Passing STRINGs with BYVAL and 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. Functions may contain a list of parameters that are passed by the caller.
Crestron SIMPL+® Software 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. Keyword Meanings KEYWORD MEANING ByRef Changes made to the variable that is passed to the function actually change the contents of the source variable.
Software Crestron SIMPL+ ® 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.
Crestron SIMPL+® Software ByVal ByRef ReadOnlyByRef [LOCAL COPY] [SOURCE] [SOURCE] STRING_OUTPUT array - - - STRING_OUTPUT array element - - - STRUCTURE - R, W R STRUCTURE element (INTEGER) R, W - - STRUCTURE element (LONG_INTEGER) R, W - - STRUCTURE element (SIGNED_INTEGER) R, W - - STRUCTURE element (SIGNED_LONG_INTEGER) R, W - - - - - VARIABLE TYPE STRUCTURE element (STRING) R: Read access allowed. W: Write access allowed.
Software Crestron SIMPL+ ® Returning a Value NOTE: A zero (0) message is automatically returned if no return statement is encountered. The syntax for returning a value from integer and string functions is RETURN ;. To return a value from a FUNCTION, PUSH, CHANGE, RELEASE or EVENT, the syntax is RETURN. Integer functions include INTEGER_FUNCTION, SIGNED_INTEGER_FUNCTION, LONG_INTEGER_FUNCTION and SIGNED_LONG_INTEGER_FUNCTION. String functions include STRING_FUNCTION.
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; } Language Reference Guide - DOC.
Software Crestron SIMPL+ ® Calling a Function When calling a function where the return is being used, the syntax is: = ([argument_list]); For example, INTEGER X, ANALOG1, ANALOG2; STRING Q$[20], B$[50]; X = ComputeChecksum(Analog1, Analog2); Q$ = DoSomething(Analog1, B$); Are legal.
Crestron SIMPL+® Software 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. A function library is simply a group of functions in a SIMPL+ file. The file is saved as a SIMPL+ Library File (*.USL), from the Save As dialog in the SIMPL+ editor.
Software Crestron SIMPL+ ® Program Structure When a new SIMPL+ program is created, a template is provided that lists the order in which constructs and statements should be defined. Sections can be uncommented and expanded out to implement the desired code. A SIMPL+ program layout would consist of, in order: 1. Compiler Directives 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.
Crestron SIMPL+® Software 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. Array out of bounds An attempt was made to access an element of an array that is outside the declared range of the array.
Software Crestron SIMPL+ ® Scheduler is full Any time-based function such as DELAY, PULSE, or WAIT will schedule an event in SIMPL+. A scheduled event will add one or more entries to the SIMPL+ scheduler. The scheduler currently supports 200 events and is global to the entire SIMPL+ system. If the scheduler is full and another event is added, this message is issued. NOTE: The message “Skedder Full” is issued from a SIMPL program, not SIMPL+.
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”); } // Main is only called once when the system starts up or is reset. FUNCTION MAIN() { PRINT(“Main Starts!\n”); } Language Reference Guide - DOC.
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.
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); COUNT=0; // Checksum count initialized to 0. // Add each byte in the string to the running count.
Software Crestron SIMPL+ ® Example 3: Computing the Number of Days in a Month (Using Functions) #SYMBOL_NAME “Compute Number of Days in a Month” #ANALOG_INPUT MONTH; #ANALOG_OUTPUT DAYS; INTEGER_FUNCTION ComputeDaysInMonth(INTEGER Month) { // Note that this computation does NOT take into account leap // year! INTEGER Days; SWITCH (Month) { CASE( 2): Days = 28; // February CASE( 4): Days = 30; // April CASE( 6): Days = 30; // June CASE( 9): Days = 30; // September CASE(11): Days = 30; // November Default:
Crestron SIMPL+® Software 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”.
Software Crestron SIMPL+ ® File Time and Date Functions Overview These versions of the Time and Date functions in a given SIMPL+ program are used to retrieve information about the current date and time from the file info structure returned from FINDFIRST/FINDNEXT. Values can be retrieved as text strings i.e. “January” or integer values. Typically, integer values are used if computations need to be performed (i.e. when the date is the 25th, perform a specific action).
Crestron SIMPL+® Software Example: (Refer to "File Functions Overview"on page 116) INTEGER nFileHandle, iErrorCode; LONG_INTEGER ilArray[10]; nFileHandle = FileOpen ( “MyFile”, _O_RDONLY ); IF (nFileHandle >= 0) { iErrorCode = WriteLongIntegerArray(nFileHandle, ilArray); if (iErrorCode > 0) PRINT ( “Array written to file correctly.\n”); else PRINT ( “Error code %d\n”, iErrorCode); } Version: SIMPL+ Version 3.01 or higher (Pro 2 only) Control System: 2-Series Only Language Reference Guide - DOC.
Software Crestron SIMPL+ ® Compiler Errors and Warnings Compiler Errors and Warnings Overview The SIMPL+ program compiler errors and warnings are grouped into several categories, as shown in the following table. Errors are listed in numerical order; page links are provided to detailed descriptions of the errors.
Crestron SIMPL+® Software CATEGORY NUMBER MESSAGE TEXT PAGE Declaration Errors 1300 Array size missing Array size invalid page 304 1301 Invalid array index page 305 1302 Variable name, ‘’, exceeds maximum length of characters page 306 1303 Declaration type not allowed within structure: '' Structure cannot contain String Arrays or Structure variables: Structure definitions not allowed within other structures Local Structure declarations are not allowed page 307
Software Crestron SIMPL+ ® CATEGORY NUMBER MESSAGE TEXT PAGE Construct Errors 1600 'Function Main' cannot contain function parameters 'Function Main' cannot return a value page 326 1601 Duplicate CASE Statement Constant expected: '' page 326 1602 Switch statement contains 'default' without 'case' labels page 327 1603 #CATEGORY does not exist: '' Defaulting to Category Type, ""32"" (Miscellaneous).
Crestron SIMPL+® Software Syntax Errors (Compiler Errors 1000 to 1013) Compiler Error 1000 syntax error: '' 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. Scope refers to the level at which an Event, user-defined function or statement resides.
Software Crestron SIMPL+ ® Compiler Error 1001 syntax error: Undefined variable: '' Undefined function ‘’ The specified identifier was not declared. All variables and user-defined functions must be declared before they are used. They must be declared either globally or within the same function scope. Variables from one program are not accessible from another program. Scope refers to the level at which an Event, user-defined function or statement resides.
Crestron SIMPL+® Software structArr[1].
Software Crestron SIMPL+ ® Compiler Error 1002 syntax error: Missing '' A language element was expected and not found. The compiler expects certain language elements to appear before or after other elements. If any other language element is used, the compiler cannot understand the statement. Examples are missing parenthesis after a function call, missing semicolons after a statement and missing braces when defining functions. A token is a language element such as a keyword or operator.
Crestron SIMPL+® Software Compiler Error 1003 syntax error: Incorrect type '', expected type(s): '' Incorrect type, expected type(s): '' 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.
Software Crestron SIMPL+ ® Compiler Error 1005 syntax error: Unexpected symbol in compiler directive: '' An invalid identifier is following a compiler directive.
Crestron SIMPL+® Software Compiler Error 1007 syntax error: Missing array index: '' 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.
Software Crestron SIMPL+ ® Compiler Error 1008 syntax error: Invalid integer argument or undefined variable: '' The construct being used requires either an integer value or variable passed as a function argument.
Crestron SIMPL+® Software Compiler Error 1009 syntax error: Missing structure member: '' Structure does not contain member: '' 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 arrays are as follows: [index].
Software Crestron SIMPL+ ® Compiler Error 1010 syntax error: Symbol Name contains illegal character: ';' The compiler directive, #SYMBOL_NAME, cannot contain a semicolon as part of the symbol name.
Crestron SIMPL+® Software 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.
Software Crestron SIMPL+ ® Fatal Errors (Compiler Errors 1100 to 1101) Compiler Error 1100 fatal error: Statement outside of function scope User-defined functions, Events, and compiler directives can only be defined at a global level. Scope refers to the level at which an Event, user-defined function or statement resides. Having a global scope means that the function or variable can be called or accessed from anywhere within the program.
Crestron SIMPL+® Software Function Main() automatically // ok – Function Main gets called // at the start of the program { i = 5; str = “”; // ok // ok Call MyFunc(); // ok } Compiler Error 1101 fatal error: Abort - Error count exceeded 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.
Software Crestron SIMPL+ ® x = x + y + myFunc(1); break; // ok } } } } return (1); } INTEGER_FUNCTION AnotherFunc( INTEGER i ) { x = (1 + str); // error – cannot add an integer // and string if ( x > “abc” ) integer // error – cannot compare an // and string { if ( str ) validity // error – cannot check the // of a string { if ( str = MyFunc(1) ) // // error – cannot add strings and integers together { while ( str < “abc” ) // ok { x = (x + ); // error – incomplete expression break; } } } } retur
Crestron SIMPL+® Software Compiler Error 1201 expression error: Invalid \\x sequence 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.
Software Crestron SIMPL+ ® Declaration Errors (Compiler Errors 1300 to 1312) Compiler Error 1300 declaration error: Array size missing Array size invalid STRING, STRING_INPUT and BUFFER_INPUT variables require a valid length. A length is specified by number enclosed within brackets. Arrays for these datatypes are specified by the first set of brackets containing the number of strings and the second set of brackets containing the total length for each string.
Crestron SIMPL+® Software } FUNCTION myFunc2( STRING sArg[10], // error – size is not allowed STRING sArgArr[][] ) // error – 2-D strings not // supported { } 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. All arrays are passed to functions by reference, so specifying an index in this case is not allowed.
Software Crestron SIMPL+ ® xArr = xArr; // error – cannot copy arrays xArr = x2dArr[1]; // error – cannot copy arrays x2dArr[1] = xArr; // error – cannot copy arrays Call MyIntFunc( xArr[5], x2dArr ); // error – cannot pass index // arrays are passed // by reference } FUNCTION MyStrFunc( STRING s, STRING s[] ) { STRING sLocal[100]; // ok str = “abc”; strArr[5] = “def”; strIn = s; strOut = s; sInArr[5] = “abc”; sOutArr[5] = “abc”; // // // // // // ok ok ok ok ok ok Call MyStrFunc( str, strArr ); // o
Crestron SIMPL+® Software Compiler Error 1303 declaration error: Declaration type not allowed within structure: '' Structure cannot contain String Arrays or Structure variables: '' Structure definitions not allowed within other structures Local Structure declarations are not allowed 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.
Software Crestron SIMPL+ ® Compiler Error 1304 declaration error: Local variables must be declared at top of function All local variables within a function block must be declared before any statements are encountered. Local variables are not allowed to be declared within a block of statements such as inside an if-else or while loop.
Crestron SIMPL+® Software 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.
Software Crestron SIMPL+ ® Compiler Error 1307 declaration error: Variables must be declared before array declarations: '' I/O declarations must be declared in a specific order. All arrays of an I/O declaration type (i.e.: DIGITAL_INPUT) must be declared after any variables of the same type.
Crestron SIMPL+® Software Compiler Error 1308 declaration error: Global variable declaration cannot be declared in library file: '' I/O Declaration cannot be declared in library file: '' 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.
Software Crestron SIMPL+ ® Compiler Error 1309 declaration error: Compiler Directive must be set before all global variable declarations #DEFAULT_NONVOLATILE Compiler Directive already set #DEFAULT_VOLATILE Compiler Directive already set The compiler directives, #DEFAULT_VOLATILE and #DEFAULT_NONVOLATILE, must be used before any global variables are encountered within the SIMPL+ module. A module cannot contain more than one of these directives.
Crestron SIMPL+® Software // all global variables INTEGER x; STRING str[100]; DIGITAL_INPUT di; #DEFAULT_NONVOLATILE // error – #DEFAULT_VOLATILE has already // been set INTEGER y; #DEFAULT_NONVOLATILE // error – #DEFAULT_VOLATILE has already // been set INTEGER z; FUNCTION MyFunc() { } Compiler Error 1310 declaration error: Compiler directive cannot be in function scope Compiler directives cannot be used locally within functions.
Software Crestron SIMPL+ ® Compiler Error 1311 declaration error: Undefined Wait Label: '' Missing, invalid or already defined Wait label: '' Wait Statements can be given a label as an optional argument. This label must be a unique name and more than one wait statement cannot share the same label name. The label name can then be used in the Pause, Cancel and Resume wait functions.
Crestron SIMPL+® Software Compiler Error 1312 declaration error: Array boundary exceeded maximum size of ‘num_bytes’ bytes The maximum number of indices for an array is 65535.
Software Crestron SIMPL+ ® Compiler Error 1314 declaration error: Minimum array size is not allowed for this datatype: '' Minimum array size for this datatype has already been declared: '' Minimum array sizes are only applicable to Input and Output datatypes (i.e.: DIGITAL_INPUT, ANALOG_OUTPUT, STRING_INPUT, etc.). A variable of another datatype was found trying to define a minimum array size.
Crestron SIMPL+® Software 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. • If a complex assignment is being made, make sure that all parenthesis are matched.
Software Crestron SIMPL+ ® Compiler Error 1401 assignment error: Variable cannot be used for assignment: '' Function arguments that have been declared as ReadOnlyByRef can only have their values read; values cannot be assigned to them.
Crestron SIMPL+® Software Function Argument Errors (Compiler Errors 1500 to 1508) Compiler Error 1500 function argument error: Argument cannot be passed by reference 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; the STRING_INPUT must first be copied into a STRING variable and then passed.
Software Crestron SIMPL+ ® Call AnotherFunc( 1 ); // ok Call AnotherFunc( di ); // error – di is a DIGITAL_INPUT and // cannot be passed // by reference } Compiler Error 1501 function argument error: Argument cannot be passed by value In SIMPL+, arrays can only be passed by reference. The keyword, ByVal, cannot be used within a function’s argument list in conjunction with arrays.
Crestron SIMPL+® Software Compiler Error 1502 function argument error: Function contains incomplete number of arguments Function call contains an unmatched number of arguments 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.
Software Crestron SIMPL+ ® // or Output signal // error – ‘i’ is not // or Output signal // error – ‘5’ is not // or Output signal i = IsSignalDefined( str ); an Input digOut = IsSignalDefined( 5 ); an Input } Compiler Error 1504 function argument error: Incomplete number of format string arguments Format string contains an unmatched number of arguments Argument is missing or invalid. Format Specifier expected Argument is missing or invalid.
Crestron SIMPL+® Software // corresponding value Print( “My name is %s.
Software Crestron SIMPL+ ® Compiler Error 1506 function argument error: 0, 1 or 2 constant expected for argument 1 The function, MakeString, can contain a 0, 1, 2 as the first argument. This tells the control system to output the resulting string to a specific destination. An integer value other than 0, 1 or 2 was encountered as the first argument of MakeString(). The different destinations are as follows: 0: Computer Port, same as PRINT.
Crestron SIMPL+® Software Compiler Error 1508 function argument error: I/O variable cannot be passed to read file functions: '' Read file functions (ReadInteger, ReadString, etc.) cannot contain Input or Output variables for the function’s resulting read buffer.
Software Crestron SIMPL+ ® Construct Errors (Compiler Errors 1600 to 1608) Compiler Error 1600 construct error: 'Function Main' cannot contain function parameters 'Function Main' cannot return a value Function Main is the starting point of a SIMPL+ program. It is automatically called once when the system startup or is reset. Since this function is invoked by a method outside of the SIMPL+ module, no arguments can be included in it’s argument list and no value can be returned from it.
Crestron SIMPL+® Software { } case (2): { } // error – 2 has been previously used case (5+6): { } // error – expressions are not allowed case (x): { } // error – variables are not allowed case (“abc”): // error – strings are not allowed { } case (str): { } // error – strings are not allowed } } Compiler Error 1602 construct error: Switch statement contains 'default' without 'case' labels The Switch and CSwitch constructs must contain ‘case’ statements if the ‘default’ statement is to be used.
Software Crestron SIMPL+ ® { } } Switch ( x ) { default: { } } // error – no Case statement in Switch CSwitch ( x ) { default: // error – no Case statement in Switch { } } } Compiler Error 1603 construct error: #CATEGORY does not exist: ''. Defaulting to Category Type, ""32"" (Miscellaneous). The category number for this compiler directive was not found or was not a valid category number within the Symbol Tree Category List within SIMPL windows.
Crestron SIMPL+® Software 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.
Software Crestron SIMPL+ ® { TerminateEvent; // error – TerminateEvent is not within // an event function } } Compiler Error 1606 construct error: Statement must be contained within a loop statement The ‘break’ statement can only be used with a loop construct. Valid loop constructs are While loops, Do-While loops and For loops. The compiler encountered this function outside of one of these event functions.
Crestron SIMPL+® Software 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(). In order to use GetLastModifiedArrayIndex() for multiple input signal arrays, a separate event function will have to be defined for each array.
Software Crestron SIMPL+ ® File Errors (Compiler Errors 1700 to 1702) Compiler Error 1700 file error: End of file reached The compiler reached the end of file before all functions or statements were completed. • Make sure all functions have matching opening and closing braces. • Make sure all statement expressions have matching opening and closing parenthesis.
Crestron SIMPL+® Software Compiler Warnings (Compiler Errors 1800 to 1803) Compiler Warning 1800 compiler warning: 'Return' statement will only terminate current Wait statement's function scope 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. Wait Statements are similar to event functions (EVENT, PUSH, CHANGE, RELEASE) in that they execute in their own program thread.
Software Crestron SIMPL+ ® Scope refers to the level at which an Event, user-defined function or statement resides. Having a global scope means that the function or variable can be called or accessed from anywhere within the program. A local scope means that the variable can only be accessed from within the event or function that it resides in.
Crestron SIMPL+® Software Compiler Warning 1803 compiler warning: Possible data loss: LONG_INTEGER to INTEGER assignment 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. • • Make sure all the datatypes within an expression are of the same datatype. • Make sure the return value of a function matches the destination’s datatype.
Software Crestron SIMPL+ ® 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 336 z SIMPL+® Language Reference Guide - DOC.
Crestron SIMPL+® Software Obsolete Functions System Interfacing - Cresnet and CPU GetCIP Name: GetCIP Syntax: INTEGER GetCIP(INTEGER CIPID, INTEGER JOIN_NUMBER, INTEGER TYPE); Description: Retrieves the current state of the join number on a particular CIP ID (referred to as IP ID in SIMPL+). 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. NOTE: CIP is defined as Cresnet (over) Internet Protocol.
Software Crestron SIMPL+ ® Return Value: An Integer. For Digital values, a non-zero value indicates a logic high and a 0 value indicates a logic low. For analog values, a 16-bit number is returned corresponding to the state of the analog join.
Crestron SIMPL+® Software TYPE is one of several predefined constants: din: Digital inputs from device (symbol output list) ain: Analog inputs from device (symbol output list) dout: Digital outputs to device (symbol input list) aout: Analog outputs to device (symbol input list) 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.
Software Crestron SIMPL+ ® Parameters: SLOT_NUMBER is an INTEGER containing the slot number of the card to query. JOIN_NUMBER is an INTEGER containing the Join number to get the status. TYPE is one of several predefined constants: din: Digital inputs from device (symbol output list) ain: Analog inputs from device (symbol output list) dout: Digital outputs to device (symbol input list) aout: Analog outputs to device (symbol input list) NOTE: Access to serial signals is not supported.
Crestron SIMPL+® Software 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.
Software Crestron SIMPL+ ® Description: Sends the string specified by PACKET onto the Cresnet network. It duplicates the function of the SIMPL Windows symbol “Network Transmission (Speedkey: NTX).” This function is not used in general programming. Parameters: PACKET is a string containing the command to put on the Cresnet network. Return Value: None. Example: SendCresnetPacket(“\xFF\x03\x02”); This example will send a broadcast message to all touchpanels causing them to enter sleep mode.
Crestron SIMPL+® Software Example: SendPacketToCPU(“\x1BDFF\r”); 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 SetCIP Name: SetCIP Syntax: SetCIP(INTEGER CIPID, INTEGER JOIN_NUMBER, INTEGER TYPE); Description: Sets the state of the join number on a particular CIP ID.
Software Crestron SIMPL+ ® Version: SIMPL+ Version 2.00 only. This function is not available in Versions 1.00 or 3.00. Control System: X-Generation only SetCresnet Name: SetCresnet Syntax: SetCresnet(INTEGER CRESNET_ID, INTEGER JOIN_NUMBER, INTEGER TYPE); Description: Sets the state of the join number on a particular Cresnet Network ID. 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.
Crestron SIMPL+® Software Control System: X-Generation only SetSlot Name: SetSlot Syntax: SetSlot(INTEGER SLOT_NUMBER, INTEGER JOIN_NUMBER, INTEGER TYPE); 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. Parameters: SLOT_NUMBER is an INTEGER containing the slot number of card to set the join number.
Software Crestron SIMPL+ ® Interfacing to the CEN-OEM Interfacing to the CEN-OEM via a SIMPL+ Program Overview When using a X-Generation system to communicate over Ethernet to a CEN-OEM, the CEN-OEM definition is used from the SIMPL Windows Configuration Manager. This symbol has analog inputs, analog outputs, digital inputs, digital outputs, serial inputs, and serial outputs.
Crestron SIMPL+® Software #ANALOG_OUTPUT_JOIN Name: #ANALOG_OUTPUT_JOIN Syntax: #ANALOG_OUTPUT_JOIN Description: Changes the join number starting with the next ANALOG_OUTPUT definition to the join number specified by . Example: ANALOG_OUTPUT SIG1, SIG2, SIG3, SIG4; In this example, SIG1 references Join #1, SIG2 references Join #2, SIG3 references Join #3, and SIG4 references Join #4.
Software Crestron SIMPL+ ® #DIGITAL_INPUT_JOIN 20 DIGITAL_INPUT SIG3, SIG4; 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 #DIGITAL_OUTPUT_JOIN Name: #DIGITAL_OUTPUT_JOIN Syntax: #DIGITAL_OUTPUT_JOIN Description: Changes the join number starting with the next DIGITAL_OUTPUT definition to the join number specified by .
Crestron SIMPL+® Software Description: Changes the join number starting with the next STRING_INPUT or BUFFER_INPUT definition to the join number specified by . Example: STRING_INPUT SIG1[20], SIG2[20], SIG3[20], SIG4[20]; BUFFER_INPUT B1$[20] In this example, SIG1 references Join #1, SIG2 references Join #2, SIG3 references Join #3, SIG4 references Join #4, and B1$ references Join#5.
Software Crestron SIMPL+ ® Version: SIMPL+ Version 2.00 CEN-OEM-Specific Definitions CEN-OEM Specific Definitions Overview The CEN-OEM has one serial port which is used to communicate with a destination device. SIMPL+ defines several special purpose variables exclusively to work with the CEN-OEM to manipulate this serial port. These variables are only valid when the file is saved with an OEM extension. Each OEM variable has a specific type (DIGITAL_INPUT, etc.
Crestron SIMPL+® Software _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.
Software Crestron SIMPL+ ® Example: PUSH _OEM_CTS { PRINT(“CTS Pin has gone high!\n”); } Version: SIMPL+ Version 2.00 _OEM_DTR Name: _OEM_DTR Syntax: _OEM_DTR = ; or any expression that can use a variable as part of its contents. Description: When set to a non-zero value, raises the DTR pin high. This pin is typically used to signify “Data Terminal Ready”, which means that the CEN-OEM is telling an external piece of equipment that it is online and ready to function.
Crestron SIMPL+® Software _OEM_LONG_BREAK Name: _OEM_LONG_BREAK Syntax: _OEM_LONG_BREAK = ; 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. The variable may also be read back from to determine its current status.
Software Crestron SIMPL+ ® Example: _OEM_MAX_STRING = 1000; In this example, the maximum embedded packet size is changed to 1000 bytes. Version: SIMPL+ Version 2.00 _OEM_PACING Name: _OEM_PACING Syntax: _OEM_PACING = ; or any expression that can use a variable as part of its contents. Description: Controls the number of milliseconds the system will delay between sending bytes in a given string. This variable is treated the same as ANALOG_OUTPUT. The maximum value allowed is 255 (250ms).
Crestron SIMPL+® Software _OEM_RTS Name: _OEM_RTS Syntax: _OEM_RTS = ; 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. Writing a non-zero value to this variable sets the RTS pin high, writing 0 sets it low.
Software Crestron SIMPL+ ® Example: 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); } In this example, whenever the input buffer changes, it is scanned for the character with the hex value of 0x7F. Each time it is present, a 0x15 is transmitted. The buffer is cleared at the end of the iteration. Version: SIMPL+ Version 2.00 _OEM_STR_OUT Name: _OEM_STR_OUT Syntax: Any expression where a BUFFER_OUTPUT is legal.
Crestron SIMPL+® Software Index Symbols #ANALOG_INPUT_JOIN, ............................... 346 #ANALOG_OUTPUT_JOIN, ........................... 347 #CATEGORY, ..................................................... 33 #CRESTRON_LIBRARY, .................................. 34 #DEFAULT_NONVOLATILE, .......................... 35 #DEFAULT_VOLATILE, ................................... 36 #DEFINE_CONSTANT, ..................................... 37 #DIGITAL_INPUT_JOIN, ................................
Software Crestron SIMPL+ ® D Data Conversion Functions, ............................... 109 Date, ................................................................... 242 Day, .................................................................... 243 DECLARATION ERRORS, .............................. 304 Declarations, ......................................................... 45 Declarations Overview, ........................................ 45 Delay, ..........................................................
Crestron SIMPL+® Introduction, ........................................................... 1 IsDirectory, ......................................................... 153 IsHidden, ............................................................ 154 IsReadOnly, ........................................................ 155 IsSignalDefined, ................................................. 340 IsSystem, ............................................................ 156 IsVolume, .......................................
Software SendCresnetPacket, ............................................ 341 SendMail, ............................................................. 73 SendPacketToCPU, ............................................ 342 SetArray, ............................................................... 98 SetCIP, ................................................................ 343 SETCLOCK, ...................................................... 254 SetCresnet, ..........................................................
Crestron SIMPL+® Software Software License Agreement This License Agreement (“Agreement”) is a legal contract between you (either an individual or a single business entity) and Crestron Electronics, Inc. (“Crestron”) for software referenced in this guide, which includes computer software and, as applicable, associated media, printed materials, and “online” or electronic documentation (the “Software”).
Crestron SIMPL+® Software If You are a business or organization, You agree that upon request from Crestron or its authorized agent, You will within thirty (30) days fully document and certify that use of any and all Software at the time of the request is in conformity with Your valid licenses from Crestron of its authorized agent. Without prejudice to any other rights, Crestron may terminate this Agreement immediately upon notice if you fail to comply with the terms and conditions of this Agreement.
Crestron SIMPL+® Software Return and Warranty Policies Merchandise Returns / Repair Service 1. 2. 3. No merchandise may be returned for credit, exchange, or service without prior authorization from CRESTRON. To obtain warranty service for CRESTRON products, contact the factory and request an RMA (Return Merchandise Authorization) number. Enclose a note specifying the nature of the problem, name and phone number of contact person, RMA number, and return address.
Crestron Electronics, Inc. 15 Volvo Drive Rockleigh, NJ 07647 Tel: 888.CRESTRON Fax: 201.767.7576 www.crestron.com Language Reference Guide – DOC. 5797G 04.