Difference between revisions of "ObjectType:binary"
Jump to navigation
Jump to search
Line 20: | Line 20: | ||
== Examples == | == Examples == | ||
+ | |||
+ | ;Example Code | ||
+ | function main() | ||
+ | { | ||
+ | Declare Buffer buffer | ||
+ | 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 | ||
+ | |||
+ | 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 | ||
+ | } | ||
== See Also == | == See Also == | ||
* [[LavishScript:Data Types|Data Types]] | * [[LavishScript:Data Types|Data Types]] |
Revision as of 17:42, 29 August 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 buffer 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 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 }