Pulse

# 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. Pulse is always high, then low. If the output is already high, the high is ignored, but the low will be sent at the appropriate time.

Parameters:

TIME is the number of hundredths of a second to pulse. For example, 500 specifies a 5-second delay.

OUT is a DIGITAL_OUTPUT that is to be pulsed.

Return Value:

None.

NOTE:  (X-Gen only)   Elements of a DIGITAL_OUTPUT array cannot be used within the Pulse function

Example:

    // A pulse of 525 hundredths of a second or 5.25 seconds

    #define_constant MY_PULSE_TIME 525

    DIGITAL_OUTPUT OutputToPulse;

    PULSE(MY_PULSE_TIME, OutputToPulse);

This will execute immediately and output a pulse of 5.25 seconds to the digital output OutputToPulse.

Version:

X Generation:  SIMPL v1.20.01 and later

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
System Control
PULSE
Pulse


TerminateEvent

# 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. Otherwise, the CHANGE will exit after the WHILE loop finishes.

Version:

X Generation

SIMPL v1.20.01 and later

2-Series

SIMPL v2.01.05 and later.  Within functions, returns from the function, it does NOT terminate the event.   Existing code that relies on the event terminating should be revised.

Language Constructs & Functions
System Control
TERMINATEEVENT
TerminateEvent

ANALOG_INPUT CHANGE IF INTEGER PRINT PUSH RELEASE TERMINATEEVENT TerminateEvent WHILE


WaitForInitializationComplete

# WaitForInitializationComplete

Name:

WaitForInitializationComplete

Syntax:

SIGNED_INTEGER WaitForInitializationComplete()

Description:

Waits for the logic processor to perform its first logic solution before returning control back to the calling task.  This makes it possible to access inputs and outputs in function main() that are modified during the initial logic solution (propagating signals with logic "1" attached).  The function Main() starts to run at when the Simpl+ module is initialized.  This allows any initial values for global variables to be set before any event handlers are run.  However, since it does run at initialization time, any inputs or outputs accessed would have their initial value of 0 when accessed.  WaitForInitializationComplete will stop main() from running until the "Initialization Complete" message appears in Toolbox.  This means that any input or output whose value is modified while processing the "1" logic solution, will now have the correct values.

Parameters:

None.

Return Value:

Returns 0 if successful , \<0 if an error occurs.

Example:

DIGITAL_INPUT   diEnable;

INTEGER giProcessEnabled;

main()

