|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Date and Time Calculation > DTO. - Date Time Operations > Date & Time Operations |
MiniRobotLanguage (MRL)
DTO.gsec Command
Get the numeric second value from a time string
Intention
This command parses a time string, based on an optional format mask, and extracts the numeric value of the **Second** component (0-59).
Syntax
DTO.gsec|TimeString|[FormatMask]|[$$RES]
DTO.getsecond|...
Parameter Explanation
P1 - TimeString (Required)
The time string (or a variable, e.g., $$TIM) containing the time value.
Example: "14:30:45.123"
P2 - FormatMask (Optional)
The format mask string (or variable) describing the structure of P1.
Example: "HH:MM:SS.ttt". If omitted, a default mask like "HH:MM:SS.ttt" (using ':' separator) is assumed.
P3 - $$RES (Optional)
The variable (e.g., $$SEC) where the numeric second value (0-59) will be stored. If omitted, the result is placed on TOS.
Example
'**********************************************
' DTO.gsec - Sample
'**********************************************
'
' --- Example 1: Get second from standard time ---
$$TIM = "14:30:45"
DTO.gsec|$$TIM||$$SEC
DBV.Second 1: $$SEC ' Result: 45
'
' --- Example 2: Get second using a different mask ---
$$TIM = "22.15.05.1234"
$$MSK = "HH.MM.SS.XXXX"
DTO.gsec|$$TIM|$$MSK|$$SEC
DBV.Second 2: $$SEC ' Result: 5
'
' --- Example 3: No seconds specified (defaults to 0) ---
$$TIM = "08:00"
$$MSK = "HH:MM"
DTO.gsec|$$TIM|$$MSK|$$SEC
DBV.Second 3: $$SEC ' Result: 0
'
ENR.
Remarks
This command uses the INT_ParseTimeComponents backend function.
If the time string does not contain seconds, or if the mask doesn't specify 'SS' or 'S', the command returns 0.
Limitations
- If the time string cannot be parsed correctly using the mask (e.g., wrong format or invalid values like 70 seconds), the result will be 0.
See also
• DTO.Get Time Milliseconds (gtms)