-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.scscript
More file actions
194 lines (157 loc) · 6.13 KB
/
example.scscript
File metadata and controls
194 lines (157 loc) · 6.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
// Example Swipeclock Script
// This file demonstrates the syntax highlighting and IntelliSense features
// Employee object properties
if (employee.department == "OPS") {
addalert("Employee is in OPS department");
// Check employee name
if (employee.firstname contains "John") {
addalert("Found John");
}
}
// ReportingDate object properties
if (reportingdate.isfirstdayofmonth) {
addalert("First day of the month");
}
if (reportingdate.totalhours > 8) {
addalert("Overtime alert");
}
// Global functions
$myvar = dateadd("mm", 6, employee.startdate);
$result = dateserial(reportingdate.year, 12, 31);
// Time rounding
round("N15"); // Round to nearest 15 minutes
roundin("U30"); // Round in punches up to nearest 30 minutes
roundout("D15"); // Round out punches down to nearest 15 minutes
// String functions
$dept = translate(employee.department, "100|110|200", "Warehouse,Shipping,Accounting");
if (within(employee.location, "100|110|200")) {
addalert("Location found");
}
// Time comparisons
if (intime > "8:00am") {
addalert("Late arrival");
}
if (intime < 7:00am) {
addalert("Early arrival");
}
// Date comparisons
if (reportingdate.date > "2024-01-01") {
addalert("Date is after 2024-01-01");
}
// Accrual functions
accrueup("PTO", 4, 160);
$balance = getbalance("Vacation");
setbalance("Sick", 0);
// Additional functions
if (touches(6:00am, 3:00pm)) {
addalert("Punch touches time range");
}
if (overlaps(6:00am, 3:00pm)) {
addalert("Punch overlaps time range");
}
// Properties that have function overloads
$isHoliday = reportingdate.isholiday;
$isYesterdayHoliday = reportingdate.isholiday(reportingdate.date - 1);
// Functions with multiple signatures
round("N15");
round(5.555);
split(12:00am);
split(12:00am, true, false);
// Global properties
if (isfirsttoday) {
addalert("First punch of the day");
}
if (hours > 8) {
addalert("More than 8 hours");
}
// Local variables (with $ prefix)
$hoursWorked = hours;
$categoryName = category;
// Global variables (no prefix)
myGlobalVar = 10;
anotherVar = "Hello World";
// Comments
/* This is a multi-line comment
that spans multiple lines */
// Operators
if (employee.department == "OPS" && reportingdate.totalhours > 8) {
addalert("OPS employee with overtime");
}
if (employee.department contains "OPS" || employee.department startswith "HR") {
addalert("Department match");
}
// Nested if statements
if (employee.department == "OPS") {
if (reportingdate.totalhours > 8) {
addalert("Overtime");
} else if (reportingdate.totalhours < 4) {
addalert("Part time");
} else {
addalert("Regular hours");
}
} else {
addalert("Other department");
}
// ============================================
// TEST CASES FOR ERROR AND WARNING HIGHLIGHTING
// ============================================
// Invalid property - should show ERROR (red squiggles)
employee.invalidproperty;
reportingdate.nonexistent;
// Extended fields - should show WARNING (yellow squiggles) if swipeclock.warnExtendedFields is enabled
employee.home4; // Warning: requires additional home fields to be enabled
employee.home5; // Warning: requires additional home fields to be enabled
employee.home9; // Warning: requires additional home fields to be enabled
employee.department1; // Warning: requires additional department fields to be enabled
employee.department5; // Warning: requires additional department fields to be enabled
employee.department9; // Warning: requires additional department fields to be enabled
employee.location1; // Warning: requires additional location fields to be enabled
employee.location3; // Warning: requires additional location fields to be enabled
employee.location9; // Warning: requires additional location fields to be enabled
employee.payrate1; // Warning: requires additional payrate fields to be enabled
employee.payrate5; // Warning: requires additional payrate fields to be enabled
employee.payrate9; // Warning: requires additional payrate fields to be enabled
// Requires an additional processing rule to be enabled
employee.birthday;
employee.schedule;
employee.maxhours;
employee.jobtitlecode;
employee.paytypecode;
employee.country;
employee.state;
employee.autolunchhours;
employee.lunchminutes;
employee.accrualfactor;
// Beyond official limit - should show ERROR (red squiggles)
employee.home10; // Error: beyond the officially supported limit of 9
employee.home15; // Error: beyond the officially supported limit of 9
employee.department10; // Error: beyond the officially supported limit of 9
employee.department20; // Error: beyond the officially supported limit of 9
employee.location10; // Error: beyond the officially supported limit of 9
employee.location99; // Error: beyond the officially supported limit of 9
employee.payrate10; // Error: beyond the officially supported limit of 9
employee.payrate100; // Error: beyond the officially supported limit of 9
// Invalid function - should show ERROR (red squiggles)
invalidfunction(); // Error: unrecognized function
nonexistentfunction(123); // Error: unrecognized function
badfunctioncall("test", 456); // Error: unrecognized function
// Undefined variable - should show WARNING (yellow squiggles)
undefinedGlobalVar; // Warning: variable may be undefined
$undefinedLocalVar; // Warning: variable may be undefined
anotherUndefinedVar; // Warning: variable may be undefined
// Invalid string declaration - should show ERROR (red squiggles)
$invalidStringTest = 'single quotes not supported'; // Error: single quotes not supported
addalert('invalid string'); // Error: single quotes not supported
// Valid examples (no errors/warnings)
definedGlobal = 10;
definedGlobal; // This should NOT show a warning since it's defined above
$definedLocal = "test";
$definedLocal; // This should NOT show a warning since it's defined above
// Valid extended fields (home1-3 are default, no warning needed)
employee.home1; // No warning - default field
employee.home2; // No warning - default field
employee.home3; // No warning - default field
// Valid default fields (no warnings)
employee.department; // No warning - default field
employee.location; // No warning - default field
employee.payrate0; // No warning - default field