<< Click to Display Table of Contents >> Manual > Script Guide > Script Ver2 (SC2 syntax) > Data Types |
About Data Types
The SC2 syntax can handle the following five data types:
Data Types |
explanation |
Boolean |
It is a Boolean value (T or F). "T" represents the On state and "F" represents the Off state. |
Number |
It is a number. It can also handle decimal points. |
character |
A string. |
time |
Time (date and time). |
Object |
You can store objects in variables. |
Other states besides those listed in the table above include indefinite values (#N/A#) and null values (#NOTHING#). For more information, please refer to "About indefinite values and null values". |
Boolean
Write T or F. T represents the On state, and F represents the Off state. You can also write TRUE or FALSE (please write in all capital letters).
example)
var a = T; var b = F; var d = a && b; // d becomes F. var e = a || b; // e becomes T. var f = T && F || F; // f becomes F.
Numeric types
It is a number. It can handle both normal integers and double-precision floating-point numbers.
example)
var a = 123.45; var b = 23.45; var d = a + b; // d is 146.9. var e = 0xFF23; // You can express the number in hexadecimal by prefixing it with 0x
The range of values that can be handled in hexadecimal notation is 0x00000000 to 0xFFFFFFFF. |
Character types
It is a character. Characters must be enclosed in quotation marks (").
example)
var a = "Hello"; var b = a + " " + "World"; // b becomes "Hello World".
Time type
Time. Use the time format to express the time. For information about the time format, see "Time type format".
example)
var a = #2005/1/2 3:4:5#; //January 2, 2005, 3:04:05 var a = #2005/1/2 3:4:5.123#; //January 2, 2005, 3:04:05, 123ms var a = #now#; //The current time var a = #now - 1D#; //The time one day ago (24 hours ago) from the current time
Object Types
You can store objects in variables.
example)
var a = this; //Assign your own object a.FillColor = "#FF0000"; //Make your own background red a = parent; //Assign the parent object a.FillColor = "#00FF00"; //Make the parent background green
In addition to directly specifying the time, time type data can also be used to find a relative time, such as 10 minutes from now. Some controls have time type properties, and when accessing these from a script, you can do so using a time type variable.
Absolute time specification
The format for expressing absolute time is as follows:
#yyyy/mm/dd H:M:S# |
example)
#2005/1/2 3:4:5# |
If you want to include the ms, use the following format:
#yyyy/mm/dd H:M:S.ms# |
example)
#2005/1/2 3:4:5.123# |
Relative time specification
The time type also allows for relative time expressions. Relative time is a way of specifying the date and time, such as one day later based on the current date and time.
The format for expressing relative time is as follows:
Reference time [+time interval] [-time interval]... |
The following base times can be specified in the base time section of the format.
Reference time |
explanation |
If the current time is "2016/06/15 12:12:12" (Wednesday), |
now |
the current. |
2016/06/15 12:12:12 |
year |
this year. |
2016/01/01 00:00:00 |
month |
this month. |
2016/06/01 00:00:00 |
week |
this week. |
2016/06/12 00:00:00 |
day |
today. |
2016/06/15 00:00:00 |
hour |
The current time (valid until o'clock). |
2016/06/15 12:00:00 |
minute |
The current time (valid down to the minute). |
2016/06/15 12:12:00 |
future |
future. |
A time far into the future. |
past |
past. |
A time far in the past. |
Before the time interval, you must specify a "+" or "-" and a numerical value. "+" means future, and "-" means past. For example, "+10m" means 10 minutes after the reference time.
Time Interval |
explanation |
y |
year |
mo |
month |
d |
day |
w |
week |
h |
time |
m |
Minutes |
s |
Seconds |
Example: If the current date is "2016/01/13 12:12:12" (Wednesday)
|
If the current date is the 31st, you cannot use a relative time that includes subtracting months from NOW (e.g. #NOW-1MO#, etc.). This is because if the month before the 31st has only 30 days, an error will occur because there is no corresponding day. Please be aware of this. |
If you perform calculations using time type values, the results will be as follows:
var a = #2004/1/1 0:0:0#; var b = #2004/1/1 0:1:0#; var d = b - a; // d is 60 (seconds). var e = a + 10; // e is added to a by 10 seconds, so it becomes #2004/1/1 0:0:10#. |
The root method "GetRelativeTime" can obtain a relative time using a relative time format based on a specific time (not the current time, but a specified time).
Example 1) The result will be "2002/10/9 10:10:10". var a = ::GetRelativeTime(::CTime("2002/10/10 10:10:10"), "now-1d");
Example 2) The result will be "2002/10/9 0:0:0". var a = ::GetRelativeTime(::CTime("2002/10/10 10:10:10"), "day-1d"); |
Type conversion
The root method provides the following conversion methods, which can be called from a script to perform type conversion.
Converts a value to a Boolean type. |
|
Converts a value to a numeric type. |
|
Converts a value to a string. |
|
Converts a value to a time type. |
|
Creates a numeric string according to a format. |
|
Converts a value to a time string. |
|
Converts a value to a hexadecimal string. |
|
Converts a value to an octal string. |
|
Converts a value to a binary string. |
|
Converts a hexadecimal string to a value. |
|
Converts an octal string to a value. |
|
Converts a binary string to a value. |
For example, in the following case, the string “Data1:123 Data2:456” will be assigned to the variable c.
var a = 123; var b = 456; var c = "Data1:" + ::CStr(a) + " Data2:" + ::CStr(b);
CNumToLocale (NL) is a convenient function that generates a numeric string with the decimal point and number of digits adjusted. The first argument is the numeric value, and the second argument is the number of decimal points.
Example: In the following example, the character "12.00" is assigned to a. var a = ::NL(12, 2); |