Core Function PTRRead
From Sputnik Wiki
(Difference between revisions)
(→Example) |
|||
(9 intermediate revisions by one user not shown) | |||
Line 14: | Line 14: | ||
==== type ==== | ==== type ==== | ||
+ | |||
The type of data to read | The type of data to read | ||
+ | |||
<pre> | <pre> | ||
[TYPE] [WHAT IT IS] | [TYPE] [WHAT IT IS] | ||
+ | r Raw bytes | ||
c ASCII char | c ASCII char | ||
C UNICODE char | C UNICODE char | ||
Line 29: | Line 32: | ||
f float | f float | ||
d double | d double | ||
+ | t pointer | ||
</pre> | </pre> | ||
+ | |||
+ | ==== offset ==== | ||
+ | |||
+ | Offset to add to the pointer. | ||
+ | |||
+ | |||
+ | ==== length ==== | ||
+ | |||
+ | Optional; Only valid if type is "r" this defines how many bytes to read. | ||
=== Return Value === | === Return Value === | ||
Line 35: | Line 48: | ||
Success: Returns the value requested or -1 if fail. | Success: Returns the value requested or -1 if fail. | ||
− | Failure: Returns | + | Failure: Returns null. |
=== Remarks === | === Remarks === |
Latest revision as of 09:58, 19 September 2015
PTRRead( <ptr>, <type>, <offset> )
Contents |
Description
Read data from a memory pointer optionally starting from a given index.
Parameters
ptr
The pointer to use.
type
The type of data to read
[TYPE] [WHAT IT IS] r Raw bytes c ASCII char C UNICODE char b unsigned byte B signed byte s signed int16 i signed int32 l signed int64 S unsigned int16 I unsigned int32 L unsigned int64 f float d double t pointer
offset
Offset to add to the pointer.
length
Optional; Only valid if type is "r" this defines how many bytes to read.
Return Value
Success: Returns the value requested or -1 if fail.
Failure: Returns null.
Remarks
None.
Example
$PTR = Alloc(300); PTRWrite($PTR, "f", 0, 133.77); PTRWrite($PTR, "l", 4, 777); PTRWrite($PTR, "i", 12, 1221); Println( PTRRead($PTR, "f", 0) ); Println( PTRRead($PTR, "l", 4) ); Println( PTRRead($PTR, "i", 12) ); Free($PTR);