8.3.17 SeparateStrCount (count the number of separate strings)
- Purpose
-
Splits a specified string at a specified delimiter, and returns the number of separate strings.
- Syntax
SeparateStrCount (String, SeparateChar)
- Arguments
-
- String
-
Write the string to be split, or specify a variable that stores this value.
- SeparateChar
-
Specify the delimiter as a character string or as a variable that stores this value.
- Description
-
The SeparateStrCount command splits a specified string at the specified delimiter, and returns the number of separate strings. The command returns 1 if the delimiter is not found.
If String begins or ends with the delimiter, the command counts the separate strings assuming a zero-length string ("") immediately before or after that delimiter.
Zero is returned if String is a zero-length string ("").
To obtain the separated strings, use the SeparateStr command.
To include n double quotation marks (") as characters in String, you must enter n*8 double quotation marks. However, if you specify 2 in the following registry, you can use n*2 double quotation marks instead of n*8:
- Registry key
HKEY_LOCAL_MACHINE\SOFTWARE\Hitachi\JP1/Script\SPTX
- Value name
ParseDQ
- Value datatype
-
REG_DWORD
- Value
-
0: If you are using quotation marks in a parameter string, the setting that allows you to specify n*2 double quotation marks (") is disabled (this is the default value).
1: If you are using quotation marks in a parameter string, the setting that allows you to specify n*2 double quotation marks (") is enabled.
To specify both 1 (see the SetGV, GetGV, and DeleteGV commands) and 2 as the value of this registry, type 3.
- When the setting takes effect
-
The setting takes effect the next time the script file is executed.
- Examples
' This code stores 3 in variable count1. Dim count1 count1 = SeparateStrCount ("JP1 Script 01-00,01-01", " ") ' This code stores 3 in variable count2. Dim count2, param param = """Code 100"" Price 300" count2 = SeparateStrCount (param, " ") ' This code stores 4 in variable count3. Dim count3 count3 = SeparateStrCount ("Code100;Code200;Code300;", ";")
- JP1/Script version
-
Supported from JP1/Script 05-00.