Difference between revisions of "ObjectType:binary"
Jump to navigation
Jump to search
(7 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | == | + | == Overview == |
+ | {{ObjectType-Vitals|binary|[[LavishScript]]|none|Same as '''Size'''|none|no|LSBinary *}} | ||
+ | Positions within a binary object are 1-based. | ||
== Members == | == Members == | ||
− | *[[ | + | *[[ObjectType:uint|uint]] '''Size''': Size of the buffer |
− | *[[ | + | *[[ObjectType:intptr|intptr]] '''Int['''#''']''': An int at byte position # of this buffer |
− | *[[ | + | *[[ObjectType:byteptr|byteptr]] '''Byte['''#''']''': A byte at position # of this buffer |
− | *[[ | + | *[[ObjectType:floatptr|floatptr]] '''Float['''#''']''': A float at byte position # of this buffer |
− | *[[ | + | *[[ObjectType:int64ptr|int64ptr]] '''Int64['''#''']''': An int64 at byte position # of this buffer |
− | *[[ | + | *[[ObjectType:string|string]] '''String['''#''']''': A string at byte position # of this buffer. NULL if the string is not null-terminated within the size of the buffer |
− | *[[ | + | *[[ObjectType:uintptr|uintptr]] '''Uint['''#''']''': A uint at byte position # of this buffer |
− | *[[ | + | *[[ObjectType:boolptr|boolptr]] '''Bool['''#''']''': A bool at byte position # of this buffer |
== Methods == | == 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 | *'''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 | *'''Copy['''buffer''','''#''']''': Copies # bytes from another buffer to position 1 of this buffer | ||
− | |||
− | |||
− | |||
== Examples == | == Examples == | ||
− | + | ;Example code | |
− | |||
− | ;Example | ||
function main() | function main() | ||
{ | { | ||
− | Declare Buffer | + | Declare Buffer binary |
Declare File file test.dat | Declare File file test.dat | ||
Line 48: | Line 45: | ||
File:Close | File:Close | ||
echo Closed | 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 Filename=${File.Path}${File.Filename} | ||
echo Opened Readonly=${File:Open[readonly](exists)} | echo Opened Readonly=${File:Open[readonly](exists)} | ||
Line 54: | Line 57: | ||
echo Null terminating... | echo Null terminating... | ||
Buffer.Byte[${File.Size}]:Set[0] | Buffer.Byte[${File.Size}]:Set[0] | ||
− | echo String=${Buffer.String[ | + | echo String=${Buffer.String[1]} |
File:Close | File:Close | ||
echo Closed | echo Closed | ||
Line 60: | Line 63: | ||
echo Filename=${File.Path}${File.Filename} | echo Filename=${File.Path}${File.Filename} | ||
echo Opened=${File:Open(exists)} | echo Opened=${File:Open(exists)} | ||
− | Buffer.Int[ | + | Buffer.Int[1]:Set[12345678] |
echo WriteBinary=${File:WriteBinary[Buffer,${File.Size}](exists)} | echo WriteBinary=${File:WriteBinary[Buffer,${File.Size}](exists)} | ||
File:Close | File:Close | ||
echo Closed | 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 | ||
+ | |||
== See Also == | == See Also == | ||
− | + | {{LavishScript:ObjectType}} | |
− | |||
− | |||
− |
Latest revision as of 16:30, 8 July 2018
Contents
Overview
binary | |
Defined By | LavishScript |
Inherits | none |
Reduces To | Same as Size |
Variable Object Type | none |
Uses Sub-Types | no |
C/C++ Type | LSBinary * |
Positions within a binary object are 1-based.
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
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[1]} File:Close echo Closed echo Filename=${File.Path}${File.Filename} echo Opened=${File:Open(exists)} Buffer.Int[1]: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
See Also
LavishScript Object Types
- Text
- string - mutablestring - unistring
- Numbers
- byte - float - float64 - int - uint - int64
- Boolean (TRUE/FALSE)
- bool
- Pointers
- boolptr - byteptr - floatptr - float64ptr - intptr - uintptr - int64ptr - rgbptr - stringptr
- Containers
- objectcontainer - array - index - collection - queue - stack - set - variablescope
- JSON
- jsonobject - jsonarray - jsonvaluecontainer - jsonvalue
- Iteration
- iterator - jsoniterator
- Date/Time
- time
- File Handling
- filepath - file - filelist - filelistentry
- Tasks
- lavishmachine - Accessed via the Top-Level Object LMAC
- task - tasklibrary - taskmanager - tasktype - taskpulseargs - elmactaskstate