Platforms to show: All Mac Windows Linux Cross-Platform

Back to TXTRecordMBS class.

TXTRecordMBS.ContainsKey(txtRecord as string, key as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared 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"

dim s as string = t.Bytes // copy record to string

// now search in that string:
if TXTRecordMBS.ContainsKey(s, "Hello") then
MsgBox "Hello found."
else
MsgBox "Hello not found -> bug."
end if

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

txtRecord: The txt record to search in as a string.
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(txtRecord as string) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared 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"

dim s as string = t.Bytes // copy record

// now count in that record
MsgBox str(TXTRecordMBS.Count(s))

See also:

TXTRecordMBS.KeyAtIndex(txtRecord as string, index as Integer) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared 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"

dim s as string = t.Bytes // copy record to string

// now search in that string:
MsgBox TXTRecordMBS.KeyAtIndex(s,0) +EndOfLine + TXTRecordMBS.ValueAtIndex(s,0)

txtRecord: The txt record to search in as a string.
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.Value(txtRecord as string, key as string) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared 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"

dim s as string = t.bytes
MsgBox TXTRecordMBS.Value(s, "Hello") // lookup value

txtRecord: Pointer to the received TXT Record bytes.
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(txtRecord as string, index as Integer) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared 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"

dim s as string = t.Bytes // copy record to string

// now search in that string:
MsgBox TXTRecordMBS.KeyAtIndex(s,0) +EndOfLine + TXTRecordMBS.ValueAtIndex(s,0)

txtRecord: The txt record to search in as a string.
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 GetValueAtIndex() 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...