{

        // initialize local variables.

        giProcessEnabled = 0;

        if ( WaitForInitializationComplete() \< 0 )

        {

            print(Error waiting for initialization complete\n");

            return;

        }

        // now we can access variables that were processed with the logic "1" solution

        while (diEnable)

        {

            giProcessEnabled = 1;

            // rest of the code for the process.

        }

}

Version:

X Generation:  Not Supported

2-Series:  SIMPL v2.05.17 and later

Language Constructs & Functions
System Control
WaitForInitializationComplete


GenerateUserError

# GenerateUserError

Name:

GenerateUserError

Syntax:

GenerateUserError(\<Static Specification String\> [, \<arg1\> ...]);

Description:

Places an error message into the control system's error log.

Parameters:

\<Static Specification String\> is a quoted string that contains text and formatting information. Format specifiers are of the form: %[[Pad]Width]specifier

See Print for a list and description of valid Format Specifiers.

Return Value:

None.

Example:

   Function MyFunc()

   {

STRING sError;

sError = "Projector";

GenerateUserError( "The %s bulb has exceeded %d hours", sError, 1000 );

   }

Version:

X Generation:  Not Supported

2-Series:  SIMPL v2.04.11 and later

Language Constructs & Functions
System Interfacing
GenerateUserError


GenerateUserNotice

# GenerateUserNotice

Name:

GenerateUserNotice

Syntax:

GenerateUserNotice(\<Static Specification String\> [, \<arg1\> ...]);

Description:

Places a notification message into the control system's error log

Parameters:

\<Static Specification String\> is a quoted string that contains text and formatting information. Format specifiers are of the form: %[[Pad]Width]specifier

See Print for a list and description of valid Format Specifiers.

Return Value:

None.

Example:

Function MyFunc()

{

STRING sNotice;

sNotice = "Projector";

GenerateUserNotice( "The %s bulb has a total of %d hours", sNotice, 500 );

}

Version:

X Generation:  Not Supported

2-Series:  SIMPL v2.04.11 and later

Language Constructs & Functions
System Interfacing
GenerateUserNotice


GenerateUserWarning

# GenerateUserWarning

Name:

GenerateUserWarning

Syntax:

GenerateUserWarning(\<Static Specification String\> [, \<arg1\> ...]);

Description:

Places a warning message into the control system's error log.

Parameters:

\<Static Specification String\> is a quoted string that contains text and formatting information. Format specifiers are of the form: %[[Pad]Width]specifier

See Print for a list and description of valid Format Specifiers.

Return Value:

None.

Example:

   Function MyFunc()

   {

STRING sWarning;

sWarning = "Projector";

GenerateUserWarning( "The %s bulb has a total of %d hours", sWarning, 800 );

   }

Version:

X Generation:  Not Supported

2-Series:  SIMPL v2.04.11 and later

Language Constructs & Functions
System Interfacing
GenerateUserWarning


GetCIP

# 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 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.

Parameters:

CIPID is an INTEGER containing the ID of the CIP device to query.

JOIN_NUMBER is an INTEGER containing the Join number to get the status. For touchpanels, the join number is identical to the press/feedback number. For other devices, contact Crestron customer service.

TYPE is one of several predefined constants:

din:        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. For analog values, a 16-bit number is returned corresponding to the state of the analog join.

Example:

Assuming a relay card has been defined in Slot 1 and Relay A2 has a signal name tied to it, and a CEN-IO has been defined at CIP ID 03 and cue i1 has a signal tied to it, this SIMPL+ statement will connect the two:

    SetSlot(1,2,dout) = GetCIP(0x03,18,din);

NOTE:  In the above example statement, the join number representing cue i1 on the CEN-IO is 18.

NOTE:  This is not a permanent connection; it will only set the state when this statement is executed.

Version:

X Generation:  SIMPL v1.50.06 and later

2-Series:  Not Supported.

Language Constructs & Functions
System Interfacing
GetCIPDev
GetCIP


GetCresnet

# GetCresnet

Name:

GetCresnet

Syntax:

    INTEGER GetCresnet(INTEGER CRESNET_ID, INTEGER JOIN_NUMBER,

                       INTEGER TYPE);

Description:

Retrieves the current state of the join number on a particular Cresnet Network ID. Note that the device must be defined in SIMPL and the join number to use must have a signal tied to it for this function to work.

Parameters:

CRESNET_ID is an INTEGER containing the ID of the Cresnet Network device to query.

JOIN_NUMBER is an INTEGER containing the Join number to get the status. For touchpanels, the join number is identical to the press/feedback number. For other devices, contact Crestron customer service.

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. For analog values, a 16-bit number is returned corresponding to the state of the analog join.

Example:

Assuming a relay card has been defined in Slot 1 and Relay A2 has a signal name tied to it, and a touch screen has been defined at Cresnet ID 07, and press 42 has a signal name tied to it, this SIMPL+ statement will connect the two:

    SetSlot(1,2,dout) = GetCresnet(0x07,42,din);

NOTE:  This is not a permanent connection; it will only set the state when this statement is executed.

Version:

X Generation:  SIMPL v1.50.06 and later

2-Series:  Not Supported.

Language Constructs & Functions
System Interfacing
GetCresnetDev
GetCresnet


GetModelNumber

# GetModelNumber

Name:

GetModelNumber

 Syntax:

    GetModelNumber

Description:

Returns the product name.

Example:

FUNCTION DisplayProduct()

{

     PRINT( “This is a %s”, GetModelNumber() );

}

Version:

X Generation:  Not Supported

2-Series:  Not Supported

3-Series: v \<\> and above

Language Constructs & Functions
System Interfacing
GetModelNumber

DisplayProduct FUNCTION GetModelNumber PRINT


GetProgramNumber

# GetProgramNumber

Name:

GetProgramNumber

 Syntax:

    GetProgramNumber

Description:

Returns which program the module is executing from.

Example:

FUNCTION DisplayProgramNumber()

{

     PRINT( “This is the %d”, GetProgramNumber() );

}

Version:

X Generation:  Not Supported

2-Series:  Not Supported

3-Series: v \<\> and above

Language Constructs & Functions
System Interfacing
GetProgramNumber

DisplayProgramNumber FUNCTION GetProgramNumber PRINT


GetSeries

# GetSeries

Name:

GetSeries

 Syntax:

    GetSeries

Description:

Returns the product series.  For example, the 3-series architecture will return 3 and the 2-series architecture will return 2.

Example:

FUNCTION GetMySeries()

{

     SWITCH( GetSeries() )

     {

          CASE (2):

               PRINT( “2-Series” );

          CASE (3):

               PRINT( “3-series” );

     }

}

Version:

X Generation:  Not Supported

2-Series:  Not Supported

3-Series: v \<\> and above

Language Constructs & Functions
System Interfacing
GetSeries

CASE FUNCTION GetMySeries GetSeries PRINT SWITCH


GetSlot

# GetSlot

Name:

GetSlot

Syntax:

    INTEGER GetSlot(INTEGER SLOT_NUMBER, INTEGER JOIN_NUMBER,

                    INTEGER TYPE);

Description:

Retrieves the current state of the join number on a particular card. Note that the device must be defined in SIMPL 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 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.

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.

Example:

Assuming a relay card has been defined in Slot 1 and Relay A2 has a signal name tied to it, and a CNXIO-16 has been defined in Slot 2 and cue i1 has a signal tied to it, this SIMPL+ statement will connect the two:

    SetSlot(1,2,dout) = GetSlot(2,1,din);

NOTE:  This is not a permanent connection; it will only set the state when this statement is executed.

Version:

X Generation:  SIMPL v1.50.06 and later

2-Series:  Not Supported.

Language Constructs & Functions
System Interfacing
GetSlotDev
GetSlot


GetSymbolInstanceName

# GetSymbolInstanceName

Name:

GetSymbolInstanceName

Syntax:

    STRING GetSymbolInstanceName();

Description:

Returns the symbol "S-" and the number where this SIMPL+ symbol is located within the SIMPL program.

Parameters:

None.

Return Value:

A string indicating the location of the SIMPL+ symbol in SIMPL. For example, if the SIMPL+ symbol is at S-5.2 in the SIMPL program, the returned string will be "S-5.2".  If that same symbol resides in a macro that is located at S-6 in the SIMPL program, the returned string will be "S-6:S-5.2"

Example:

STRING InstanceName[20];

InstanceName=GetSymbolInstanceName();

Print("Instance Name is: %s", InstanceName);

Assuming the SIMPL+ symbol is located at S-5.2 in the SIMPL Program, the Instance Name is: S-5.2

Version:

SIMPL+ Version 3.03.00 or later

CUZ 3.154 or later

Language Constructs & Functions
System Interfacing
GetSymbolInstanceName


GetSymbolReferenceName

# GetSymbolReferenceName

Name:

GetSymbolReferenceName

Syntax:

    STRING GetSymbolReferenceName();

Description:

Returns the string entered into the [Reference Name] SIMPL+ symbol in SIMPL corresponding to the SIMPL+ module.

NOTE:  CIP is defined as Cresnet (over) Internet Protocol.

Parameters:

None.

Return Value:

Returns the string entered into the Reference Name field of a SIMPL+ symbol in SIMPL. If no Reference Name has been entered, an empty string is returned.

Example:

STRING RefName[20];

Function Main()

{

WaitForInitializationComplete();

RefName=GetSymbolReferenceName();

Print("Reference Name is: %s.\n", RefName);

}

Assuming the Reference Name Parameter is, for example, Kitchen Light Control, "Reference Name is: Kitchen Light Control" is the returned string.

Version:

SIMPL+ Version 3.03.00 or later

CUZ 3.154 or later

Language Constructs & Functions
System Interfacing
GetSymbolReferenceName

Cresnet GetSymbolReferenceName Main Print STRING WaitForInitializationComplete


IsSignalDefined

# IsSignalDefined

Name:

IsSignalDefined

Syntax:

    INTEGER IsSignalDefined \<input/output signal\>;

Description:

Retrieves the current SIMPL signal number associated with a particular input or output. This is generally used to determine if a particular input or output on a gate is being used, and generally used with arrayed inputs or outputs. This can be used to build a gate of a predetermined maximum size, and allow the user to add and subtract signals on the input or output of the gate (i.e., the program would be written to iterate through a DIGITAL_INPUT array until IsSignalDefined returns a 0).

Parameters:

Legal output and input signal types are ANALOG_INPUT, ANALOG_OUTPUT, BUFFER_INPUT, DIGITAL_INPUT, DIGITAL_OUTPUT, STRING_INPUT, STRING_OUTPUT.

Return Value:

The particular input or output is tied to an integer giving the signal number. If a signal has been tied to that input or output of the gate, a non-zero value will be returned. If the input/output  is tied to 0 in the SIMPL program or is not defined, then 0 will be returned. If a digital input/output in the SIMPL program is tied to 1, then 1 is returned.  If an analog or serial input/output in the SIMPL program is tied to 1, then 0 is returned.

Example:

    DIGITAL_INPUT INS[20];

    INTEGER NumInputs;

    FUNCTION MAIN()

    {

       FOR(NumInputs = 20 to 1 Step -1)

       IF(IsSignalDefined(INS[NumInputs]))

          Break;

    }

This example computes how many inputs are used on the gate. It should be noted that it is useful to count backwards from the end of the gate. If the user tied five signals, a 0, and then five more signals, this would yield the correct result that the 11th input was the last one used.

Version:

X Generation:  SIMPL v1.50.06

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
System Interfacing
IsSignalDefined


MakeProgramFilename

# MakeProgramFilename

Name:

MakeProgramFilename

Syntax:

    MakeProgramFilename

Description:

Takes in the filename (which would be the program path or anything that the user wants) and prepends  that with the Program ID Tag. The Program ID Tag is specified in the Header of the SIMPL program.

For example: if running in program and the user passes in  "\Simpl\App01\MyProgram" as the filename and the Program ID Tag is set to "HVAC" then this function would return "\Simpl\App01\HVAC_MyProgram".

NOTE:  In the 2 Series, Program ID Tags are not used, so the same name is returned.

Example:

FUNCTION MyFunc()

{

     // SIMPL Program ID Tag is set to "HVAC

     PRINT( “ProgramFileName = %s”, MakeProgramFilename("\\Simpl\\App01\\MyProgram") );

     // prints: "\Simpl\App01\HVAC_MyProgram"

}

Version:

X Generation:  Not Supported

2-Series:  Not Supported

3-Series: v \<\> and above

Language Constructs & Functions
System Interfacing
MakeProgramFilename

FUNCTION MakeProgramFilename MyFunc PRINT


System Interfacing Overview

# System Interfacing Overview

These functions control the way the SIMPL+ program communicates with Cresnet network devices and the CPU.

|  |  |
|----|----|
| Function | Description |
| [GetCIP] | Retrieves the current state of the join number on a particular CIP ID. |
| [GetCresnet] | Retrieves the current state of the join number on a particular Cresnet Network ID. |
| [GetModelNumber] | Returns the product name. |
| [GetSeries] | Returns the product series.  For example, the 3-series architecture will return 3 and the 2-series architecture will return 2. |
| [GetSlot] | Retrieves the current state of the join number on a particular card. |
| [GetSymbolInstanceName] | Returns the symbol "S-" and the number where this SIMPL+ symbol is located within the SIMPL program. |
| [GetSymbolReferenceName] | Returns the string entered into the [Reference Name] SIMPL+ symbol in SIMPL corresponding to the SIMPL+ module. |
| [IsSignalDefined] | Retrieves the current SIMPL signal number associated with a particular input or output. |
| [MakeProgramFilename] | Takes in the filename (which would be the program path or anything that the user wants) and prepends  that with the Program ID Tag. The Program ID Tag is specified in the Header of the SIMPL program. |
| [SendCresnetPacket] | Sends the string specified by PACKET onto the Cresnet network. |
| [SendPacketToCPU] | Sends the string specified by PACKET to the Cresnet CPU. |
| [SetCIP] | Sets the state of the join number on a particular CIP ID. |
| [SetCresnet] | Sets the state of the join number on a particular Cresnet Network ID. |
| [SetSlot] | Sets the state of the join number on a particular card slot. |

  [GetCIP]: GetCIPDev.md
  [GetCresnet]: GetCresnetDev.md
  [GetModelNumber]: GetModelNumber.md
  [GetSeries]: GetSeries.md
  [GetSlot]: GetSlotDev.md
  [GetSymbolInstanceName]: GetSymbolInstanceName.md
  [GetSymbolReferenceName]: GetSymbolReferenceName.md
  [IsSignalDefined]: IsSignalDefined.md
  [MakeProgramFilename]: MakeProgramFilename.md
  [SendCresnetPacket]: SendCresnetPacket.md
  [SendPacketToCPU]: SendPacketToCPU.md
  [SetCIP]: SetCIPDev.md
  [SetCresnet]: SetCresnetDev.md
  [SetSlot]: SetSlotDev.md

Language Constructs & Functions
System Interfacing
Overview
System Interfacing Overview

GetCIP GetCresnet GetModelNumber GetSeries GetSlot GetSymbolInstanceName GetSymbolReferenceName Interfacing IsSignalDefined MakeProgramFilename Overview SendCresnetPacket System

GetCIP GetCresnet GetModelNumber GetSeries GetSlot GetSymbolInstanceName GetSymbolReferenceName IsSignalDefined MakeProgramFilename SendCresnetPacket


SendCresnetPacket

# SendCresnetPacket

Name:

SendCresnetPacket

Syntax:

    SendCresnetPacket(STRING PACKET);

Description:

Sends the string specified by PACKET onto the Cresnet network. It duplicates the function of the SIMPL 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. The preferable way to do this is use the SLEEP input of the BROADCAST symbol in SIMPL.

Version:

X Generation:  SIMPL v1.50.06

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
System Interfacing
SendCresnetPacket


SendPacketToCPU

# SendPacketToCPU

Name:

SendPacketToCPU

Syntax:

    SendPacketToCPU(STRING PACKET);

Description:

Sends the string specified by PACKET to the Cresnet CPU. This is normally used for sending ESC style commands to the CPU for control. This function duplicates the functionality of the SIMPL symbol "Send Message to CPU (Speedkey:  TMSG)." This function is not used in general programming.

Parameters:

PACKET is a string containing the command to send to the CPU.

Return Value:

None.

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:

X Generation:  SIMPL v1.50.06

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
System Interfacing
SendPacketToCPU


SetCIP

# 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. Note that the device must be defined in SIMPL and the join number to use must have a signal tied to it for this function to work.

Parameters:

CIPID is an INTEGER containing the ID of the CIP device to set the join number.

JOIN_NUMBER is an INTEGER containing the Join number to set.

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)

Return Value:

None.

Example:

Assuming a CEN-IO has been defined at CIP ID 03 and Relay1 has a signal named tied to it, and a touch screen has been defined at Cresnet ID 07, and press 42 has a signal name tied to it, this SIMPL+ statement will connect the two:

    SetCIP(0x03,1,dout) = GetCresnet(0x07,42,din);

NOTE:  This is not a permanent connection; it will only set the state when this statement is executed.

Version:

X Generation:  SIMPL v1.50.06 and later

2-Series:  Not Supported.

Language Constructs & Functions
System Interfacing
SetCIPDev
SetCIP


SetCresnet

# 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 and the join number to use must have a signal tied to it for this function to work.

Parameters:

CRESNET_ID is an INTEGER containing the ID of the Cresnet Network device to set the join number.

JOIN_NUMBER is an INTEGER containing the Join number to set.

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)

Return Value:

None.

Example:

Assuming a touch screen has been defined at Cresnet ID 07, and press 42 and feedback 69 have signal names tied to them, this SIMPL+ statement will connect the two:

    SetCresnet(0x07,69,dout) = GetCresnet(0x07,42,din);

NOTE:  This is not a permanent connection; it will only set the state when this statement is executed.

Version:

X Generation:  SIMPL v1.50.06 and later

2-Series:  Not Supported.

Language Constructs & Functions
System Interfacing
SetCresnetDev
SetCresnet


SetSlot

# 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 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.

JOIN_NUMBER is an INTEGER containing the Join number to set.

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)

Return Value:

None.

Example:

Assuming a relay card has been defined in Slot 1 and Relay A2 has a signal name tied to it, and a touch screen has been defined at Cresnet ID 07, and press 42 has a signal name tied to it, this SIMPL+ statement will connect the two:

    SetSlot(1,2,dout) = GetCresnet(0x07,42,din);

NOTE:  This is not a permanent connection; it will only set the state when this statement is executed.

Version:

X Generation:  SIMPL v1.50.06 and later

2-Series:  Not Supported.

Language Constructs & Functions
System Interfacing
SetSlotDev
SetSlot


Clock Driver

# Clock Driver

The Clock Driver symbol makes the internal clock of the control system available to other symbols. In addition, its presence alone will synchronize the internal clocks on touchpanels with the internal clock of the control system. (The output signal and parameter need not be defined.)

The \<dst\> parameter specifies the format for Daylight Savings Time, as shown in the following table:

|  |  |
|----|----|
| \<dst\> | Format |
| 0 | No DST |
| 1 | U.S. (first Sunday in April to the last Sunday in October) |
| 2 | Southern Hemisphere (first Sunday in October to the 3rd Sunday in March) |
| 3 |  Same as 2 (for compatibility with MSX) |
| 4 (2-Series only) | European Union Standard (last Sunday in March to the last Sunday in October) |
| 5 (2-Series only) |  Egypt (last Friday in April to the last Thursday in September) |

Entering Daylight Savings Time drives the time back one hour beginning at 2:00 A.M. Leaving Daylight Savings Time moves the time ahead one hour beginning at 2:00 A.M.

Language Constructs & Functions
Time & Date Functions
Clock Driver


Date

# Date

Name:

Date

Syntax:

    STRING Date(INTEGER FORMAT);

Description:

Returns a string corresponding to the current date with the specified FORMAT.

Parameters:

FORMAT is an integer describing the way to format the date for the return. Valid formats are 1 through 4.

FORMAT 1 returns a string in the form MM/DD/YYYY

FORMAT 2 returns a string in the form DD/MM/YYYY

FORMAT 3 returns a string in the form YYYY/MM/DD

FORMAT 4 returns a string in the form MM/DD/YY

In format 4, the year 2000 is shown as 00. Digits 58 - 99 are treated as 1958-1999 and 00-57 are treated as 2000 through 2057.

Return Value:

A STRING corresponding to the current date.

Example:

    STRING TheDate$[100];

    FUNCTION MAIN()

    {

      TheDate$=DATE(1);

      PRINT("The date is %s\n", TheDate$);

    }

This would print a string such as "The date is 03/25/1999".

Version:

X Generation:  SIMPL v1.20.01 and later

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
Time & Date Functions
DATE
Date

DATE Date FUNCTION INTEGER MAIN PRINT STRING


Day

# 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:

X Generation:  SIMPL v1.20.01 and later

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
Time & Date Functions
DAY
Day


FileDate

# 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 (see [FindFirst] for description)

FORMAT is an integer describing the way to format the date for the return. Valid formats are 1 through 4.

FORMAT 1 returns a string in the form MM/DD/YYYY

FORMAT 2 returns a string in the form DD/MM/YYYY

FORMAT 3 returns a string in the form YYYY/MM/DD

FORMAT 4 returns a string in the form MM/DD/YY

In format 4, the year 2000 is shown as 00. Digits 58 - 99 are treated as 1958-1999 and 00-57 are treated as 2000 through 2057.

Return Value:

A STRING corresponding to the current date.

Example:

(see [File Functions Overview])

    STRING TheDate$[100];

    FILE_INFO FileInfo;

    SIGNED_INTEGER Found;

StartFileOperations();

    Found = FindFirst("\*.dat", FileInfo );

    WHILE (Found = 0)

    {

      TheDate$ = FileDate(FileInfo, 1);

      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".

Version:

X Generation:  Not Supported

2-Series:  SIMPL Version 2.02.10 and later

  [FindFirst]: ../File_Functions/File_First.md
  [File Functions Overview]: ../File_Functions/File_Functions_Overview.md

Language Constructs & Functions
Time & Date Functions
FILEDATE
FileDate

EndFileOperations File FileDate FindClose FindFirst FindNext Functions IF INTEGER Overview PRINT SIGNED_INTEGER STRING StartFileOperations WHILE


FileDay

# 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 (see [FindFirst] 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.

Example:

(see [File Functions Overview])

    STRING TheDay$[100];

    FILE_INFO FileInfo;

    SIGNED_INTEGER Found;

StartFileOperations();

    Found = FindFirst("\*.dat", FileInfo );

    WHILE (Found = 0)

    {

      TheDay$ = FileDay(FileInfo);

      PRINT ( "Day of file = %s\n", TheDay$ );

      Found = FindNext(FileInfo);

    }

    IF ( FindClose() \< 0 )

      PRINT ( "Error in closing find operation\n" );

EndFileOperations();

An example output of this would be "Day of file = Monday".

Version:

X Generation:  Not Supported

2-Series:  SIMPL Version 2.02.10 and later

  [FindFirst]: ../File_Functions/File_First.md
  [File Functions Overview]: ../File_Functions/File_Functions_Overview.md

Language Constructs & Functions
Time & Date Functions
FILEDAY
FileDay

EndFileOperations File FileDay FindClose FindFirst FindNext Functions IF Overview PRINT SIGNED_INTEGER STRING StartFileOperations WHILE


FileGetDateNum

# 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 (see [FindFirst] for description).

Return Value:

The day of the month as an integer from 1 to 31.

Example:

(see [File Functions Overview])

    INTEGER NumDateOfMonth;

    [FILE_INFO] FileInfo;

    INTEGER Found;

StartFileOperations();

    Found = FindFirst("\*.dat", FileInfo );

    WHILE (Found = 0)

    {

      NumDateOfMonth = FileGetDateNum(FileInfo);

      PRINT ( "Day of the month of file = %d\n", NumDateOfMonth);

      Found = FindNext(FileInfo);

    }

    IF ( FindClose() \< 0 )

      PRINT ( "Error in closing find operation\n" );

EndFileOperations();

An example output of this would be "Day of the month of file = 25".

Version:

X Generation:  Not Supported

2-Series:  SIMPL Version 2.02.10 and later

  [FindFirst]: ../File_Functions/File_First.md
  [File Functions Overview]: ../File_Functions/File_Functions_Overview.md
  [FILE_INFO]: ../File_Functions/File_INFO_Structure.md

Language Constructs & Functions
Time & Date Functions
FILEGETDATENUM
FileGetDateNum

EndFileOperations FILE_INFO File FileGetDateNum FindClose FindFirst FindNext Functions IF INTEGER Overview PRINT SIGNED_INTEGER StartFileOperations WHILE

FindFirst
File Functions Overview
FILE_INFO


FileGetDayOfWeekNum

# 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 (see [FindFirst] for description).

Return Value:

The day of the week as an integer from 0 to 6; 0 represents Sunday to 6 representing Saturday.

Example:

(see [File Functions Overview])

   INTEGER NumDayOfWeek;

    [FILE_INFO] FileInfo;

    SIGNED_INTEGER Found;

StartFileOperations();

    Found = FindFirst("\*.dat", FileInfo );

    WHILE (Found = 0)

    {

      NumDayOfWeek = FileGetDayOfWeekNum(FileInfo);

      PRINT ( "Day of week of file = %d\n", NumDayOfWeek);

      Found = FindNext(FileInfo);

    }

    IF ( FindClose() \< 0 )

      PRINT ( "Error in closing find operation\n" );

EndFileOperations();

An example output of this would be "Day of week of file = 4".

Version:

X Generation:  Not Supported

2-Series:  SIMPL Version 2.02.10 and later

  [FindFirst]: ../File_Functions/File_First.md
  [File Functions Overview]: ../File_Functions/File_Functions_Overview.md
  [FILE_INFO]: ../File_Functions/File_INFO_Structure.md

Language Constructs & Functions
Time & Date Functions
FILEGETDAYOFWEEKNUM
FileGetDayOfWeekNum

EndFileOperations FILE_INFO File FileGetDayOfWeekNum FindClose FindFirst FindNext Functions IF INTEGER Overview PRINT SIGNED_INTEGER StartFileOperations WHILE


FileGetHourNum

# 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 (see [FindFirst] for description).

Return Value:

The number of hours from 0 to 23 (24-hour time format).

Example:

(see [File Functions Overview])

    INTEGER NumHours;

    [FILE_INFO] FileInfo;

    SIGNED_INTEGER Found;

StartFileOperations();

    Found = FindFirst("\*.dat", FileInfo );

    WHILE (Found = 0)

    {

      NumHours = FileGetHourNum(FileInfo);

      PRINT ( "Hours of file time = %d\n", NumHours);

      Found = FindNext(FileInfo);

    }

    IF ( FindClose() \< 0 )

       PRINT ( "Error in closing find operation\n" );

EndFileOperations();

An example output of this would be "Hours of file time = 22".

Version:

X Generation:  Not Supported

2-Series:  SIMPL Version 2.02.10 and later

  [FindFirst]: ../File_Functions/File_First.md
  [File Functions Overview]: ../File_Functions/File_Functions_Overview.md
  [FILE_INFO]: ../File_Functions/File_INFO_Structure.md

Language Constructs & Functions
Time & Date Functions
FILEGETHOURNUM
FileGetHourNum

EndFileOperations FILE_INFO File FileGetHourNum FindClose FindFirst FindNext Functions IF INTEGER Overview PRINT SIGNED_INTEGER StartFileOperations WHILE


FileGetMinutesNum

# FileGetMinutesNum

Name:

2-series only

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 (see [FindFirst] for description).

Return Value:

The number of minutes from 0 to 59.

Example:

(see [File Functions Overview])

   INTEGER NumMinutes;

    [FILE_INFO] FileInfo;

    SIGNED_INTEGER Found;

StartFileOperations();

    Found = FindFirst("\*.dat", FileInfo );

    WHILE (Found = 0)

    {

      NumMinutes = FileGetMinutesNum(FileInfo);

      PRINT ( "Minutes of file time = %d\n", NumMinutes);

      Found = FindNext(FileInfo);

    }

    IF ( FindClose() \< 0 )

       PRINT ( "Error in closing find operation\n" );

EndFileOperations();

An example output of this would be "Minutes of file time = 33".

Version:

X Generation:  Not Supported

2-Series:  SIMPL Version 2.02.10 and later

  [FindFirst]: ../File_Functions/File_First.md
  [File Functions Overview]: ../File_Functions/File_Functions_Overview.md
  [FILE_INFO]: ../File_Functions/File_INFO_Structure.md

Language Constructs & Functions
Time & Date Functions
FILEGETMINUTESNUM
FileGetMinutesNum

EndFileOperations FILE_INFO File FileGetMinutesNum FindClose FindFirst FindNext Functions IF INTEGER Overview PRINT SIGNED_INTEGER StartFileOperations WHILE


FileGetMonthNum

# 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 (see [FindFirst] ).

Return Value:

The month of the year as an integer from 1 to 12.

Example:

(see [File Functions Overview])

    INTEGER NumMonth;

    [FILE_INFO] FileInfo;

    SIGNED_INTEGER Found;

StartFileOperations();

    Found = FindFirst("\*.dat", FileInfo );

    WHILE (Found = 0)

    {

      NumMonth = FileGetMonthNum(FileInfo);

      PRINT ( "Month of file date = %d\n", NumMonth);

      Found = FindNext(FileInfo);

    }

    IF ( FindClose() \< 0 )

       PRINT ( "Error in closing find operation\n" );

EndFileOperations();

An example output of this would be "Month of file date = 9".

Version:

X Generation:  Not Supported

2-Series:  SIMPL Version 2.02.10 and later

  [FindFirst]: ../File_Functions/File_First.md
  [File Functions Overview]: ../File_Functions/File_Functions_Overview.md
  [FILE_INFO]: ../File_Functions/File_INFO_Structure.md

Language Constructs & Functions
Time & Date Functions
FILEGETMONTHNUM
FileGetMonthNum

EndFileOperations FILE_INFO File FileGetMonthNum FindClose FindFirst FindNext Functions IF INTEGER Overview PRINT SIGNED_INTEGER StartFileOperations WHILE


FileGetSecondsNum

# 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 (see [FindFirst] for description).

Return Value:

The number of seconds from 0 to 59.

Example:

(see [File Functions Overview])

   INTEGER NumSeconds;

    [FILE_INFO] FileInfo;

    SIGNED_INTEGER Found;

StartFileOperations();

    Found = FindFirst("\*.dat", FileInfo );

    WHILE (Found = 0)

    {

      NumSeconds = FileGetSecondsNum(FileInfo);

      PRINT ( "Seconds of file time = %d\n", NumSeconds);

      Found = FindNext(FileInfo);

    }

    IF ( FindClose() \< 0 )

       PRINT ( "Error in closing find operation\n" );

EndFileOperations();

An example output of this would be "Seconds of file time = 25".

Version:

X Generation:  Not Supported

2-Series:  SIMPL Version 2.02.10 and later

  [FindFirst]: ../File_Functions/File_First.md
  [File Functions Overview]: ../File_Functions/File_Functions_Overview.md
  [FILE_INFO]: ../File_Functions/File_INFO_Structure.md

Language Constructs & Functions
Time & Date Functions
FILEGETSECONDSNUM
FileGetSecondsNum

EndFileOperations FILE_INFO File FileGetSecondsNum FindClose FindFirst FindNext Functions IF INTEGER Overview PRINT SIGNED_INTEGER StartFileOperations WHILE


FileGetYearNum

# 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 (see [FindFirst] for description).

Return Value:

The year as an integer. The full year is specified. For example, the year 2003 will return the integer 2003.

Example:

(see [File Functions Overview])

   INTEGER NumYear;

    [FILE_INFO] FileInfo;

    SIGNED_INTEGER Found;

StartFileOperations();

    Found = FindFirst("\*.dat", FileInfo );

    WHILE (Found = 0)

    {

      NumYear = FileGetYearNum(FileInfo);

      PRINT ( "Year of file date = %d\n", NumYear);

      Found = FindNext(FileInfo);

    }

    IF ( FindClose() \< 0 )

       PRINT ( "Error in closing find operation\n" );

EndFileOperations();

An example output from this would be "Year of file date = 1999".

Version:

X Generation:  Not Supported

2-Series:  SIMPL Version 2.02.10 and later

  [FindFirst]: ../File_Functions/File_First.md
  [File Functions Overview]: ../File_Functions/File_Functions_Overview.md
  [FILE_INFO]: ../File_Functions/File_INFO_Structure.md

Language Constructs & Functions
Time & Date Functions
FILEGETYEARNUM
FileGetYearNum

EndFileOperations FILE_INFO File FileGetYearNum FindClose FindFirst FindNext Functions IF INTEGER Overview PRINT SIGNED_INTEGER StartFileOperations WHILE


FileMonth

# 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 (see [FindFirst] 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.

Example:

(see [File Functions Overview])

    STRING TheMonth$[100];

    [FILE_INFO] FileInfo;

    SIGNED_INTEGER Found;

StartFileOperations();

    Found = FindFirst("\*.dat", FileInfo );

    WHILE (Found = 0)

    {

      TheMonth$ = FileMONTH(FileInfo);

      PRINT ( "Month of file date = %s\n", TheMonth$);

      Found = FindNext(FileInfo);

    }

    IF ( FindClose() \< 0 )

       PRINT ( "Error in closing find operation\n" );

EndFileOperations();

An example output of this would be "Month of file date = September".

Version:

X Generation:  Not Supported

2-Series:  SIMPL Version 2.02.10 and later

  [FindFirst]: ../File_Functions/File_First.md
  [File Functions Overview]: ../File_Functions/File_Functions_Overview.md
  [FILE_INFO]: ../File_Functions/File_INFO_Structure.md

Language Constructs & Functions
Time & Date Functions
FILEMONTH
FileMonth

EndFileOperations FILE_INFO File FileMONTH FileMonth FindClose FindFirst FindNext Functions IF Overview PRINT SIGNED_INTEGER STRING StartFileOperations WHILE


FileTime

# 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 (see [FindFirst] 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 0s.

Example:

(see [File Functions Overview])

   STRING TheTime$[100];

    [FILE_INFO] FileInfo;

    SIGNED_INTEGER Found;

StartFileOperations();

    Found = FindFirst("\*.dat", FileInfo );

    WHILE (Found = 0)

    {

      TheTime$=TIME();

      PRINT ( "File time = %s\n", TheTime$);

      Found = FindNext(FileInfo);

    }

    IF ( FindClose() \< 0 )

       PRINT ( "Error in closing find operation\n" );

EndFileOperations();

An example output from this would be "File time = 14:25:32".

Version:

X Generation:  Not Supported

2-Series:  SIMPL Version 2.02.10 and later

  [FindFirst]: ../File_Functions/File_First.md
  [File Functions Overview]: ../File_Functions/File_Functions_Overview.md
  [FILE_INFO]: ../File_Functions/File_INFO_Structure.md

Language Constructs & Functions
Time & Date Functions
FILETIME
FileTime

EndFileOperations FILE_INFO File FileTime FindClose FindFirst FindNext Functions IF Overview PRINT SIGNED_INTEGER STRING StartFileOperations TIME WHILE


GETDATENUM

# 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:

X Generation:  SIMPL v1.20.01 and later

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
Time & Date Functions
GETDATENUM

FUNCTION GETDATENUM GetDateNum INTEGER MAIN PRINT


GETDAYOFWEEKNUM

# 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.

Example:

    INTEGER NumDayOfWeek;

    FUNCTION MAIN()

    {

      NumDayOfWeek = GetDayOfWeekNum();

      PRINT("The current day of the week is %d\n", NumDayOfWeek);

    }

An example output of this would be "The current day of the week is 4".

Version:

X Generation:  SIMPL v1.20.01 and later

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
Time & Date Functions
GETDAYOFWEEKNUM

FUNCTION GETDAYOFWEEKNUM GetDayOfWeekNum INTEGER MAIN PRINT


GetDst

# GetDst

Name:

GetDst

Syntax:

    INTEGER GetDst()

Description:

Gets the current DST (Daylight Savings Time) state. In order to set the DST state, a [Clock Driver] symbol with a DST value is needed in the SIMPL Program.

Parameters:

None

Return Value:

An INTEGER containing the DST status:

0: Unknown

1: In DST

2: Not in DST

Example:

    INTEGER DstMode;

    DstMode = GetDst();

    If(DstMode = 0)

       Print("DST Mode is currently unknown.\n");

    Else if (DstMode = 1)

       Print("DST Mode is currently On (In DST).\n");

    Else if (DstMode = 2)

       Print("DST Mode is currently Off (Not in DST).\n");

This example will return one of the following strings based on the DST status:

DST Mode is currently Unknown.

DST Mode is currently On (In DST).

DST Mode is currently Off (Not in DST).

Version:

SIMPL+ Version 3.03.00 or later

CUZ 3.154 or later required

  [Clock Driver]: javascript:void(0);

Language Constructs & Functions
Time & Date Functions
GETDST
GetDst


GetGmtOffset

# GetGmtOffset

Name:

GetGmtOffset

Syntax:

    SIGNED_INTEGER GetGmtOffset();

Description:

Retrieves the GMT Offset that was configured via the consol command GMTOFFSET or through the SetGmtOffset() function.

Parameters:

None.

Return Value:

A SIGNED_INTEGER containing the offset in minutes.

Example:

    SIGNED_INTEGER SystemGmtOffset;

    SystemGmtOffset = GetGmtOffset();

    Print("GmtOffset = %d minutes\n", SystemGmtOffset);

In this example the GmtOffset would be the value of %d expressed as a positive or negative number.

Version:

SIMPL+ Version 3.03.00 or later

CUZ 3.154 or later required

Language Constructs & Functions
Time & Date Functions
GETGMTOFFSET
GetGmtOffset

GetGmtOffset Print SIGNED_INTEGER SetGmtOffset


GETHOURNUM

# 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:

X Generation:  SIMPL v1.20.01 and later

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
Time & Date Functions
GETHOURNUM

FUNCTION GETHOURNUM GetHourNum INTEGER MAIN PRINT


GETHSECONDS

# 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.

Example:

    INTEGER OldTime, NewTime, Loop;

    Loop=0;

    OldTime=GETHSECONDS();

    WHILE(Loop \< 10000)

    {

      Loop = Loop + 1

    }

    NewTime=GETHSECONDS();

    PRINT ("Elapsed Time is %d hundredths of a second.\n",

           Newtime-OldTime);

The output of this code would be "Elapsed Time is 400 hundredths of a second."

NOTE: This is bad programming as it ties up the CPU.

Version:

X Generation:  SIMPL v1.20.01 and later

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
Time & Date Functions
GETHSECONDS

GETHSECONDS GetHSeconds INTEGER PRINT WHILE


GETMINUTESNUM

# 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:

X Generation:  SIMPL v1.20.01 and later

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
Time & Date Functions
GETMINUTESNUM

FUNCTION GETMINUTESNUM GetMinutesNum INTEGER MAIN PRINT


GETMONTHNUM

# 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:

X Generation:  SIMPL v1.20.01 and later

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
Time & Date Functions
GETMONTHNUM

FUNCTION GETMONTHNUM GetMonthNum INTEGER MAIN PRINT


GETSECONDSNUM

# 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:

X Generation:  SIMPL v1.20.01 and later

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
Time & Date Functions
GETSECONDSNUM

FUNCTION GETSECONDSNUM GetSecondsNum INTEGER MAIN PRINT


GETTICKS

# GETTICKS

Name:

GetTicks

Syntax:

    INTEGER GetTicks();

Description:

Returns an integer corresponding to the number of system ticks. Each tick is 1/112.5 seconds for X-Generation and 0.01 seconds for 2-Series, same as GetHSeconds(). Typically, this function could be used for very fine timing, to determine if a specific amount of time has elapsed. Use of this function is discouraged, use GetHSeconds() instead.

Parameters:

None.

Return Value:

The number of ticks in the clock.

Example:

    INTEGER OldTime, NewTime, Loop;

    Loop=0;

    OldTime=GETTICKS();

    WHILE(Loop \< 10000)

    {

      Loop = Loop + 1;

    }

    NewTime=GETTICKS();

    PRINT("Elapsed Time is %d ticks\n", Newtime-OldTime);

An example output from this code fragment would be "Elapsed Time is 7000 ticks".

NOTE: This is bad programming as it ties up the CPU.

Version:

X Generation:  SIMPL v1.20.01 and later

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
Time & Date Functions
GETTICKS

GETTICKS GetHSeconds GetTicks INTEGER PRINT WHILE


GETYEARNUM

# 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:

X Generation:  SIMPL v1.20.01 and later

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
Time & Date Functions
GETYEARNUM

FUNCTION GETYEARNUM GetYearNum INTEGER MAIN PRINT


MONTH

# 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".

Version:

X Generation:  SIMPL v1.20.01 and later

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
Time & Date Functions
MONTH


Time and Date Functions Overview (Part 1)

# 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).

|  |  |
|----|----|
| Function | Description |
| [Date] | Returns a string corresponding to the current date with the specified FORMAT. |
| [Day] | Returns the day of the week as a STRING. |
| [FileDate] | Returns a string corresponding to the current date of the specified file with the specified FORMAT. |
| [FileDay] | Returns the day of the week of the file as a STRING. |
| [FileGetDateNum] | Returns an integer corresponding to the day of the month of the file. |
| [FileGetDayOfWeekNum] | Returns an integer corresponding to the day of the week of file. |
| [FileGetHourNum] | Returns an integer corresponding to the number of hours in the time of the file. |
| [FileGetMinutesNum] | Returns an integer corresponding to the number of minutes in the file time. |
| [FileGetMonthNum] | Returns an integer corresponding to the month of the year of file. |
| [FileGetSecondsNum] | Returns an integer corresponding to the number of seconds in the time of the file. |
| [FileGetYearNum] | Returns an integer corresponding to the year of the file. |
| [FileMonth] | Returns a string containing the current system time. |
| [FileTime] | Returns a string containing the current system time. |
| [GetDateNum] | Returns an integer corresponding to the current day of the month. |
| [GetDayOfWeekNum] | Returns an integer corresponding to the current day of the week. |
| [GetDst] | Gets the current DST (Daylight Savings Time) state. |
| [GetGmtOffset] | Retrieves the GMT Offset that was configured via the consol command GMTOFFSET or through the SetGmtOffset() function. |
| [GetHourNum] | Returns an integer corresponding to the number of hours in the current time. |
| [GetHSeconds] | Returns an integer corresponding to the number of hundredths of a second based on the system clock. |
| [GetMinutesNum] | Returns an integer corresponding to the number of minutes in the current time. |
| [GetMonthNum] | Returns an integer corresponding to the current month of the year. |
| [GetSecondsNum] | Returns an integer corresponding to the number of seconds in the current time. |
| [GetTicks] | Returns an integer corresponding to the number of system ticks. |
| [GetYearNum] | Returns an integer corresponding to the current year. |
| [Month] | Returns the current month as a string. |
| [SetClock] | Sets the system clock. |
| [SetDate] | Sets the system date. |
| [SetGmtOffset] | Sets the system GMT Offset. |
| [Time] | Returns a string containing the current system time. |

Language Constructs & Functions
Time & Date Functions
Overview
Time and Date Functions Overview

DST Date Functions Overview Part STRING SetGmtOffset Time and


Time and Date Functions Overview (Part 2)

  [Date]: DATE.md
  [Day]: DAY.md
  [FileDate]: FILEDATE.md
  [FileDay]: FILEDAY.md
  [FileGetDateNum]: FILEGETDATENUM.md
  [FileGetDayOfWeekNum]: FILEGETDAYOFWEEKNUM.md
  [FileGetHourNum]: FILEGETHOURNUM.md
  [FileGetMinutesNum]: FILEGETMINUTESNUM.md
  [FileGetMonthNum]: FILEGETMONTHNUM.md
  [FileGetSecondsNum]: FILEGETSECONDSNUM.md
  [FileGetYearNum]: FILEGETYEARNUM.md
  [FileMonth]: FILEMONTH.md
  [FileTime]: FILETIME.md
  [GetDateNum]: GETDATENUM.md
  [GetDayOfWeekNum]: GETDAYOFWEEKNUM.md
  [GetDst]: GETDST.md
  [GetGmtOffset]: GETGMTOFFSET.md
  [GetHourNum]: GETHOURNUM.md
  [GetHSeconds]: GETHSECONDS.md
  [GetMinutesNum]: GETMINUTESNUM.md
  [GetMonthNum]: GETMONTHNUM.md
  [GetSecondsNum]: GETSECONDSNUM.md
  [GetTicks]: GETTICKS.md
  [GetYearNum]: GETYEARNUM.md
  [Month]: MONTH.md
  [SetClock]: SETCLOCK.md
  [SetDate]: SETDATE.md
  [SetGmtOffset]: SETGMTOFFSET.md
  [Time]: TIME.md

DATE Date Day FileDate FileDay FileGetDateNum FileGetDayOfWeekNum FileGetHourNum FileGetMinutesNum FileGetMonthNum FileGetSecondsNum Functions Overview Part TIME Time and

|
| [Time] | Returns a string containing the current system time. |


SETCLOCK

# 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.

SECONDS is an integer containing the seconds portion of the time to which the clock is set. SECONDS range from 0 to 59.

Return Value:

None.

Example:

    ANALOG_INPUT Hours, Minutes, Seconds;

    CHANGE Hours, Minutes, Seconds

    {

      SetClock(Hours, Minutes, Seconds);

      PRINT("Current Time is: %s\n", Time());

    }

In this example, the Hours, Minutes, and Seconds are specified from an external SIMPL Program. For example, if Hours = 5, Minutes = 10, Seconds = 25, then the output will be Current Time is: 05:10:25.

Version:

X Generation:  SIMPL v1.50.06

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
Time & Date Functions
SETCLOCK

ANALOG_INPUT CHANGE INTEGER PRINT SETCLOCK SetClock Time


SETDATE

# 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. The year is four digits, i.e. 1999.

Return Value:

None.

Example:

    ANALOG_INPUT Month, Day, Year;

    CHANGE Month, Day, Year

    {

      SetDate(Month, Day, Year);

      PRINT("Current Date is: %s\n", Date(1));

    }

In this example, Month, Day, and Year come from a SIMPL program. For example, if Month = 12, Day = 25, Year = 1999, the output from this program will be Current Date = 12/25/1999.

Version:

X Generation:  SIMPL v1.50.06

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
Time & Date Functions
SETDATE

ANALOG_INPUT CHANGE Date INTEGER PRINT SETDATE SetDate


SetGmtOffset

# SetGmtOffset

Name:

SetGmtOffset

Syntax:

    SIGNED_INTEGER SetGmtOffset(SIGNED_INTEGER GmtOffset);

Description:

Sets the system GMT Offset. Can be used as an alternative to the GMTOFFSET console command.

Parameters:

A SIGNED_INTEGER containing the offset in minutes. Valid values are -720 through 780.

Return Value:

A SIGNED_INTEGER

 0: Success

-1: Could not set (out of range)

Example:

    // Set the GMT Offset to -300 minutes (-5 hours)

    SIGNED_INTEGER return_code;

    return_code = SetGmtOffset(-300);

    if(return_code = -1)

       print("Could not set GMT Offset, out of range.\n");

Error (-1) is returned.

Version:

SIMPL+ Version 3.03.00 or later

CUZ 3.154 or later required

Language Constructs & Functions
Time & Date Functions
SETGMTOFFSET
SetGmtOffset


TIME

# 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 0s.

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:

X Generation:  SIMPL v1.20.01 and later

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
Time & Date Functions
TIME


ByRef, ByVal, ReadOnlyByRef (Part 1)

# ByRef, ByVal, ReadOnlyByRef

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.

Language Constructs & Functions
User Defined Functions
ByRef, ByVal, ReadOnlyByRef
ByRef, ByVal, ReadOnlyByRef


ByRef, ByVal, ReadOnlyByRef (Part 2)

| KEYWORD       | MEANING                                                                                |
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ByRef         | Changes made to the variable that is passed to the function actually change the contents of the source variable. Note that any change made to the source variable will be reflected in the function. For example, if an INTEGER is passed ByRef and its state changes, the function will know about the change. It is typically more efficient to pass a variable by reference because space is not taken up by making local copies as with ByVal. Also referred to as "Pass by Reference".                                                                                |
| ByVal         | The variable that is passed to the function has a local copy made of it. Changes made to the variable in the function are made on a local copy. The local copy is destroyed when the function terminates. The contents of this variable are a "snapshot" of the contents of the variable that was passed. Unlike Pass by Reference, changes made to the original variable that was passed to the function are not recognized in the function. When an expression is passed, it may only be passed by value since there is no source variable that the ByRef keyword may potentially modify. Also referred to as "Pass by Value". |
| ReadOnlyByRef | This performs a Pass by Reference, identical to ByRef, but the compiler catches operations that write to the variable that has been passed. This would be typically be used if a DIGITAL_INPUT or other input type has been passed and which cannot be written. It is also used as a tool to catch unintentional writes to variables that have been passed.                                                                                |

ByRef ByVal DIGITAL_INPUT INTEGER Part ReadOnlyByRef

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.


ByRef, ByVal, ReadOnlyByRef (Part 3)

If not specified in the function declaration, variables will be passed by reference if applicable. If the variable cannot be passed by reference (such as an element of an array), it will be passed by value. Any expression will always be passed by value.

The following table shows legal access methods for the basic data types when passed

to a function.

It is also used as a tool to catch unintentional writes to variables that have been passed. |


ByRef, ByVal, ReadOnlyByRef (Part 4)

| VARIABLE TYPE                           | ByVal [LOCAL COPY] | ByRef [SOURCE] | ReadOnlyByRef [SOURCE] |
| --------------------------------------- | ------------------ | -------------- | ---------------------- |
| ANALOG_INPUT                            | R, W               | R, (E1)        | R                      |
| ANALOG_INPUT array                      | -                  | R, (E1)        | R                      |
| ANALOG_INPUT array element              | R,W                | -              | -                      |
| ANALOG_OUTPUT                           | R,W                | -              | R                      |
| ANALOG_OUTPUT array                     | -                  | -              | R                      |
| ANALOG_OUTPUT array element             | R, W               | -              | -                      |
| BUFFER_INPUT                            | R, W               | R              | R                      |
| BUFFER_INPUT array                      | -                  | R              | R                      |
| BUFFER_INPUT array element              | R, W               | -              | -                      |
| DIGITAL_INPUT                           | R, W               | R, (E1)        | R                      |
| DIGITAL_INPUT array                     | -                  | R, (E1)        | R                      |
| DIGITAL_INPUT array element             | R, W               | -              | -                      |
| DIGITAL_OUTPUT                          | R, W               | -              | R                      |
| DIGITAL_OUTPUT array                    | -                  | -              | R                      |
| DIGITAL_OUTPUT array element            | R, W               | -              | -                      |
| INTEGER                                 | R, W               | R, W           | R                      |
| INTEGER array                           | -                  | R, W           | R                      |
| INTEGER array element                   | R, W               | -              | -                      |
| LONG_INTEGER                            | R, W               | R, W           | R                      |
| LONG_INTEGER array                      | -                  | R, W           | R                      |
| LONG_INTEGER array element              | R, W               | -              | -                      |
| SIGNED_INTEGER                          | R, W               | R, W           | R                      |
| SIGNED_INTEGER array                    | -                  | R, W           | R                      |
| SIGNED_INTEGER array element            | R, W               | -              | -                      |
| SIGNED_LONG_INTEGER                     | R, W               | R, W           | R                      |
| SIGNED_LONG_INTEGER array               | -                  | R, W           | R                      |
| SIGNED_LONG_INTEGER array element       | R, W               | -              | -                      |
| STRING                                  | R, W               | R, W           | R                      |
| STRING array                            | -                  | R, W           | R                      |
| STRING array element                    | R, W               | -              | -                      |
| STRING_INPUT                            | R, W               | R              | R                      |
| STRING_INPUT array                      | -                  | R              | R                      |
| STRING_INPUT array element              | R, W               | -              | -                      |
| STRING_OUTPUT                           | -                  | -              | -                      |
| 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               | -              | -                      |
| STRUCTURE element (STRING)              | -                  | -              | -                      |

Any expression will always be passed by value. The following table shows legal access methods for the basic data types when passed

to a function.


ByRef, ByVal, ReadOnlyByRef (Part 5)

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.

An example of a function declaration that has no parameters and returns no value would be:

    FUNCTION PrintText()

    {

      // Code

    }

The following is an example of a function declaration that takes an INTEGER and returns a STRING. The INTEGER is passed by value, so it cannot be modified.

NOTE:  It is not strictly necessary to use the "ByVal" keyword here. ByVal can be used to make sure that no modifications to the original variable are done by accident within the function.

    STRING_FUNCTION ComputeDate(ByVal INTEGER TheMonth)

    {

      STRING Month$[20];

      // Code to compute Month$…

      RETURN(Month$);

    }

The following is an example of a function declaration that takes a STRING array and sorts it and an integer that takes the actual number of elements that are contained in the array. It returns an INTEGER error code:

    INTEGER_FUNCTION SortNameInDatabase(STRING Name[],

                                        INTEGER NumElements)

    {

      INTEGER Error;

      // Code to sort Names[] and setError…

      RETURN(Error);

    }

ByRef ByVal ComputeDate FUNCTION INTEGER INTEGER_FUNCTION Part PrintText RETURN ReadOnlyByRef STRING STRING_FUNCTION SortNameInDatabase


Calling a Function

# Calling a Function

When calling a function where the return is being used, the syntax is:

    \<variable\> = \<function_name\>([argument_list]);

For example,

    INTEGER X, ANALOG1, ANALOG2;

    STRING Q$[20], B$[50];

    X = ComputeChecksum(Analog1, Analog2);

    Q$ = DoSomething(Analog1, B$);

Are legal.

If the return is not going to be used, or there is no return (in the case of a FUNCTION), the syntax is:

    \<CALL\> \<function_name\>([argument_list]);

For example,

    CALL DoSomethingElse();  (X-Generation or 2-Series)

or

    DoSomethingElse() ;   (2-Series only)

NOTE:  (X-Generation only) Functions do not support recursion, i.e. the code in the body of a function may not contain a call to that function.

NOTE:  The keyword, CALL, is required in the X-Generation control system, and optional in the 2-Series control system. CALL may not be used when calling non-user defined functions.   For example:  CALL Print( str, "abc" );   // Illegal

Language Constructs & Functions
User Defined Functions
Calling a Function

Calling ComputeChecksum DoSomething DoSomethingElse FUNCTION Function INTEGER Print STRING


Function Definition

# Function Definition

    \<function_type\> \<function_name\> ([argument list])

    {

      \<statements\>

     [RETURN \<expression\>;]

    }

The table shown below demonstrates what \<function_type\> may be, what it means, and what data may be returned to the caller. Note that in all cases, a RETURN is not required, as the system defaults it to a shown specified value.

| <function type>              | MEANING                                            | RETURN VALUE                               |
| ---------------------------- | -------------------------------------------------- | ------------------------------------------ |
| FUNCTION                     | Returns no data to the caller.                     | No RETURN                                  |
| INTEGER_FUNCTION             | Returns an integer value to the caller.            | INTEGER expression (default 0)             |
| LONG_INTEGER_FUNCTION        | Returns a long integer value to the caller.        | LONG_INTEGER expression (default 0)        |
| SIGNED_INTEGER_FUNCTION      | Returns a signed integer value to the caller.      | SIGNED_INTEGER expression (default 0)      |
| SIGNED_LONG_INTEGER_FUNCTION | Returns a signed long integer value to the caller. | SIGNED_LONG_INTEGER expression (default 0) |
| STRING_FUNCTION              | Returns a string value to the caller.              | STRING expression (default "")             |

Language Constructs & Functions
User Defined Functions
Function Definition


Function Libraries

# 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.

In order to include a function library, the #CRESTRON_LIBRARY or #USER_LIBRARY directives are used. The libraries are searched in the order they are included, in case a function name is used in more than one library. The first function found is used. Refer to #CRESTRON_LIBRARY and #USER_LIBRARY  for more information.

Language Constructs & Functions
User Defined Functions
Function Libraries


Function Parameters

# 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. Typically, data is passed to a function in order to make the code readable, maintainable, and less prone to bugs. SIMPL+ Version 1.00 did not allow data to be passed to functions. The only way to get data into functions was to declare global variables and have the functions reference the global variables.

The function argument list contains a comma separated list of arguments. The arguments are of the form:

    [ByRef | ByVal] \<INTEGER | LONG_INTEGER | SIGNED_INTEGER | SIGNED_LONG_INTEGER | STRUCTURE\> \<variable_name\>

[ByRef and ByVal][BYVAL and BYREF] are keywords telling the system the read/write permissions and local behavior for the variable in the function.

[INTEGER], [STRING][STRINGs] or [STRUCTURE] tells the function the\<variable_name\> type. [BUFFER_INPUT], [STRING_INPUT], [STRING_OUTPUT], and STRING declarations are passed into a function using the STRING type. All other types are passed using the INTEGER type.

The function refers to the passed variable as \<variable_name\>. Note that for a one-dimensional array, the syntax is \<variable_name\>[] and for a two-dimensional array the syntax is \<variable_name\>[][].

  [STRINGs]: ../Declarations/STRING.md
  [BYVAL and BYREF]: ByRef%2c_ByVal%2c_ReadOnlyByRef.md
  [DIGITAL_INPUT]: ../Declarations/DIGITAL_INPUT.md
  [ANALOG_INPUT]: ../Declarations/ANALOG_INPUT.md
  [STRING_INPUT]: ../Declarations/STRING_INPUT.md
  [INTEGER]: ../Declarations/INTEGER.md
  [STRUCTURE]: ../Declarations/STRUCTURES.md
  [BUFFER_INPUT]: ../Declarations/BUFFER_INPUT.md
  [STRING_OUTPUT]: ../Declarations/STRING_OUTPUT.md

Language Constructs & Functions
User Defined Functions
Function Parameters


Returning a Value

# Returning a Value

The syntax for returning a value from integer and string functions is RETURN \<expression\>;.   \
To return 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.

For Integer Functions, any valid integer expression is legal. For example:

    RETURN (25);

    RETURN (Z + MULDIV(A,B,C) + 100);

Are legal (assuming Z, A, B, C, are INTEGERs). If no RETURN statement is present in an integer, 0 is returned.

NOTE: If no Return Value is specified within an String_Function, then an empty string will be returned by default.

NOTE: RETURN  is a 2-Series only function.

For a string function, any valid string is legal (string expressions are not allowed).  For example:

STRING str[100];

RETURN ("Hello!\n");

RETURN (str);

Are legal (assuming Z is an INTEGER and A$ is a STRING). If no RETURN statement is present in a STRING_FUNCTION, an empty string ("") is returned.

In SIMPL Version 3.00, the RETURN statement without arguments can be used in all functions that do not return strings or integers. For example:

         INTEGER_FUNCTION MyIntegerFn ( )

    {

      IF (1)

      {

      RETURN (1);

      }

      RETURN (0);

    }

    LONG_INTEGER_FUNCTION MyLongIntFn ( )

    {

      IF (1)

      {

      RETURN (1);

      }

      RETURN (0);

    }

    SIGNED_INTEGER_FUNCTION MySignedIntFn ( )

    {

      IF (1)

      {

      RETURN (1);

      }

      RETURN (0);

    }

SIGNED_LONG_ INTEGER_FUNCTION MySignedLongIntFn ( )

    {

      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 Constructs & Functions
User Defined Functions
Returning a Value

CHANGE EVENT FUNCTION IF INTEGER INTEGER_FUNCTION LONG_INTEGER_FUNCTION MULDIV MyFn MyIntegerFn MyLongIntFn MySignedIntFn MySignedLongIntFn MyStringFn PUSH RELEASE RETURN Returning SIGNED_INTEGER_FUNCTION SIGNED_LONG_INTEGER_FUNCTION


User Defined Functions Overview

# 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.

Language Constructs & Functions
User Defined Functions
User Defined Functions Overview


CancelAllWait

# 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.

Example:

    DIGITAL_INPUT Trig, KillWaits;

    PUSH Trig

    {

      WAIT(1000, FirstWait)

 {

        PRINT("Wait 1 Triggered!\n");

 }

      WAIT(2000, SecondWait)

 {

        PRINT("Wait 2 Triggered!\n");

 }

    }

    PUSH KillWaits

    {

      CancelAllWait();

    }

In this example, when Trig is pushed, a 10-second and 20-second event are scheduled. Whichever wait events are still running when KillWaits is triggered, will be removed from the Wait list and will not get activated.

Version:

X Generation:  SIMPL v1.20.01 and later

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
Wait Events
CANCELALLWAIT
CancelAllWait

CancelAllWait DIGITAL_INPUT PRINT PUSH WAIT


CancelWait

# 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.

Example:

    DIGITAL_INPUT Trig, KillWaits;

    PUSH Trig

    {

      WAIT(1000, FirstWait)

{

        PRINT("Wait 1 Triggered!\n");

}

      WAIT(2000, SecondWait)

{

        PRINT("Wait 2 Triggered!\n");

}

    }

    PUSH KillWaits

    {

      Cancelwait(FirstWait);

    }

In this example, when Trig is pushed, a 10-second and 20-second event are scheduled. When KillWaits is triggered, if FirstWait is still on the wait list, it will be removed from the wait list and will not get activated. SecondWait will activate at the end of the 20-second wait time.

Version:

X Generation:  SIMPL v1.20.01 and later

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
Wait Events
CANCELWAIT
CancelWait

CancelWait Cancelwait DIGITAL_INPUT PRINT PUSH WAIT


Wait Events Overview

# 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. The system supports up to 200 total timed events that may be running at any given time across all SIMPL+ modules.

Timed events include: WAIT, DELAY, and PAUSE statements.

A WAIT statement differs from a DELAY in both timing and order of statement execution. In a WAIT statement, the WAIT block executes only after the specified amount of time, but execution proceeds immediately to the statement following the WAIT block.  In a DELAY, all execution is halted until the delay is finished.

Language Constructs & Functions
Wait Events
Overview
Wait Events Overview


PauseAllWait

# 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.

Example:

    DIGITAL_INPUT Trig, PauseWaits;

    PUSH Trig

    {

      WAIT(1000, FirstWait)

{

        PRINT("Wait 1 Triggered!\n");

}

      WAIT(2000, SecondWait)

{

        PRINT("Wait 2 Triggered!\n";

}

    }

    PUSH PauseWaits

    {

      PauseAllWaits();

    }

In this example, when Trig is pushed, a 10-second and 20-second event is scheduled. When PauseWaits is triggered, any of the running WAIT events will be halted, but may later be resumed, cancelled, or retimed.

Version:

X Generation:  SIMPL v1.20.01 and later

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
Wait Events
PAUSEALLWAIT
PauseAllWait

DIGITAL_INPUT PRINT PUSH PauseAllWait PauseAllWaits WAIT


PauseWait

# 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.

Example:

    DIGITAL_INPUT Trig, PauseWait;

    PUSH Trig

    {

      WAIT(1000, FirstWait)

{

        PRINT("Wait 1 Triggered!\n");

}

      WAIT(2000, SecondWait)

{

        PRINT("Wait 2 Triggered!\n";

}

    }

    PUSH PauseWait

    {

      PauseWait(SecondWait);

    }

In this example, when Trig is pushed, a 10-second and 20-second event is scheduled. When PauseWait is triggered, the SecondWait event will be paused if it has not already run to completion. It may be later cancelled, resumed, or retimed.

Version:

X Generation:  SIMPL v1.20.01 and later

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
Wait Events
PAUSEWAIT
PauseWait


ResumeAllWait

# 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.

Example:

    DIGITAL_INPUT Trig, PauseWaits, ResumeWaits;

    PUSH Trig

    {

      WAIT(1000, FirstWait)

{

        PRINT("Wait 1 Triggered!\n");

}

      WAIT(2000, SecondWait)

{

        PRINT("Wait 2 Triggered!\n";

}

    }

    PUSH PauseWaits

    {

      PauseAllWait();

    }

    PUSH ResumeWaits

    {

      ResumeAllWaits();

    }

In this example, when Trig is pushed, a 10-second and 20-second event is scheduled. When PauseWaits is triggered, any of the running WAIT events will be halted. When ResumeWaits is triggered, the previously paused waits will resume from when they were paused. For example, if FirstWait and SecondWait were paused at 5-second, when ResumeAllWait is called, FirstWait will have 5-seconds more to execute and SecondWait will have 15-seconds more to execute.

Version:

X Generation:  SIMPL v1.20.01 and later

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
Wait Events
RESUMEALLWAIT
ResumeAllWait

DIGITAL_INPUT PRINT PUSH PauseAllWait ResumeAllWait ResumeAllWaits WAIT


ResumeWait

# 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.

Example:

    DIGITAL_INPUT Trig, PauseWaits, ResumeWaits;

    PUSH Trig

    {

      WAIT(1000, FirstWait)

{

        PRINT("Wait 1 Triggered!\n");

}

      WAIT(2000, SecondWait)

{

        PRINT("Wait 2 Triggered!\n";

}

    }

    PUSH PauseWaits

    {

      PauseAllWait();

    }

    PUSH ResumeWait

    {

      ResumeWait(FirstWait);

    }

In this example, when Trig is pushed, a 10-second and 20-second event is scheduled. When PauseWaits is triggered, any of the running WAIT events will be halted. When ResumeWaits is triggered, the FirstWait event that was previously paused will resume from when it was paused. For example, if FirstWait was paused at 5-seconds, when ResumeWait(FirstWait) is called, FirstWait will have 5-seconds more to execute. SecondWait will still be paused.

Version:

X Generation:  SIMPL v1.20.01 and later

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
Wait Events
RESUMEWAIT
ResumeWait

DIGITAL_INPUT PRINT PUSH PauseAllWait ResumeWait WAIT


RetimeWait

# 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 10-second, 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.

NAME is a name of a previously defined WAIT event.

Return Value:

None.

Example:

    DIGITAL_INPUT Trig, ChangeWaitTime;

    PUSH Trig

    {

      WAIT(1000, FirstWait)

{

        PRINT("Wait 1 Triggered!\n");

}

    }

    PUSH ChangeWaitTime

    {

      RetimeWait(500, FirstWait);

    }

In this example, when Trig is pushed, a 10-second event is scheduled. If ChangeWaitTime is activated while FirstWait is still running, the time will be reset to 5-seconds. If FirstWait has expired, no action will be taken.

Version:

X Generation:  SIMPL v1.20.01 and later

2-Series:  SIMPL v2.01.05 and later

Language Constructs & Functions
Wait Events
RETIMEWAIT
RetimeWait

DIGITAL_INPUT INTEGER PRINT PUSH RetimeWait TIME WAIT


Wait (Part 1)

# Wait

Name:

Wait

Syntax:

    Wait(INTEGER |LONG_INTEGER TIME[, NAME])

    [{]

      \<statements\>

    [}]

NOTE: There is no semicolon after a WAIT statement because it has a clause or block following it.

Description:

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. For example, if in an endless WHILE loop, a second WAIT will only begin after the first finishes.

When the system encounters a WAIT, the event is put into the WAIT scheduler. The SIMPL+ module continues to execute without interruption. At some point, a task switch will occur (either due to event termination or other means, refer to [Task Scheduling Changes and Consequences], [Task Switching for 2-Series Control Systems] and [Task Switching for X-Generation (CNX) Control Systems]). The WAIT schedule is checked by the operating system after a task switch, and if a wait event needs to be serviced, it is run and then terminates. Note that the module may task switch away while inside the WAIT, just like in other events.

A WAIT statement differs from a DELAY in both timing and order of statement execution. In a WAIT statement, the WAIT block executes only after the specified amount of time, but execution proceeds immediately to the statement following the WAIT block.  In a DELAY, all execution is halted until the delay is finished.

Parameters:

TIME is a long_integer, expressed in hundredths of a second. For example, 525 specifies a wait time of 5.25 seconds.

NAME is an optional name given to the WAIT event. It has the same syntax as a variable name. Note that you cannot put two separate WAIT statements in the same SIMPL+ program that have the same NAME (this will cause a compilation error).

NOTE:  (2-Series Only) The only variable types that are allowed to be used within a Wait Statement block are global variables and variables declared locally within the Wait Statement's block. Local variables declared within the function containing the Wait Statement are not allowed.

NOTE:  A semicolon should not be used at the end of the WAIT statement.  If a semicolon is placed immediately after the wait statement, a compiler error will result. If braces are not following the WAIT statement, only the statement immediately following will be part of the WAIT statement.  See example below.

Example:

    LONG_INTEGER WaitTime;

    DIGITAL_INPUT StopVCR;

    ANALOG_INPUT SysWait;

    STRING_OUTPUT VCR$;

    PUSH StopVCR

{

WAIT (SysWait, VCR_Stop) // correct

{

VCR$ = "\x02STOP\x03";

}

WAIT (SysWait, VCR_Stop) // correct

VCR$ = "\x02STOP\x03"; // this is the only statement for this WAIT statement

VCR$ = "\x02PLAY\x03"; // will NOT be included in WAIT statement

WAIT (SysWait, VCR_Stop); // ERROR - semicolon should NOT be used

{

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)

}

}

Language Constructs & Functions
Wait Events
WAIT
Wait

ANALOG_INPUT DELAY DIGITAL_INPUT FUNCTION Generation INTEGER LONG_INTEGER MyFunc NAME PUSH Part STRING_OUTPUT TIME WAIT WHILE Wait


Wait (Part 2)

In this example, a VCR is triggered to go into STOP, but the STOP command is delayed based upon a time specified by an analog input to the SIMPL+ program.

Version:

X Generation

SIMPL v1.20.01 and later

2-Series:

SIMPL v2.01.05 and later [Same as X Generation SIMPL v1.20.01] however local variables are allowed within WAIT statements.

  [Task Scheduling Changes and Consequences]: ../../Task_Switching/Task_Scheduling_Changes_and_Consequences.md
  [Task Switching for 2-Series Control Systems]: ../../Task_Switching/Task_Switching_for_2-Series_Control_Systems.md
  [Task Switching for X-Generation (CNX) Control Systems]: ../../Task_Switching/Task_Switching_for_CNX_Control_Systems.md

CNX Changes Consequences Control Generation Part Scheduling Series Switching Systems Task WAIT Wait and for

See example below. Example:

    LONG_INTEGER WaitTime;

    DIGITAL_INPUT StopVCR;

    ANALOG_INPUT SysWait;

    STRING_OUTPUT VCR$;

    PUSH StopVCR

{

WAIT (SysWait, VCR_Stop) // correct

{

VCR$ = "\x02STOP\x03";

}

WAIT (SysWait, VCR_Stop) // correct

VCR$ = "\x02STOP\x03"; // this is the only statement for this WAIT statement

VCR$ = "\x02PLAY\x03"; // will NOT be included in WAIT statement

WAIT (SysWait, VCR_Stop); // ERROR - semicolon should NOT be used

{

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)

}

}


System Interfacing Functions

# System Interfacing Functions

- [GetCIP]

- [GetCresnet]

- [GetSlot]

- [IsSignalDefined]

- [SendCresnetPacket]

- [SendPacketToCPU]

- [SetCIP]

- [SetCresnet]

- [SetSlot]

  [GetCIP]: Language_Constructs_&_Functions/System_Interfacing/GetCIPDev.md
  [GetCresnet]: Language_Constructs_&_Functions/System_Interfacing/GetCresnetDev.md
  [GetSlot]: Language_Constructs_&_Functions/System_Interfacing/GetSlotDev.md
  [IsSignalDefined]: Language_Constructs_&_Functions/System_Interfacing/IsSignalDefined.md
  [SendCresnetPacket]: Language_Constructs_&_Functions/System_Interfacing/SendCresnetPacket.md
  [SendPacketToCPU]: Language_Constructs_&_Functions/System_Interfacing/SendPacketToCPU.md
  [SetCIP]: Language_Constructs_&_Functions/System_Interfacing/SetCIPDev.md
  [SetCresnet]: Language_Constructs_&_Functions/System_Interfacing/SetCresnetDev.md
  [SetSlot]: Language_Constructs_&_Functions/System_Interfacing/SetSlotDev.md

Obsolete Functions
System Interfacing Functions

Functions GetCIP GetCresnet GetSlot Interfacing IsSignalDefined SendCresnetPacket SendPacketToCPU SetCIP SetCresnet SetSlot System

GetCIP GetCresnet GetSlot IsSignalDefined SendCresnetPacket SendPacketToCPU SetCIP SetCresnet SetSlot


Arithmetic Operators

# Arithmetic Operators

Arithmetic Operators

| OPERATOR | NAME                | EXAMPLE  | EXPLANATION                                                                   |
| -------- | ------------------- | -------- | ----------------------------------------------------------------------------- |
| -        | Negation            | -X       | Negate the value of X (2's Complement of X).                                  |
| *        | Multiplication      | X *Y     | Multiply X by Y (signed arithmetic).                                          |
| /        | Unsigned Division   | X / Y    | Divide X by Y, truncates result (unsigned arithmetic).                        |
| S/       | Signed Division     | X S/ Y   | Divide X by Y, truncates result (signed arithmetic).                          |
| MOD      | Signed Modulo       | X MOD Y  | Remainder after dividing X by Y (signed arithmetic).                          |
| UMOD     | Unsigned Modulo     | X UMOD Y | Remainder after dividing X by Y (unsigned arithmetic). Only 2-Series Systems. |
| %        | Signed Modulo Alias | X % Y    | Translates to Signed Modulo                                                   |
| +        | Addition            | X + Y    | Add the value of Y to X.                                                      |
| -        | Subtraction         | X - Y    | Subtract the value of Y from X                                                |


Bitwise Operators

# Bitwise Operators

Bitwise Operators

|  |  |  |  |
|----|----|----|----|
| OPERATOR | NAME | EXAMPLE | EXPLANATION |
| \<\< | Shift Left | X \<\< Y | Shift X to the left by Y bits; 0 is Shifted in. |
| \>\> | Shift Right | X \>\> Y | Shift X to the right by Y bits; 0 is Shifted in. |
| {{ | Rotate Left | X {{ Y | Rotate X to the left by Y bits; full 16 bits used. Same as RotateLeft(). |
| }} | Rotate Right | X }} Y | Rotate X to the right by Y bits; full 16 bits used. Same as RotateRight(). |
| NOT | 1's Complement | NOT(X) | Change 0 bits to 1, 1 bits to 0. |
| & | Bitwise AND | X & Y | AND the bits of X with the bits of Y. |
| | | Bitwise OR | X | Y | OR the bits of X with the bits of Y. |
| ^ | Bitwise XOR | X ^ Y | XOR the bits of X with the bits of Y. |

NOTE:  For the Shift and Rotate operators, only the lower 5-bits of Y are used, giving values of Y ranging from 0 to 31. For example, if Y=600, the lower 5-bits equate to 24. Rotating a 16-bit number through 16 positions gives the original number back. Therefore, for rotating 24, the result is equivalent to rotating through 8. Shifting greater than 16 will always give a 0 as a result.

Bitwise NOT Operators RotateLeft RotateRight