User Tools

Site Tools


Sidebar

Passage markup

basics

coding

extra

list

section

whitespace

Macros

basics

colour

data structure

date and time

game state

live

maths

number

revision

saving

showing and hiding

string

styling

url

deprecated

Types of data

Special keywords

Special passage tags

harlowe:move

(move: VariableToValue) → Instant

A variant of (put:) that deletes the source value after copying it - in effect moving the value from the source to the destination.

Example usage:

(move: $arr's 1st into $var)

Rationale:

You'll often use data structures such as array or datamap as storage for values that you'll only use once, such as a list of names to print out. When it comes time to use them, you can remove it from the structure and retrieve it in one go.

Details:

You must use the into keyword, like (put:), with this macro. This is because, like (put:), the destination of the value is on the right, whereas the source is on the left.

You can also set multiple variables in a single (move:) by separating each VariableToValue with commas: (move: $a's 1st into $b, $a's 2nd into $c), etc.

If the value you're accessing cannot be removed - for instance, if it's an array's length - then an error will be produced.

See also:

harlowe/move.txt · Last modified: 2017/10/10 00:39 (external edit)