Core Function DllStructGetVars
From Sputnik Wiki
(Difference between revisions)
(→Example) |
m (1 revision) |
||
(6 intermediate revisions by one user not shown) | |||
Line 15: | Line 15: | ||
=== Return Value === | === Return Value === | ||
− | Success - Returns the array (hashmap name,key) with keys as the variable names with value as a | + | Success - Returns the array (hashmap name,key) with keys as the variable names with value as a 3 element array where first is the ubound of the array and second is total bytes used by the item and the third is the name of the struct that the item is an object of if this name is an empty string then the item is not a struct. |
Failure - Returns empty array. | Failure - Returns empty array. | ||
Line 21: | Line 21: | ||
=== Remarks === | === Remarks === | ||
− | + | If you get 0 on the array size it means its not an array!. | |
=== Example === | === Example === | ||
Line 29: | Line 29: | ||
$vlist = DLLStructGetVars($a); | $vlist = DLLStructGetVars($a); | ||
− | foreach($vlist as $Name | + | foreach($vlist as $Name => $vData) |
{ | { | ||
− | List( $UBound, $Bytes ) = $vData; | + | List( $UBound, $Bytes, $StructName ) = $vData; |
if($UBound) | if($UBound) | ||
println("DLLStruct item '$Name' has array size of '$UBound' and uses '$Bytes' byte(s) of ram"); | println("DLLStruct item '$Name' has array size of '$UBound' and uses '$Bytes' byte(s) of ram"); | ||
Line 39: | Line 39: | ||
// A more cool way | // A more cool way | ||
− | println("DLLStruct item 'test' has | + | println("DLLStruct item 'test' has UBound of '" . DLLStructGetVars($a)["test"][0] . "'"); |
println("DLLStruct item 'test' uses '" . DLLStructGetVars($a)["test"][1] . "' byte(s) of ram"); | println("DLLStruct item 'test' uses '" . DLLStructGetVars($a)["test"][1] . "' byte(s) of ram"); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Core Function]] | [[Category:Core Function]] |
Latest revision as of 12:38, 14 June 2015
DllStructGetVars( <dllstruct> )
Contents |
Description
Create an array of all items and their array size with total byte size
Parameters
dllstruct
The DLLStruct to use.
Return Value
Success - Returns the array (hashmap name,key) with keys as the variable names with value as a 3 element array where first is the ubound of the array and second is total bytes used by the item and the third is the name of the struct that the item is an object of if this name is an empty string then the item is not a struct.
Failure - Returns empty array.
Remarks
If you get 0 on the array size it means its not an array!.
Example
$a = DllStructCreate( "int var1;ubyte var2;int test[700];uint var3;char var4[128]"); $vlist = DLLStructGetVars($a); foreach($vlist as $Name => $vData) { List( $UBound, $Bytes, $StructName ) = $vData; if($UBound) println("DLLStruct item '$Name' has array size of '$UBound' and uses '$Bytes' byte(s) of ram"); else println("DLLStruct item '$Name' is not an array and uses '$Bytes' byte(s) of ram"); } // A more cool way println("DLLStruct item 'test' has UBound of '" . DLLStructGetVars($a)["test"][0] . "'"); println("DLLStruct item 'test' uses '" . DLLStructGetVars($a)["test"][1] . "' byte(s) of ram");