Core Function DecPad

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "<pre> Contains( <string>, <substring>, <casesense>) </pre> === Description === Check if string contains a sub string. === Parameters === ==== string ==== The string to searc...")
 
 
Line 1: Line 1:
 
<pre>
 
<pre>
Contains( <string>, <substring>, <casesense>)
+
DecPad( <expression>, <count> )
 
</pre>
 
</pre>
  
 
=== Description ===
 
=== Description ===
  
Check if string contains a sub string.
+
Pads numeric string to a given number of chars (Filling in the gap with zeros).
  
 
=== Parameters ===
 
=== Parameters ===
  
==== string ====
+
==== expression ====
  
The string to search.
+
The expression to pad.
  
==== substring ====
+
==== count ====
  
The substring to search for
+
The length of the final string (Equal to or higher than current length).
 
+
==== casesense ====
+
 
+
Optional; If this is above 0 the function will use case insensitive search
+
  
 
=== Return Value ===
 
=== Return Value ===
  
Success: Returns 1.
+
Success: Returns padded string.
  
Failure: Returns 0.
+
Failure: Returns unpadded string.
  
 
=== Remarks ===
 
=== Remarks ===
Line 34: Line 30:
  
 
<syntaxhighlight lang="sputnik">
 
<syntaxhighlight lang="sputnik">
$val = "The fox";
+
$binary = Pack("ifz0", (int)100, (float)777.42, "Hello");
 
+
$i = 0;
// Regular and case sensitive
+
foreach( $binary as $item )
If( Contains($val, "fox") )
+
{
+
println("It contains fox");
+
}
+
Else
+
{
+
println("It does not fox");
+
}
+
 
+
// Case insensitive
+
If( Contains($val, "FOX", 1) )
+
{
+
println("It contains fox");
+
}
+
Else
+
 
{
 
{
println("It does not fox");
+
println(  
 +
"Index '" . DecPad($i, 4) . "' " .
 +
"Dec '$item' " . 
 +
"Hex '" . Hex($item) . "' " .
 +
"Char '" . Chr($item) . "'"
 +
);
 +
$i++;
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:Core Function]]
 
[[Category:Core Function]]

Latest revision as of 11:38, 2 December 2011

DecPad( <expression>, <count> )

Contents

Description

Pads numeric string to a given number of chars (Filling in the gap with zeros).

Parameters

expression

The expression to pad.

count

The length of the final string (Equal to or higher than current length).

Return Value

Success: Returns padded string.

Failure: Returns unpadded string.

Remarks

None.

Example

$binary = Pack("ifz0", (int)100, (float)777.42, "Hello");
$i = 0;
foreach( $binary as $item )
{
	println( 
			"Index '" . DecPad($i, 4) . "' " . 
			"Dec '$item' " .  
			"Hex '" . Hex($item) . "' " . 
			"Char '" . Chr($item) . "'"
			);
	$i++;
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox