Crestron SIMPL+
Language Reference Guide - DOC. 5797G
®
Example 4: Computing the Number of Days in a
Month (Using Function Libraries)
The following code would be saved as, in this example, "My Function Library.USL".
INTEGER_FUNCTION ComputeDaysInMonth(INTEGER Month)
{
// Note that this computation does NOT take into account leap
// year!
INTEGER Days;
SWITCH(Month)
{
CASE( 2): Days = 28; // February
CASE( 4): Days = 30; // April
CASE( 6): Days = 30; // June
CASE( 9): Days = 30; // September
CASE(11): Days = 30; // November
Default:
Days = 31;
}
Return(Days);
}
The following code can be saved as any filename:
#SYMBOL_NAME "Compute Number of Days in a Month"
#USER_LIBRARY "My Function Library"
#ANALOG_INPUT MONTH;
#ANALOG_OUTPUT DAYS;
CHANGE MONTH
{
DAYS = ComputeDaysInMonth(MONTH);
}
// All others
Software
®
SIMPL+
283
Need help?
Do you have a question about the SIMPL+ and is the answer not in the manual?