Difference between revisions of "ObjectType:binary"

From Lavish Software Wiki
Jump to navigation Jump to search
 
Line 1: Line 1:
== Description ==
+
== Overview ==
 +
{{ObjectType-Vitals|binary|[[LavishScript]]|none|Same as '''Size'''|none|no|LSBinary *}}
 
Positions within a binary object are 1-based.
 
Positions within a binary object are 1-based.
  
 
== Members ==
 
== Members ==
*[[DataType:uint|uint]] '''Size''': Size of the buffer
+
*[[ObjectType:uint|uint]] '''Size''': Size of the buffer
*[[DataType:intptr|intptr]] '''Int['''#''']''': An int at byte position # of this buffer  
+
*[[ObjectType:intptr|intptr]] '''Int['''#''']''': An int at byte position # of this buffer  
*[[DataType:byteptr|byteptr]] '''Byte['''#''']''': A byte at position # of this buffer  
+
*[[ObjectType:byteptr|byteptr]] '''Byte['''#''']''': A byte at position # of this buffer  
*[[DataType:floatptr|floatptr]] '''Float['''#''']''': A float at byte position # of this buffer  
+
*[[ObjectType:floatptr|floatptr]] '''Float['''#''']''': A float at byte position # of this buffer  
*[[DataType:int64ptr|int64ptr]] '''Int64['''#''']''': An int64 at byte position # of this buffer  
+
*[[ObjectType:int64ptr|int64ptr]] '''Int64['''#''']''': An int64 at byte position # of this buffer  
*[[DataType: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: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
*[[DataType:uintptr|uintptr]] '''Uint['''#''']''': A uint at byte position # of this buffer  
+
*[[ObjectType:uintptr|uintptr]] '''Uint['''#''']''': A uint at byte position # of this buffer  
*[[DataType:boolptr|boolptr]] '''Bool['''#''']''': A bool 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
 
== Returns ==
 
Same as Size
 
  
 
== Examples ==
 
== Examples ==
Line 105: Line 103:
 
  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:ObjectType}}
 
 
[[Category:LavishScript]]
 
[[Category:LavishScript Data Types]]
 

Latest revision as of 16:30, 8 July 2018

Overview

Object Type Vitals
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