botserver/docs/src/chapter-05/keyword-last.md

843 B
Raw Blame History

LAST Keyword

Syntax

LAST "text"

Parameters

  • "text" A string expression from which the last word will be extracted.

Description

LAST returns the final whitespaceseparated token of the provided string. If the string is empty or contains only whitespace, the result is an empty string. This keyword is useful for retrieving the trailing part of a users input or any delimited text.

Example

SET command = LAST user_input
TALK "You entered the last word: " + command

If user_input is "search books about Rust", LAST returns "Rust".

Implementation Notes

  • The keyword splits the string on any whitespace (spaces, tabs, newlines) and returns the last element.
  • It does not modify the original string.
  • Caseinsensitive; the returned word preserves the original casing.