Home Contents | # mtd16:get | Mtd16 | Core4 Lua Commands

## SYNOPSIS

1. val = msg:get(tag [, default])
2. val = msg:getBool(tag [, default])
3. val = msg:getNumber(tag [, default])
4. val = msg:getString(tag [, default])
5. val = msg:getDate(tag [, default])
6. val = msg:getTime(tag [, default])
7. val = msg:getDateTime(tag [, default])
8. val = msg:getNetworkAddress(tag [, default])
9. val = msg:getMessage(tag)
10. valL, valH = msg:getInt64(tag [, defaultL, defaultH])

## DESCRIPTION

Retrieve the value of the data field tagged tag from msg. If tag is not a number, it is looked up in the table mtd16.lutTag to get its numerical value.

If the message does not contain a value for the tag, the default value is returned instead. The default for default is nil.

## RETURN VALUE

The function msg:get() returns the value as a type that is most suitable for the type indicated by tag.

The functions msg:getBool(), msg:getNumber() and msg:getString() etc... forcefully return their specifc datatype or nil if this is not possible.

The function msg:getNetworkAddress() supports only IPv4 addresses. It returns an IP address in dotted quad notation on success.

The function msg:getMessage() returns nested contents as a message instance.

All functions return nil (or default, if given) if the tag does not exist in msg. Note that there is no support for default in msg:getMessage().

Using getInt64(), it is possible to read a 64-bit number, by using two 32-bit variables. With that function, everything is doubled: There are two optional default variables, it returns two 32-bit integer values on success or two nil values on failure.

## ERRORS

Raises an error if msgCode could not be converted to a number by looking it up in mtd16.lutTag.

## EXAMPLE

> > >
msg = mtd16.new(0xF00F) msg:append(0x3001, "FNORD!") print(msg:get(0x3001))
FNORD!

## NOTES

The function mtd16:getInt64() first appeared in SDK 2.0.2.

## SEE ALSO

#mtd16, mtd16.answerCode, mtd16.fromData, mtd16.fromText, mtd16.isNestedTag, mtd16.lutType, mtd16.new, mtd16.tagCode, mtd16.tagName, mtd16.tagNumber, mtd16.tagType, mtd16:append, mtd16:appendMessageCode, mtd16:contains, mtd16:isEmpty, mtd16:isValid, mtd16:messageCode, mtd16:nextMessageCode, mtd16:pairs, mtd16:rewind, mtd16:tags, mtd16:toData, mtd16:toText, mtd16:trace, tostring(mtd16)