Set.string

From AGI Wiki
Revision as of 20:07, 21 April 2019 by Andrew Korson (talk | contribs) (Created page with "The '''set.string''' command assigns the text of a message to a string. == Syntax == set.string(str sA, msg mB);<br /> set.string(str sA, "...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The set.string command assigns the text of a message to a string.

Syntax

set.string(str sA, msg mB);
set.string(str sA, "message text");
sA = mB;
sA = "message text";

Remarks

Strings are limited to 40 characters (including the null terminator). If the message text is longer than 40 characters, the string only uses the first 40. This is one of the few situations where AGI actually checks and prevents buffer overflow.

The number of strings available in AGI is 24 (s0 - s23), except for versions 2.089, 2.272 and 3.002.149, which have a limit of 12 (s0 - s11).

The very first string (s0) is reserved by AGI as the player input prompt.

Possible Errors

AGI does not check that sA is a valid string. If a value greater than the limit is used, AGI will write over areas of memory that contains game state data and the main program executable code. This will almost certainly crash AGI.

Example

Code:
set.string(s5, "a sample message");
s5 = "another sample message";

Technical Information

Required Interpreter Version: Available in all AGI versions.
Byte-Code Value: 114 (0x72 hex)

See Also

String Commands