bored script methods reference
TRANSCRIPT
8/10/2019 Bored Script Methods Reference
http://slidepdf.com/reader/full/bored-script-methods-reference 1/8
(Created using Arbed's "Extract API" operation)
//// Basic methods for all scripts://
Class TmplScriptContext
Sub Assert(cond as Boolean, msg as String)Aborts the script with an error msg if cond=false
Sub Beep()Sounds the beep
Function BitAnd(a as Int64, b as Int64) as Int64Performs a bitwise 'and' operation
Function Container_BlockCount() as Int64Returns the number of blocks of the current container
Function Container_BlockSize() as Int64Returns the blocksize in bytes of the current container
Function Container_Description() as String
Returns a user-readable description of the current container
Function Container_ReadBlock(blkNum as Int64) as BooleanReads a block of the current containerReturns true on success, false when unreadable or blkNum out of
range
Function Container_ReadBlock(blkNum as Int64, blockSize as Integer) as Boolean
Reads a block from the current container, using the givenblock size for size of data and for block numbering.Returns true on success, false when unreadable or blkNum out of
range
Sub Container_SetBlockSize(blocksize as Integer)Sets the current container's block size
Function CurrentBlockNumber() as Int64Returns the current block number within the current container
Function CurrentPhysByteOffset() as Int64Returns the current block's byte offset relative to start of the
disk
Function CurrentStructLabel() as StringReturns the label (name) of the currently used templates structu
re
Function CurrentStructOffset() as IntegerReturns the byte offset for the current structure's start within
the current block
Function CurrentTemplate() as StringReturns the name (ID) of the currently set template, or an empty
string if none is set
8/10/2019 Bored Script Methods Reference
http://slidepdf.com/reader/full/bored-script-methods-reference 2/8
Function Data_ByteSum(ofs as Integer, len as Integer) as IntegerReturns a simple checksum of the given range within the current
scope(Scope being the current structure in which the script is used)
Function Data_ByteSum(ofs as Integer, len as Integer, scope as Integer)as Integer
Returns a simple checksum of the given range within the desiredscope
Possible values of scope:0: current structure-1: template-2: entire block>0: parent level from current structure
Function Data_cstring(ofs as Integer, fieldsize as Integer) as StringReturns a 0-terminated string from the given range within the cu
rrent scope
Function Data_cstring(ofs as Integer, fieldsize as Integer, scope as Integer) as String
Returns a 0-terminated string from the given range within the desired scope (see above)
Function Data_cstrlen(ofs as Integer) as IntegerReturns the length of the 0-terminated string at the given offset within the current scope
Function Data_cstrlen(ofs as Integer, fieldsize as Integer) as IntegerReturns the length of the 0-terminated string at the given range
within the current scope
Function Data_cstrlen(ofs as Integer, fieldsize as Integer, scope as Integer) as Integer
Returns the length of the 0-terminated string at the given range within the desired scope
Function Data_dstring(ofs as Integer, fieldsize as Integer) as StringReturns a UDF "dstring" from the given range within the currentscope
Function Data_dstring(ofs as Integer, fieldsize as Integer, scope as Integer) as String
Returns a UDF "dstring" from the given range within the desiredscope
Function Data_int16be(ofs as Integer) as Integer
Function Data_int16be(ofs as Integer, scope as Integer) as Integer
Function Data_int16le(ofs as Integer) as Integer
Function Data_int16le(ofs as Integer, scope as Integer) as Integer
Function Data_int32be(ofs as Integer) as Integer
Function Data_int32be(ofs as Integer, scope as Integer) as Integer
Function Data_int32le(ofs as Integer) as Integer
8/10/2019 Bored Script Methods Reference
http://slidepdf.com/reader/full/bored-script-methods-reference 3/8
Function Data_int32le(ofs as Integer, scope as Integer) as Integer
Function Data_int64be(ofs as Integer) as Int64
Function Data_int64be(ofs as Integer, scope as Integer) as Int64
Function Data_int64le(ofs as Integer) as Int64
Function Data_int64le(ofs as Integer, scope as Integer) as Int64
Function Data_int8(ofs as Integer) as Integer
Function Data_int8(ofs as Integer, scope as Integer) as Integer
Function Data_pstring(ofs as Integer, fieldsize as Integer) as StringReturns a pascal string (first byte specifies length) from the g
iven range within the current scope
Function Data_pstring(ofs as Integer, fieldsize as Integer, scope as Integer) as String
Returns a pascal string (first byte specifies length) from the given range within the desired scope
Function Data_size() as Integer
Returns the current struct's maximum size
Function Data_string(ofs as Integer, fieldsize as Integer) as StringReturns a string from the given range within the current scope
Function Data_string(ofs as Integer, fieldsize as Integer, scope as Integer) as String
Returns a string from the given range within the desired scope
Function Data_string16(ofs as Integer, fieldsize as Integer) as StringReturns a UTF-16 string from the given range within the current
scope
Function Data_string16(ofs as Integer, fieldsize as Integer, scope as Integer) as StringReturns a UTF-16 string from the given range within the desired
scope
Function Data_uint16be(ofs as Integer) as Integer
Function Data_uint16be(ofs as Integer, scope as Integer) as Integer
Function Data_uint16le(ofs as Integer) as Integer
Function Data_uint16le(ofs as Integer, scope as Integer) as Integer
Function Data_uint32be(ofs as Integer) as Int64
Function Data_uint32be(ofs as Integer, scope as Integer) as Int64
Function Data_uint32le(ofs as Integer) as Int64
Function Data_uint32le(ofs as Integer, scope as Integer) as Int64
Function Data_uint64be(ofs as Integer) as UInt64
8/10/2019 Bored Script Methods Reference
http://slidepdf.com/reader/full/bored-script-methods-reference 4/8
8/10/2019 Bored Script Methods Reference
http://slidepdf.com/reader/full/bored-script-methods-reference 5/8
Sub Error(msg as String)Aborts the script with the given error message
Function GMTOffsetInHours() as DoubleReturns a fractional hour value specifying the GMT offset on the
current OS
Function GetDateFromMacSeconds(seconds as Int64, ByRef year as Integer,ByRef month as Integer, ByRef day as Integer) as Double
Returns the fractional hour of day along with setting passed year, month and day for
a given value representing the Macintosh 32 bit datetime value
Function GetDateFromUnixEpoch(seconds as Int64, ByRef year as Integer, ByRef month as Integer, ByRef day as Integer) as Double
Returns the fractional hour of day along with setting passed year, month and day for
a given value representing the UNIX epoch 32 bit datetime value
Function HasProp(name as String) as BooleanReturns true if the given script-property exists (i.e. if it has
been set earlier)
Function HexStr(i as Int64) as String
Returns the hexadecimal representation of the given integer number.
Function HexStr(i as Int64, width as Integer) as StringReturns the hexadecimal representation of the given integer numb
er.'width' is the minimal amount of characters to return, left-padd
ed byzeros as necessary.
Function IntStr(i as Int64) as StringReturns the textual representation of the given integer number
Function IntStr(i as Int64, width as Integer) as StringReturns the textual representation of the given integer number.'width' specifies the minimal number of chars, padding the numbe
rwith spaces on the left as needed.
Function IntStr0(i as Int64, width as Integer) as StringReturns the textual representation of the given integer number.'width' specifies the minimal number of chars, padding the numbe
rwith zeros ("0") on the left as needed.
Function IntVal(v as String) as Int64
Returns the integer value of the given textual representation of a number.
Returns 0 if the text does not start with a number.
Function IsValidTemplate() as BooleanReturns true if the currently set template (see SetTemplate) is
validfor the currently block.
Function LastBlockNumber() as Int64
8/10/2019 Bored Script Methods Reference
http://slidepdf.com/reader/full/bored-script-methods-reference 6/8
Returns the number of blocks of the current container minus 1.
Sub PopState()Resets the Template or Struct that was previouslysaved by a call to PushState
Function PropInt(name as String) as Int64Returns the integer value of the given script-property.The script will abort with an error if the script-propertydoes not exist.
Sub PropInt(name as String, assigns val as Int64)Stores the integer value for the given script-property.
Function PropInt(name as String, default as Int64) as Int64Returns the integer value of the given script-propertyIf the script-property does not exist, the passed default valuewill be returned.
Function PropRetrieveBlock(name as String) as BooleanReloads a previously stored block from the named script-propertyReturns false if the script-property does not exist
Sub PropStoreBlock(name as String)
Stores the current block under the named script-property
Function PropStr(name as String) as StringReturns the textual value of the given script-property.The script will abort with an error if the script-propertydoes not exist.
Sub PropStr(name as String, assigns val as String)Stores the textual value for the given script-property.
Function PropStr(name as String, default as String) as StringReturns the textual value of the given script-property.If the script-property does not exist, the passed default value
will be returned.
Sub PushState()Saves the currently active Template or Struct so that youcan set a different one and later call PopState later to goback the the previous one.
Function Remainder(divident as Int64, divisor as Int64) as Int64Returns the remainder of the given division operands.
Function SequenceNumber(parentLevel as Integer = 0) as IntegerReturns the current sequence (or array) number if thecurrent element part of a sequence.
Returns -1 otherwise.
Sub SetStruct(structName as String, ofs as Integer)Sets the given struct to be used at the given offet within the c
urrent block.This is relevant for the use of the Elem... methods.
Sub SetStruct(structName as String, ofs as Integer, maxSize as Integer)Sets the given struct to be used at the given offet within the c
urrent block,
8/10/2019 Bored Script Methods Reference
http://slidepdf.com/reader/full/bored-script-methods-reference 7/8
and with the given maximum size in bytes.This is relevant for the use of the Elem... methods.
Sub SetTemplate(tmplName as String)Sets the given template to be used with the current block (at of
fset 0).This is relevant for the use of the Elem... and the IsValidTempl
ate methods.
Sub SetTemplate(tmplName as String, ofs as Integer)Sets the given template to be used at the given offet within the
current block.This is relevant for the use of the Elem... and the IsValidTempl
ate methods.
Function ShiftLeft(n as Int64, shifts as Integer) as Int64Returns n shifted left (up) by the given number in "shifts"
Function ShiftRight(n as Int64, shifts as Integer) as Int64Returns n shifted right (down) by the given number in "shifts"
Function SizeStr(n as Int64) as StringDescribes the number in a compact format using kB/MB/GB
//// Additional methods for scan scripts://
Class ScanScriptContext
Sub AbortScan()Stops the scan process
Function Container_WriteBlock(journaled as Boolean) as BooleanWrites the current block back to disk.journaled: true -> writes journal file so that change can be und
one by user
Function Container_WriteBlock(blkNum as Int64, journaled as Boolean) asBoolean
Writes the current block to the specifed block addressjournaled: true -> writes journal file so that change can be und
one by user
Sub Data_ClearBlock()Fills the the current block with zero bytes
Function EnableWriting(askUser as Boolean) as BooleanEnables writing on the current disk.
Does nothing if writing is already enabled.if "askUser" is true, the user has to confirm.Returns false if writing was not enabled.
Function FinishingBlockNumber() as Int64Returns the block number at which the scan ended
Function HasBeenAborted() as BooleanReturns true only during the finishing call, and only if thescript has been aborted by a call to AbortScan, Error, a failed
8/10/2019 Bored Script Methods Reference
http://slidepdf.com/reader/full/bored-script-methods-reference 8/8
Assert or due to some other error condition.
Function IsFinishingCall() as BooleanReturns true when the script gets called for the last timeof the scan process, after all blocks have been handled,and also after the process has been aborted (can be testedwith the 'HasBeenAborted' method).
Function IsFirstCall() as BooleanReturns true for the first time the script gets called during a
scan process
Sub LogBlock(blkNum as Int64, msg as String)Adds a new row to a special window containing block numbers with
short descriptions.Double clicking a row will open the related block in the Block V
iewer
Sub LogSetFilename(name as String)Specifies log file name. If a file already exists, new log lines
will be appended to it
Sub LogSetFilename_ReplacingExisting(name as String)Specifies log file name. If a file already exists there, it will
be replaced
Sub LogWriteLine(line as String)Writes a line of text to the log file