Core Function Lines

From Sputnik Wiki
Jump to: navigation, search
Lines( <expression> )

Contents

Description

Returns an array containing all the lines from a string.

Parameters

expression

The string to evaluate.

Return Value

Success: Returns array of all lines.

Failure: Returns empty array.

Remarks

None.

Example

Example of using it with a string

{ // \n seperation
	my $Count = 0;
	my $Text = "One\nTwo\nThree\nFour";
	foreach( Lines($Text) as $Line )
	{
		println("Line $Count : '$Line'");
		$Count++;
	}
}
{ // \r\n seperation
	my $Count = 0;
	my $Text = "One\r\nTwo\r\nThree\r\nFour";
	foreach( Lines($Text) as $Line )
	{
		println("Line $Count : '$Line'");
		$Count++;
	}
}
{ // \r seperation
	my $Count = 0;
	my $Text = "One\rTwo\rThree\rFour";
	foreach( Lines($Text) as $Line )
	{
		println("Line $Count : '$Line'");
		$Count++;
	}
}
{ // \n\r seperation
	my $Count = 0;
	my $Text = "One\n\rTwo\n\rThree\n\rFour";
	foreach( Lines($Text) as $Line )
	{
		println("Line $Count : '$Line'");
		$Count++;
	}
}

Example of using it with text from a file

my $Count = 0;
my $Text = FileLoad("Main.spk");
foreach( Lines($Text) as $Line )
{
	println("Line $Count : '$Line'");
	$Count++;
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox