The linerecordsplit command is used to break up a long string into its component parts based on the parameters you define. You can specify the parts by using the 'label' and 'length' option pair described below. This command is available in WS builds of 1.2.194.0 and above. The syntax is as follows.
var elementArr = linerecordsplit(z_string, [{"label":"NUMBERS", "length":10}, {"label":"ALPHABETS", "length":20}]);
The 'linerecordsplit' command takes the following options.
The label is always paired with a length. Together, they identify the parts that you will split the string into a well as the length of the component part that you will create when you split the string. You can either use a single entry format or an array. The two possible synatax options are shown below.
Single Entry{"label":"NAME1", "length":20}
Array
[{"label":"NAME1", "length":20}, {"label":"NAME2", "length":10}]
The length is always paired with a label. As such, they identify the parts that you will split the string into a well as the length of the component part that you will create when you split the string. You can either use a single entry format or an array. The two possible synatax options are shown below.
Single Entry{"label":"NAME1", "length":20}
Array
[{"label":"NAME1", "length":20}, {"label":"NAME2", "length":10}]
In the following example, we will split a string into its component parts using the 'linerecordsplit' command.
Create a string variable as shown below.
var z_string="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
Invoke the 'linerecordsplit' command by inputting the following code.
var elementArr = linerecordsplit(z_string, [{"label":"NUMBERS", "length":10}, {"label":"ALPHABETS", "length":20}]);
In your script, print out the new components of the orginal string as follows.
println(elementArr.NUMBERS); println(elementArr.ALPHABETS);
The results shoudl be as follows: