Writes a string into the blob
Device + Agent
Name | Type | Description |
---|---|---|
string | String |
Any string
|
Nothing
This method writes the passed string into the target blob, placing the string’s characters at the current position of the target’s read/write pointer. The pointer’s location can be determined using the tell() method and set using the seek() method.
// 'errorMessages' is an array of strings | |
// Pack these error strings into a blob | |
local errorMessages = ["File not found", "read/write failure", "IO error"]; | |
local errorStringBlob = blob(); | |
foreach (index, string in errorMessages) { | |
// Write the single-byte message code in the first byte of the record | |
errorStringBlob.writen(index, 'b'); | |
// Write the message length in the second byte of the record | |
errorStringBlob.writen(string.len(), 'b'); | |
// Write the string itself to complete the record | |
errorStringBlob.writestring(string); | |
} |