Core Function DecPad
From Sputnik Wiki
(Difference between revisions)
(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> | ||
− | + | DecPad( <expression>, <count> ) | |
</pre> | </pre> | ||
=== Description === | === Description === | ||
− | + | Pads numeric string to a given number of chars (Filling in the gap with zeros). | |
=== Parameters === | === Parameters === | ||
− | ==== | + | ==== expression ==== |
− | The | + | The expression to pad. |
− | ==== | + | ==== count ==== |
− | The | + | The length of the final string (Equal to or higher than current length). |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
=== Return Value === | === Return Value === | ||
− | Success: Returns | + | Success: Returns padded string. |
− | Failure: Returns | + | Failure: Returns unpadded string. |
=== Remarks === | === Remarks === | ||
Line 34: | Line 30: | ||
<syntaxhighlight lang="sputnik"> | <syntaxhighlight lang="sputnik"> | ||
− | $ | + | $binary = Pack("ifz0", (int)100, (float)777.42, "Hello"); |
− | + | $i = 0; | |
− | + | foreach( $binary as $item ) | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
{ | { | ||
− | println(" | + | 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++; }