REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 6-Feb-2009 Edit History  

REBOL 3 Datatypes: Pair!

Contents

Concept

A pair! datatype is used to indicate spatial coordinates, such as positions on a display. They are used for both positions and sizes. Pairs are used primarily in REBOL/View.

Format

A pair is specified as integers separated by an x character.

100x50

1024x800

-50x200

Creation

Use to-pair to convert block or string values into a pair datatype:

p: to-pair "640x480" 
probe p
640x480
p: to-pair [800 600] 
probe p
800x600

Related

Use pair? to determine whether a value is a pair! datatype:

probe pair? 400x200
true
probe pair? pair
true

Pairs can be used with most integer math operators:

100x200 + 10x20

10x20 * 2x4

100x30 / 10x3

100x100 * 3

10x10 + 3

Pairs can be viewed by their individual coordinates:

pair: 640x480
probe first pair
640
probe second pair
480

All pair values support the /x and /y refinements. These refinements allow the viewing and manipulation of individual pair coordinates.

Viewing individual coordinates:

probe pair/x
640
probe pair/y
480

Modifying individual coordinates:

pair/x: 800
pair/y: 600
probe pair
800x600


  TOC < Back Next > REBOL.com - WIP Wiki Feedback Admin