Difference between revisions of "ObjectType:binary"
Jump to navigation
Jump to search
Line 22: | Line 22: | ||
function main() | function main() | ||
{ | { | ||
− | Declare Buffer | + | Declare Buffer binary |
Declare File file test.dat | Declare File file test.dat | ||
Line 104: | Line 104: | ||
WriteBinary=TRUE | WriteBinary=TRUE | ||
Closed | Closed | ||
+ | |||
+ | == Operates On == | ||
+ | <tt>LSBinary *</tt> | ||
+ | |||
+ | <small>See lstype.h</small> | ||
+ | |||
== See Also == | == See Also == | ||
* [[LavishScript:Data Types|Data Types]] | * [[LavishScript:Data Types|Data Types]] |
Revision as of 22:11, 15 December 2005
Description
Members
- uint Size: Size of the buffer
- intptr Int[#]: An int at byte position # of this buffer
- byteptr Byte[#]: A byte at position # of this buffer
- floatptr Float[#]: A float at byte position # of this buffer
- int64ptr Int64[#]: An int64 at byte position # of this buffer
- string String[#]: A string at byte position # of this buffer. NULL if the string is not null-terminated within the size of the buffer
- uintptr Uint[#]: A uint at byte position # of this buffer
- boolptr Bool[#]: A bool at byte position # of this buffer
Methods
- Resize[#]: Resizes the buffer to this many bytes. Minimum 1, maximum 4194304 (4MB) -- if you need larger for some reason, please let us know. This is a sanity check
- Copy[buffer,#]: Copies # bytes from another buffer to position 1 of this buffer
Returns
Same as Size
Examples
- Example code
function main()
{ Declare Buffer binary Declare File file test.dat echo Filename=${File.Path}${File.Filename} echo Opened=${File:Open(exists)} echo Write=${File:Write["Line One...\n"](exists)} echo Position=${File.Position} echo Write=${File:Write["Line Two!\n"](exists)} echo Position=${File.Position} echo Truncate=${File:Truncate(exists)} echo Size=${File.Size} File:Close echo Closed echo Filename=${File.Path}${File.Filename} echo Opened Readonly=${File:Open[readonly](exists)} echo Write=${File:Write["Overwriting Line One?\n"](exists)} echo Position=${File.Position} echo Read=${File.Read} echo Position=${File.Position} echo Read=${File.Read} echo Position=${File.Position} File:Close echo Closed declare FP filepath "c:/program files/innerspace/scripts" echo FileExists[test.iss] = ${FP.FileExists[test.iss]} echo Path = ${FP.Path} echo PathExists = ${FP.PathExists} echo AbsolutePath = ${FP.AbsolutePath} echo Filename=${File.Path}${File.Filename} echo Opened Readonly=${File:Open[readonly](exists)} echo ReadBinary=${File.ReadBinary[Buffer,${File.Size}]} echo Null terminating... Buffer.Byte[${File.Size}]:Set[0] echo String=${Buffer.String[0]} File:Close echo Closed echo Filename=${File.Path}${File.Filename} echo Opened=${File:Open(exists)} Buffer.Int[0]:Set[12345678] echo WriteBinary=${File:WriteBinary[Buffer,${File.Size}](exists)} File:Close echo Closed }
- Output
Filename=C:/Program Files/InnerSpace/test.dat Opened=TRUE Write=TRUE Position=12 Write=TRUE Position=22 Truncate=TRUE Size=22 Closed Filename=C:/Program Files/InnerSpace/test.dat Opened Readonly=TRUE Write=NULL Position=0 Read=Line One... Position=12 Read=Line Two! Position=22 Closed FileExists[test.iss] = TRUE Path = c:/program files/innerspace/scripts PathExists = TRUE AbsolutePath = c:/program files/innerspace/scripts Filename=C:/Program Files/InnerSpace/test.dat Opened Readonly=TRUE ReadBinary=22 Null terminating... String=NULL Closed Filename=C:/Program Files/InnerSpace/test.dat Opened=TRUE WriteBinary=TRUE Closed
Operates On
LSBinary *
See lstype.h