Platforms to show: All Mac Windows Linux Cross-Platform

Back to TXTRecordMBS class.

TXTRecordMBS.Bytes as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Network MBS Network Plugin 10.1 ✅ Yes ✅ Yes ❌ No ✅ Yes All
Allows you to retrieve a copy of to the raw bytes within a TXTRecord.
Example
dim t as new TXTRecordMBS

call t.SetValue "Hello", "World"

Returns a string with the raw bytes inside the TXTRecord which you can pass directly to DNSServiceRegisterMBS.Register() or to DNSServiceRegisterMBS.UpdateRecord().

TXTRecordMBS.ContainsKey(key as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Network MBS Network Plugin 10.1 ✅ Yes ✅ Yes ❌ No ✅ Yes All
Allows you to determine if a given TXT Record contains a specified key.
Example
dim t as new TXTRecordMBS

call t.SetValue "Hello", "World"

if t.ContainsKey("Hello") then
MsgBox "Hello found."
else
MsgBox "Hello not found -> bug."
end if

if t.ContainsKey("hallo") then
MsgBox "hallo found -> bug."
else
MsgBox "hallo not found."
end if

key: An ASCII string containing the key name.

Returns true if the TXT Record contains the specified key. Otherwise, it returns false.

See also:

TXTRecordMBS.Count as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Network MBS Network Plugin 10.1 ✅ Yes ✅ Yes ❌ No ✅ Yes All
Returns the number of keys stored in the TXT Record.
Example
dim t as new TXTRecordMBS

call t.SetValue "Hello1", "World1"
call t.SetValue "Hello2", "World2"
call t.SetValue "Hello3", "World3"

MsgBox str(t.Count)

See also:

TXTRecordMBS.KeyAtIndex(index as Integer) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Network MBS Network Plugin 10.1 ✅ Yes ✅ Yes ❌ No ✅ Yes All
Returns the key with the given index from the txt record.
Example
dim t as new TXTRecordMBS

call t.SetValue "Hello", "World"

MsgBox t.KeyAtIndex(0) +EndOfLine + t.ValueAtIndex(0)

index: the index you want in the range from zero to GetCount()-1.

It's also possible to iterate through keys in a TXT record by simply calling KeyAtIndex() repeatedly, beginning with index zero and increasing until lasterror is set to kErrorInvalid.

See also:

TXTRecordMBS.Length as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Network MBS Network Plugin 10.1 ✅ Yes ✅ Yes ❌ No ✅ Yes All
Allows you to determine the length of the raw bytes within a TXTRecord.
Example
dim t as new TXTRecordMBS

call t.SetValue "Hello1", "World1"
call t.SetValue "Hello2", "World2"
call t.SetValue "Hello3", "World3"

MsgBox str(t.Length) // shows 42

TXTRecordMBS.RemoveValue(key as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Network MBS Network Plugin 10.1 ✅ Yes ✅ Yes ❌ No ✅ Yes All
Removes a key from a TXTRecordRef. The "key" must be an ASCII string which exists in the TXTRecord.
Example
dim t as new TXTRecordMBS

call t.SetValue "Hello1", "World1"
call t.SetValue "Hello2", "World2"
call t.SetValue "Hello3", "World3"

t.RemoveValue "Hello2"

MsgBox t.Bytes

key: A key name which exists in the TXTRecord.

Lasterror is kErrorNoError on success or kErrorNoSuchKey if the "key" does not exist in the TXTRecord.

TXTRecordMBS.SetValue(key as string, value as string) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Network MBS Network Plugin 10.1 ✅ Yes ✅ Yes ❌ No ✅ Yes All
Adds a key (optionally with value) to a TXTRecordRef.
Example
dim t as new TXTRecordMBS

call t.SetValue "Hello1", "World1"
call t.SetValue "Hello2", "World2"
call t.SetValue "Hello3", "World3"

If the "key" already exists in the TXTRecord, then the current value will be replaced with the new value.

Keys may exist in four states with respect to a given TXT record:

  • Absent (key does not appear at all)
  • Present with no value ("key" appears alone)
  • Present with empty value ("key=" appears in TXT record)
  • Present with non-empty value ("key=value" appears in TXT record)

For more details refer to "Data Syntax for DNS-SD TXT Records" in

http://files.dns-sd.org/draft-cheshire-dnsext-dns-sd.txt

key: A string which only contains printable ASCII values (&h20-&h7E), excluding '=' (&h3D). Keys should be 8 characters or less.
value: Any binary value. For values that represent textual data, UTF-8 is STRONGLY recommended.

Returns kErrorNoError on success. Returns kErrorInvalid if the "key" string contains illegal characters. Returns kErrorNoMemory if adding this key would exceed the available storage.

The plugin currently does not create keys with empty value. If you need that, please email us.

TXTRecordMBS.Value(key as string) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Network MBS Network Plugin 10.1 ✅ Yes ✅ Yes ❌ No ✅ Yes All
Allows you to retrieve the value for a given key from a TXT Record.
Example
dim t as new TXTRecordMBS

call t.SetValue "Hello", "World"
MsgBox t.Value("Hello") // lookup value

key: The ASCII string containing the key name.

Returns an empty string if the key does not exist in this TXT record, or exists with no value (to differentiate between these two cases use ContainsKey()).

See also:

TXTRecordMBS.ValueAtIndex(index as Integer) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Network MBS Network Plugin 10.1 ✅ Yes ✅ Yes ❌ No ✅ Yes All
Returns the key with the given index from the txt record.
Example
dim t as new TXTRecordMBS

call t.SetValue "Hello", "World"

MsgBox t.KeyAtIndex(0) +EndOfLine + t.ValueAtIndex(0)

index: the index you want in the range from zero to GetCount()-1.

It's also possible to iterate through values in a TXT record by simply calling ValueAtIndex() repeatedly, beginning with index zero and increasing until lasterror is set to kErrorInvalid.

See also:

The items on this page are in the following plugins: MBS Network Plugin.


The biggest plugin in space...