Function Dictionary Generated by REBOL/View. Updated as of 9-May-2001 17:31:51 Copyright 2001 REBOL Technologies. All rights reserved. REBOL and its logo are trademarks of REBOL Technologies
Contents All Functions *
**
+
-
/
//
=
?
??
about
abs
absolute
add
alert
alias
all
alter
and
any
any-block?
any-function?
any-string?
any-type?
any-word?
append
arccosine
arcsine
arctangent
array
ask
at
back
binary?
bind
bitset?
block?
break
browse
build-tag
caret-to-offset
catch
center-face
change
change-dir
char?
charset
checksum
choose
clean-path
clear
clear-fields
close
comment
complement
compose
compress
confirm
connected?
context
copy
cosine
datatype?
date?
debase
decimal?
decode-cgi
decompress
dehex
delete
detab
difference
dir?
dirize
disarm
dispatch
divide
do
do-events
does
echo
either
email?
empty?
enbase
entab
equal?
error?
even?
event?
exclude
exists?
exit
exp
extract
fifth
file?
find
first
flash
focus
for
forall
foreach
forever
form
forskip
found?
fourth
free
func
function
function?
get
get-word?
greater-or-equal?
greater?
halt
has
hash?
head
head?
help
hide
hide-popup
if
image?
import-email
in
in-window?
index?
info?
inform
input
input?
insert
integer?
intersect
issue?
join
last
launch
layout
length?
lesser-or-equal?
lesser?
library?
license
list-dir
list?
lit-path?
lit-word?
load
load-image
load-prefs
load-thru
log-10
log-2
log-e
logic?
loop
lowercase
make
make-dir
make-face
max
maximum
min
minimum
modified?
mold
money?
multiply
native?
negate
negative?
next
none?
not
not-equal?
now
number?
object?
odd?
offset-to-caret
offset?
op?
open
or
pair?
paren?
parse
parse-email-addrs
parse-header
parse-header-date
parse-xml
path?
pick
poke
port?
positive?
power
prin
print
probe
protect
protect-system
query
quit
random
read
read-io
read-net
read-thru
recycle
reduce
refinement?
reform
rejoin
remainder
remold
remove
rename
repeat
repend
replace
request
request-color
request-date
request-download
request-file
request-list
request-pass
request-text
resend
return
reverse
routine?
same?
save
script?
second
secure
select
send
series?
set
set-net
set-path?
set-word?
show
show-popup
sine
size-text
size?
skip
sort
source
span?
split-path
square-root
strict-equal?
strict-not-equal?
string?
struct?
stylize
subtract
switch
tag?
tail
tail?
tangent
third
throw
throw-on-error
time?
to
to-binary
to-bitset
to-block
to-char
to-date
to-decimal
to-email
to-event
to-file
to-get-word
to-hash
to-hex
to-idate
to-image
to-integer
to-issue
to-list
to-lit-path
to-lit-word
to-logic
to-money
to-none
to-pair
to-paren
to-path
to-refinement
to-set-path
to-set-word
to-string
to-tag
to-time
to-tuple
to-url
to-word
trace
trim
try
tuple?
type?
unfocus
union
unique
unprotect
unset
unset?
until
unview
update
upgrade
uppercase
url?
usage
use
value?
view
wait
what
what-dir
while
within?
word?
write
write-io
xor
zero?
Comparison Functions
=
equal?
greater-or-equal?
greater?
lesser-or-equal?
lesser?
not-equal?
same?
strict-equal?
strict-not-equal?
in
Context Functions alias
bind
context
get
set
unset
use
value?
all
any
break
catch
compose
disarm
dispatch
do
do-events
does
either
exit
for
forall
foreach
forever
forskip
func
function
halt
has
if
launch
loop
next
quit
reduce
repeat
return
secure
switch
throw
throw-on-error
try
until
wait
while
Control Functions
Debug Functions ??
probe
trace
Help Functions ?
about
comment
help
license
probe
source
trace
usage
what
all
and
any
complement
found?
not
or
random
xor
*
**
+
-
/
//
abs
absolute
add
and
arccosine
arcsine
arctangent
complement
cosine
divide
even?
exp
log-10
log-2
log-e
max
maximum
min
minimum
multiply
negate
negative?
not
odd?
or
positive?
power
random
remainder
Logic Functions
Math Functions
sine
square-root
subtract
tangent
xor
append
change
clear
insert
remove
replace
reverse
sort
uppercase
ask
change-dir
clean-path
close
confirm
connected?
delete
dir?
dirize
dispatch
do
echo
exists?
info?
input
input?
list-dir
load
load-thru
make-dir
modified?
open
pick
poke
prin
print
query
read
read-io
read-net
read-thru
rename
resend
save
script?
secure
send
set-net
size?
split-path
update
wait
what-dir
write
write-io
append
array
at
back
change
clear
copy
difference
empty?
exclude
extract
fifth
find
first
found?
fourth
free
head
head?
index?
insert
intersect
join
last
length?
load
offset?
parse
pick
poke
random
rejoin
remove
repend
replace
reverse
second
select
skip
sort
switch
tail
tail?
third
union
charset
difference
exclude
extract
intersect
union
unique
zero?
Modify Functions
Port Functions
Series Functions
unique
Set Functions
String Functions build-tag
checksum
clean-path
compress
debase
decode-cgi
decompress
dehex
detab
dirize
enbase
entab
form
import-email
lowercase
mold
parse-email-addrs
parse-header
parse-header-date
parse-xml
reform
rejoin
remold
split-path
trim
browse
now
protect
protect-system
recycle
unprotect
upgrade
uppercase
System Functions
Tuple Functions pick
poke
Type Functions any-block?
any-function?
any-string?
any-type?
any-word?
binary?
bitset?
block?
char?
datatype?
date?
decimal?
email?
error?
event?
file?
function?
get-word?
hash?
image?
integer?
issue?
library?
list?
lit-path?
lit-word?
logic?
make
money?
native?
none?
number?
object?
op?
pair?
paren?
path?
port?
refinement?
routine?
series?
set-path?
set-word?
string?
struct?
tag?
time?
to
to-binary
to-bitset
to-block
to-char
to-date
to-decimal
to-email
to-event
to-file
to-get-word
to-hash
to-hex
to-idate
to-image
to-integer
to-issue
to-list
to-lit-path
to-lit-word
to-logic
to-money
to-none
to-pair
to-paren
to-path
to-refinement
to-set-path
to-set-word
to-string
to-tag
to-time
to-tuple
to-url
to-word
tuple?
type?
unset?
url?
word?
View Functions alert
caret-to-offset
center-face
choose
clear-fields
do-events
flash
focus
hide
hide-popup
in-window?
inform
layout
load-image
load-prefs
make-face
offset-to-caret
request
request-color
request-date
request-download
request-file
request-list
request-pass
request-text
show
show-popup
size-text
span?
stylize
unfocus
unview
view
within?
Commented Functions //
alias
alter
any
change
clean-path
make
repeat
same?
to-none
use
Function Reference *
* Summary: Returns the first value multiplied by the second. Synopsis: * value1 value2 Arguments: value1 value2 Description:
The value1 argument. (must be: number pair char money time tuple) The value2 argument. (must be: number pair char money time tuple)
The datatype of the second value may be restricted to INTEGER or DECIMAL, depending on the datatype of the first value (e.g. the first value is a time). print 123 * 10 print 12.3 * 10 print 3:20 * 3 Related: / // multiply divide
**
** Summary: Returns the first number raised to the second number. Synopsis: ** number exponent Arguments: number exponent Description:
The number argument. (must be: number) The exponent argument. (must be: number)
This is the operator for the POWER function. print 10 ** 2 print 12.345 ** 5 Related: power exp log-2 log-10 log-e
+
+ Summary: Returns the result of adding two values. Synopsis: + value1 value2 Arguments: value1 value2 Description:
The value1 argument. (must be: number pair char money date time tuple) The value2 argument. (must be: number pair char money date time tuple)
When adding values of different datatypes, the values must be compatible. print 123 + 1 print 12:00 + 11:00 print 31-Dec-1999 + 1 print 1.2.3.4 + 4.3.2.1 Related: - add subtract
-
Summary: Returns the second value subtracted from the first. Synopsis: - value1 value2 Arguments: value1 value2 Description:
The value1 argument. (must be: number pair char money date time tuple) The value2 argument. (must be: number pair char money date time tuple)
If used with only a single value, it negates the value (unary minus). When subtracting values of different datatypes, the values must be compatible. print 123 - 1 print -123 print - 123
; a negative number ; negating a positive number (unary)
print 12:00 - 11:00 print 1-Jan-2000 - 1 print 1.2.3.4 - 1.0.3.0 Related: + add subtract negate absolute
/
/ Summary:
Returns the first value divided by the second. Synopsis: / value1 value2 Arguments: value1 value2 Description:
The value1 argument. (must be: number pair char money time tuple) The value2 argument. (must be: number pair char money time tuple)
An error will occur if the second value is zero. When dividing values of different datatypes they must be compatible. print 123 / 10 print 12.3 / 10 print 1:00 / 60 Related: * // divide
//
// Summary: Returns the remainder of first value divided by second. Synopsis: // value1 value2 Arguments: value1 value2 Description:
The value1 argument. (must be: number pair char money time tuple) The value2 argument. (must be: number pair char money time tuple)
Returns the value of the remainder after the first number is divided by the second. If the second number is zero, an error will occur. print 123 // 10 print 25:32 // 24:00 If the first value is positive, then the returned remainder is nonnegative. If the first value is negative, then the returned remainder is nonpositive. Related: * / remainder Comments: -From: lmecir_mbox.vol.cz 25-Dec-2000/16:31:08-8:00:
= = minimum maximum
15-June-1999 print 4.3.2.1 > 1.2.3.4 print 11:00 > 12:00 Related: greater? < = = minimum maximum
>=
>=
Summary: Returns TRUE if the first value is greater than or equal to the second value. Synopsis: >= value1 value2 Arguments: value1 value2 Description:
The value1 argument. The value2 argument.
Returns FALSE for all other values. The values must be of the same datatype or an error will occur. For string-based datatypes, the sorting order is used for comparison with character casing ignored (uppercase = lowercase). print "abc" >= "abb" print 16-June-1999 >= 15-June-1999 print 1.2.3.4 >= 4.3.2.1 print 11:00 >= 11:00 Related: < = minimum maximum
?
? Summary: Prints information about words and values. Synopsis: ? word Arguments: word Description:
The word argument. (must be: any-type)
Synonym for HELP. ? switch Related: help what source
??
??
Summary: Prints a variable name followed by its molded value. (for debugging) Synopsis: ?? name Arguments: name Description:
The name argument.
Handy for printing the value of a variable while debugging.
about Summary:
about
Information about REBOL Synopsis: about Arguments: Description: about Related: license usage help system
abs
abs
Summary: Returns the absolute value. Synopsis: abs value Arguments: value Description:
The value argument. (must be: number pair money time)
A synonym for absolue.
absolute
absolute
Summary: Returns the absolute value. Synopsis: absolute value Arguments: value Description:
The value argument. (must be: number pair money time)
Returns a positive value equal in magnitude. print absolute -123 print absolute -1:23 Related: - negate
add
add
Summary: Returns the result of adding two values. Synopsis: add value1 value2 Arguments: value1 value2 Description:
The value1 argument. (must be: number pair char money date time tuple) The value2 argument. (must be: number pair char money date time tuple)
When adding values of different datatypes, the values must be compatible.
print add 123 1 print add 1.2.3.4 4.3.2.1 print add 3:00 -4:00 print add 31-Dec-1999 1 Related: + - subtract
alert
alert
Summary: Flashes a message to the user. Waits for a user response. Synopsis: alert str Arguments: str Description:
The str argument.
Post a simple alert message to the user. The only choice for the user is "OK". Related: flash
alias
alias
Summary: Creates an alternate spelling for a word. Synopsis: alias word name Arguments: word name Description:
Word to alias (must be: word) Name of alias (must be: string)
Create an alias for a word. The alias will be identical in every respect to the aliased word (symbol comparison and value referencing). Be careful not to confuse alias with setting another word to the same value. The alias cannot be set if the word already appears anywhere within the script or has been used in any way prior to being aliased. alias 'print "stampa" do {stampa "MONDO Rebol"} Related: set get Comments: -From: giesse_writeme.com 7-Dec-2000/2:39:35-8:00: Notice that ALIASes work for refinements and dialects too.
all
all
Summary: Shortcut AND. Evaluates and returns at the first FALSE or NONE.
Synopsis: all block Arguments: block Description:
Block of expressions (must be: block)
Evaluates each expression in a block until one of the expressions returns NONE or FALSE, in which case a NONE is returned. No other expressions are evaluated beyond that point. Otherwise, the value of the last expression will be returned. a: 100 b: -100 if all [(a > b) (a > 10) (b < -3)] [print "all were true"] time: 10:30 if all [time > 10:00 time < 11:00] [print "time is now"] day: 10 time: 9:45 ready: all [day > 5 time < 10:00 time: 12:00] print time Related: and any
alter
alter
Summary: If a value is not in the list, append it. Otherwise, remove it. Synopsis: alter list value Arguments: list value Description:
The list argument. The value argument.
?? Comments: -From: giesse_writeme.com 7-Dec-2000/2:41:57-8:00: NOTE: it returns the head of the list when the value is appended, but returns the position after the removal if the value is removed.
and
and
Summary: Returns the first value ANDed with the second. Synopsis: and value1 value2 Arguments: value1 value2 Description:
The value1 argument. (must be: logic number char tuple binary image) The value2 argument. (must be: logic number char tuple binary image)
For LOGIC values, both values must be TRUE to return TRUE, otherwise a FALSE is returned. For integers, each bit is separately affected (a numerical AND). All arguments are fully evaluated.
print true and true print true and false print (10 < 20) and (20 > 15) print 123 and 1 print 1.2.3.4 and 255.0.255.0 Related: or all not xor logic? integer?
any
any
Summary: Shortcut OR. Evaluates and returns the first value that is not FALSE or NONE. Synopsis: any block Arguments: block Description:
Block of expressions (must be: block)
Evaluates each expression in a block until one of the expressions returns a value other than NONE or FALSE, in which case the value is returned. No other expressions are evaluated beyond that point. Otherwise, NONE will be returned. a: 100 b: -100 if any [(a > b) (a > 10) (b < -3)] [print "one was true"] time: 10:30 if any [time > 10:00 day: 10 time: 9:45 ready: any [day > 5 print time
time < 11:00] [print "time is now"]
time < 10:00
time: 12:00]
Related: all or and Comments: -From: giesse_writeme.com 7-Dec-2000/2:46:46-8:00: A very useful use for ANY is to set default values. For example, if you have a word 'PORT that can hold a port number to use or NONE if the default value should be used, you can write: port: any [port 80] which will set 'PORT to 80 if it was NONE but will leave it untouched otherwise. The above is equivalent to: port: either port [port] [80] Using ANY in this case is much more convenient if you have more than one fallback value: port: any [port fallback-port-1 fallback-port-2 80] -From: giesse_writeme.com 7-Dec-2000/2:51-8:00: Another use for ANY is to emulate a sequence of if...elseif...elseif...else. Instead of writing: either cond-1 [ code-1 ] [ either cond-2 [ code-2 ] [ either cond-3 ... ] ] it is possible to write:
any [ if cond-1 [ code-1 true ; in case code-1 returns FALSE or NONE ] if cond-2 [ code-2 ] ... (default-code) ]
any-block?
any-block?
Summary: Returns TRUE for any-block values. Synopsis: any-block? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print any-block? [1 2] print any-block? first [(1 2) 3] print any-block? 'a/b/c print any-block? 12 Related: block? paren? path? any-function? any-string? any-type? any-word?
any-function?
any-function?
Summary: Returns TRUE for any-function values. Synopsis: any-function? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print any-function? :find print any-function? :+ print any-function? func [] [print "hi"] print any-function? 123 Related: function? native? op? any-block? any-string? any-type? any-word?
any-string? Summary: Returns TRUE for any-string values. Synopsis: any-string? value Arguments:
any-string?
value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. if any-string? "Hello" [print "a string"] probe any-string?
[email protected] probe any-string? ftp://ftp.rebol.com probe any-string? %/path/to/file.txt probe any-string? 11-Jan-2000 Related: string? file? email? url? any-block? any-function? any-type?
any-type?
any-type?
Summary: Returns TRUE for any-type values. Synopsis: any-type? value Arguments: value Description:
The value argument. (must be: any-type)
Returns TRUE for values of any type. Because any value that can successfully be passed to ANY-TYPE? is a value of some type, ANY-TYPE? never returns FALSE. However, an error will occur if a value cannot be passed to ANYTYPE?. print any-type? http://www.REBOL.com Related: any-type! any-block? any-function? any-string? any-word?
any-word?
any-word?
Summary: Returns TRUE for any-word values. Synopsis: any-word? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values.
print any-word? 'word foreach word [word set-word: 'lit-word :get-word 123] [ print [ rejoin [{"} mold :word {"}] either any-word? :word [ "is a type of word."]["is not a type of word."] ] ] Related: any-word! any-block? any-function? any-string? any-type?
append
append
Summary: Appends a value to the tail of a series and returns the series head. Synopsis: append series value Arguments: series value Refinements:
The series argument. (must be: series port) The value argument.
/only Description:
Appends a block value as a block
Works on any type of series, including strings and blocks. Returns the series at its head. /ONLY forces a block to be inserted as a block element (works only if the first argument is a block). string: copy "hello" probe append string " there" file: copy %file probe append file ".txt" url: copy http:// probe append url "www.rebol.com" block: copy [1 2 3 4] probe append block [5 6] probe append/only block [a block] Related: insert change remove
arccosine
arccosine
Summary: Returns the trigonometric arccosine in degrees. Synopsis: arccosine value Arguments: value
The value argument. (must be: number)
Refinements: /radians Description:
Returns result in radians.
Inverse function to the cosine. print arccosine .5 Related: arcsine arctangent cosine exp log-10 log-2 log-e pi power sine square-root tangent
arcsine
arcsine
Summary: Returns the trigonometric arcsine in degrees. Synopsis: arcsine value Arguments: value Refinements:
The value argument. (must be: number)
/radians Description:
Returns result in radians.
Inverse function to the sine. print arcsine .5 Related: arccosine arctangent cosine exp log-10 log-2 log-e pi power sine square-root tangent
arctangent
arctangent
Summary: Returns the trigonometric arctangent in degrees. Synopsis: arctangent value Arguments: value Refinements:
The value argument. (must be: number)
/radians Description:
Returns result in radians.
Inverse function to the tangent. print arctangent .22 Related: arccosine arcsine cosine exp log-10 log-2 log-e pi power sine square-root tangent
array
array
Summary: Makes and initializes a series of a given size. Synopsis: array size Arguments: size Refinements:
Size or block of sizes for each dimension (must be: integer block)
/initial value Description:
Specify an initial value for all elements Initial value
Supplying an single integer as the argument will create an array of a single dimension. To create an array of multiple dimensions, provide a block of integers. Each integer specifies the size of that dimension of the array. Normally the elements of the array will be initialized to NONE. However, other initialization values (such as zero) can be specified with the /INITIAL refinement. Arrays are rarely used in REBOL, but are provided for those familiar with other languages. In REBOL it is better practice to use series functions rather than array accesses. numbers: array 5 ; makes an array of 5 elements image: array [10 25] ; makes an array of 10 rows of 25 values xyz: array [10 25 5] ; makes a three-dimensional array repeat index 5 [poke numbers index index] print numbers numbers/3: 12345 image/4/20: http://www/colors.jpg xyz/10/5/2: 123.200.200 numbers: array/initial 5 10 print numbers Related: make
ask
ask
Summary: Ask the user for input. Synopsis: ask question Arguments: question Refinements:
Prompt to user (must be: series)
/hide Description:
mask input with *
Provides a common prompting function that is the same as a PRIN followed by an INPUT. The resulting input will have spaces trimmed from its head and tail. The /HIDE refinement hides input with "*" characters. print ask "Your name, please? " Related: confirm input prin
at
at Summary: Returns the series at the specified index. Synopsis: at series index Arguments: series index Description:
The series argument. (must be: series) Can be positive, negative, or zero. (must be: number)
Provides a simple way to index into a series. AT returns the series at the new index point. Note that the operation is relative to the current position within the series. numbers: [11 22 33] print at numbers 2 words: [grand grape great good] print first at words 2 remove at words 2 insert at words 3 [super] probe words Related: skip pick head tail
back
back
Summary: Returns the series at its previous position. Synopsis: back series Arguments: series Description:
The series argument. (must be: series port)
If the series is at its head, it will remain at its head. BACK will not go past the head, nor will it wrap to the tail. print back tail "abcd" str: tail "time" until [ str: back str print str head? str ] blk: tail [1 2 3 4] until [ blk: back blk print first blk head? blk ] Related: next last head tail head? tail?
binary?
binary?
Summary: Returns TRUE for binary values. Synopsis: binary? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print binary? #{13FF Acd0} print binary? 1234 Related: binary! type?
bind
bind
Summary: Binds words to a specified context. Synopsis: bind words known-word Arguments: words known-word Refinements:
A block of words or single word. (must be: block word) A sample word from the target context. (must be: word)
/copy Description:
Deep copies block before binding it.
Binds meaning to words in a block. That is, it gives words a context in which they can be interpreted. This allows blocks to be exchanged between different contexts, which permits their words to be understood. For instance a function may want to treat words in a global database as being local to that function. The second argument to BIND is a word from the context in which the block is to be bound. Normally, this is a word from the local context (e.g. one of the function arguments), but it can be a word from any context within the system. BIND will modify the block it is given. To avoid that, use the /COPY refinement. It will create a new block that is returned as the result. words: [a b c] fun: func [a b c][print bind words 'a] fun 1 2 3 fun "hi" "there" "fred" words: [a b c] object: make object! [ a: 1 b: 2 c: 3 prove: func [][print bind words 'a] ] object/prove settings: [start + duration]
schedule: function [start] [duration] [ duration: 1:00 do bind settings 'start ] print schedule 10:30 Related: use do func function
bitset?
bitset?
Summary: Returns TRUE for bitset values. Synopsis: bitset? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print bitset? make bitset! "abc" print bitset? 123 Related: bitset!
block?
block?
Summary: Returns TRUE for block values. Synopsis: block? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print block? [1 2 3] print block? "1 2 3" data: load "1 2 3" ; LOAD converts "1 2 3" into a block if block? data [print data] Related: block! type?
break Summary: Breaks out of a loop, while, until, repeat, foreach, etc. Synopsis:
break
break Arguments: Refinements: /return value Description:
Forces the loop function to return a value. The value argument. (must be: any-type)
The current loop is immediately terminated and evaluation resumes after the LOOP function. This function can be placed anywhere within the block being repeated, even within a sub block or function. repeat n 5 [ print n if n > 3 [break] ] Related: catch exit return loop repeat for forall foreach forever forskip while until
browse
browse
Summary: Opens the default web browser. Synopsis: browse value Arguments: value Refinements:
The URL to open (must be: any-string)
/only Description:
Don't open a new window if possible
If the browser cannot be found, nothing will happen.
build-tag
build-tag
Summary: Generates a tag from a composed block. Synopsis: build-tag blk Arguments: blk Description:
Block of parens to evaluate and other data (must be: block)
Constructs an HTML or XML tag from a block. Words within the block are used to construct the attribute words within the tag. If they are followed by a value, that value will be assigned to the attribute. Parenthesized elements are evaluated as expressions and their resulting value is used.
print build-tag [font size 3] print build-tag [font size (10 / 2)] print build-tag [img src %image.jpg] site: http://www.rebol.com/ main-index: %index.html print build-tag [A HREF (join site main-index)] root: %images/ download: %download1.gif alt-download: "Download the Latest REBOL!" print build-tag [IMG SRC (rejoin [site root download]) ALT (alt-download)] Related: tag! to-tag compose
caret-to-offset
caret-to-offset
Summary: Returns the offset position relative to the face of the character position. Synopsis: caret-to-offset face offset Arguments: face offset Description:
The face containing the text. (must be: object) The offset in the text. (must be: any-string)
This function is provided to convert from a string character index position to an X-Y offset within the text of a face. This is used primarily for text editing or for text mapping operations such as for creating colored or hyperlinked text. out: layout [ bx: box 10x15 red tx: body 100x100 ] tx/text: {This is an example character string.} xy: caret-to-offset tx at tx/text 14 bx/offset: tx/offset + xy view out Note that the resulting offset (xy) was added to the face position (tx/offset) to find the correct position to locate the box (bx). In the above example the caret-to-offset function was used on a face that have not yet been shown, but it can also be used after a face has been shown. Remember that when making changes to the contents of strings that are longer than 200 characters, you must set the text face line-list to NONE to force the recomputation of all line breaks. See the offset-to-caret function for the reverse conversion. This function can also work on faces that have never been shown. This makes pre-display processing, colored text, and hyperlinking possible using this function in combination with SIZE-TEXT.
catch Summary:
catch
Catches a throw from a block and returns its value. Synopsis: catch block Arguments: block Refinements:
Block to evaluate (must be: block)
/name word Description:
Catches a named throw. One or more names (must be: word block)
CATCH and THROW go together. They provide a way to exit from a block without evaluating the rest of the block. To use it, provide CATCH with a block to evaluate. If within that block a THROW is evaluated, it will return from the CATCH at that point. The result of the CATCH will be whatever was passed as the argument to the THROW. When using multiple CATCH functions, provide them with a name using the /NAME refinement to identify which one will CATCH which THROW. write %file.txt "i am a happy little file with no real purpose" print catch [ if exists? %file.txt [throw "Doc found"] "Doc not found" ] Related: throw do try
center-face
center-face
Summary: Center a face on screen or relative to another face. Synopsis: center-face obj Arguments: obj Refinements:
The obj argument. (must be: object)
/with face Description:
Center relative to a face. The face argument. (must be: object)
This function is used for centering a face relative to the screen or relative to other faces. It is useful for displaying dialog boxes or other types of windows that require the user's attention. In the example below, a layout face is shown in its default position, then it is displayed in the center of the screen. out1: layout [ vh2 "Bust'n Chops" body "With the Internet we're bust'n chops worldwide." ] view out1 center-face out1 view out1 To position a face relative to another face use the /with refinement.
out2: layout [vh2 "Ok boss."] out1/offset: 200x200 center-face/with out2 out1 view/new out1 view/new out2 wait 2 unview/all The out2 face is centered over the out1 face.
change
change
Summary: Changes a value in a series and returns the series after the change. Synopsis: change series value Arguments: series value Refinements:
Series at point to change (must be: series port) The new value
/part range /only /dup count Description:
Limits the amount to change to a given length or position. The range argument. (must be: number series port) Changes a series as a series. Duplicates the change a specified number of times. The count argument. (must be: number)
If the second argument is a simple value, it will replace the value at the current position in the first series. If the second argument is a series compatible with the first (block or string-based datatype), all of its values will replace those of the first argument or series. The /PART refinement changes a specified number of elements within the target series. For the convenience of cascading multiple changes the CHANGE function returns the series position just past the change. probe head change "bog" "d" probe head change [123 "test"] "the" probe head change/dup "abc" "->" 5 probe head change/part "abcde" "1234" 2 probe head change [1 4 5] [1 2 3] title: copy "how it REBOL" change title "N" probe title change find title "t" "s" probe title blk: copy ["now" 12:34 "REBOL"] change next blk "is" probe blk probe head change/only [1 4 5] [1 2 3]
probe head change/only [1 4 5] [[1 2 3]] string: copy "crush those grapes" change/part string "eat" find/tail string "crush" probe string Related: append clear insert remove sort Comments: -From: Al.Bri_xtra.co.nz 30-Dec-2000/13:02:33-8:00: 'change is also handy inside 'parse rule actions. For example: Mark: "---" MarkEnd: ( MarkEnd: change/part Mark "&emdash;" MarkEnd ) :MarkEnd changes the input string and jumps over the replaced text.
change-dir
change-dir
Summary: Changes the active directory path. Synopsis: change-dir dir Arguments: dir Description:
new directory path (must be: file)
Changes the value of system/script/path. This value is used for file-related operations. Any file path that does not begin with a slash (/) will be relative to the path in system/script/path. When a script file is executed using the DO native, the path will automatically be set to the directory containing the path. When REBOL starts, it is set to the current directory where REBOL is started. current: what-dir make-dir %./rebol-temp/ probe current change-dir %./rebol-temp/ probe what-dir change-dir current delete %./rebol-temp/ probe what-dir Related: make-dir what-dir list-dir
char?
char?
Summary: Returns TRUE for char values. Synopsis: char? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values.
print char? #"1" print char? 1 Related: char! type?
charset
charset
Summary: Makes a bitset of chars for the parse function. Synopsis: charset chars Arguments: chars Description:
The chars argument. (must be: string block)
A shortcut for MAKE BITSET! Used commonly for character based bit sets. chars: charset "aeiou" print find chars "o" print find "there you go" chars digits: charset "0123456789" area-code: ["(" 3 digits ")"] phone-num: [3 digits "-" 4 digits] print parse "(707)467-8000" [[area-code | none] phone-num] Related: bitset char! char?
checksum
checksum
Summary: Returns a CRC or other type of checksum. Synopsis: checksum data Arguments: data Refinements:
Data to checksum (must be: any-string)
/tcp /secure /hash size /method word /key key-value Description:
Returns an Internet TCP 16-bit checksum. Returns a cryptographically secure checksum. Returns a hash value Size of the hash table (must be: integer) Method to use Method (must be: word) Returns keyed HMAC value Key to use (must be: any-string)
Generally, a checksum is a number which accompanies data to verify that the data has not changed (did not have errors).
The /TCP refinement is used to compute the standard TCP networking checksum. print checksum "now is the dawning" print checksum "how is the dawning" print checksum/tcp "now is the dawning" print checksum/tcp "how is the dawning" Related: string! string? any-string! any-string?
choose
choose
Summary: Generates a choice selector menu, vertical or horizontal. Synopsis: choose choices function Arguments: choices function Refinements:
Block of items to display (must be: block) Function to call on selection (must be: function none)
/style styl /window winf /offset xy /across Description:
The style refinement. The style choice button (must be: object) The window refinement. The parent window to appear in (must be: object) The offset refinement. Offset of choice box (must be: pair) Use horizontal layout
This function pops-up a list of choices for user selection. The function does not return until the user has picked one of the choices or clicked outside of the popup area. The CHOOSE function takes a block of choices as its first argument. Its second argument is a function that is called when a choice has been made. choose ["A" "B" "C"] func [face btn] [print face/text]
clean-path
clean-path
Summary: Cleans-up '.' and '..' in path; returns the cleaned path. Synopsis: clean-path target Arguments: target Description:
The target argument. (must be: file url)
Rebuilds a directory, or URL path after following parent (..) and current (.) path indicators.
probe clean-path %com/www/../graphics/image.jpg probe clean-path http://www.rebol.com/www/../index.html messy-path: %/rebol/scripts/neat-stuff/../../experiments/./tests neat-path: clean-path messy-path probe neat-path Related: split-path change-dir dir? list-dir Comments: -From: giesse_writeme.com 7-Dec-2000/2:58:05-8:00: Warning: URLs are returned untouched. This is intended behaviour.
clear
clear
Summary: Removes all values from the current index to the tail. Returns at tail. Synopsis: clear series Arguments: series Description:
The series argument. (must be: series port none)
CLEAR is similar to REMOVE but removes through the end of the series rather than just a single value. str: copy "with all things considered" clear skip str 8 print str str: copy "get there quickly" clear find str "qui" print str Related: remove append change insert sort
clear-fields
clear-fields
Summary: Clear all text fields faces of a layout. Synopsis: clear-fields panel Arguments: panel Description:
The panel argument. (must be: object)
Clear all the fields of a layout. This is often used for input forms each time they are displayed.
close Summary: Closes an open port connection. Synopsis:
close
close port Arguments: port Description:
The port argument. (must be: port)
Closes a port opened with the OPEN function. Any changes to the port data that have been buffered will be written. rebol-port: open http://www.REBOL.com if find rebol-port "REBOL" [print "You did it!"] close rebol-port Related: open load do send
comment
comment
Summary: Ignores the argument value and returns nothing. Synopsis: comment value Arguments: value Description:
A string, block, or any other value
This function can be used to add comments to a script or to remove a block from evaluation. Note that this function is only effective in evaluated code and has no effect in data blocks. That is, within a data block comments will appear as data. In many cases, using COMMENT is not necessary. Placing braces around any expression will prevent if from being evaluated (so long as it is not part of another expression). comment "This is a comment." comment [print "As a comment, this is not printed"] Related: do
complement
complement
Summary: Returns the one's complement value. Synopsis: complement value Arguments: value Description:
The value argument. (must be: logic number char tuple bitset)
Used for bitmasking of integer numbers and inverting bitsets (charsets). print complement 0 print complement -1 chars: complement charset "ther " print find "there it goes" chars Related:
negate
compose
compose
Summary: Evaluates a block of expressions, only evaluating parens, and returns a block. Synopsis: compose value Arguments: value Refinements:
Block to compose
/deep Description:
Compose nested blocks
Constructs a block of values (output block) from another block of values (input block). Elements in the input block are placed in the output block with the exception of parenthesized elements. These elements are evaluated as expressions and their final return value placed in the output block. If the result is itself a block, then the elements of that block are inserted into the output block (in the same way as INSERT). To insert a block instead of its elements, place another block around it using the REDUCE function. The /DEEP refinement evaluates parenthesized elements within nested blocks. These elements are evaluated to the deepest level of nested blocks. probe compose [time (now/time) date (now/date)] block: compose [time: (now/time) date: (now/date)] probe block do block print time print date values: compose [2 + 2 print form values sum1: sum2: sum3: sum4: sum5: sum6: print
2 / 2
(2 * 2)
(2 - 1)]
1 + 1 2 + 2 3 + 3 4 + 4 5 + 5 6 + 6 mold compose [(sum1) sum2 ([sum3 sum4]) [sum5 sum6]]
print mold compose/deep [[(sum1) sum2] [sum3 [[(sum4) sum5] (sum6)]]] Related: reduce build-tag rejoin insert
compress
compress
Summary: Compresses a string series and returns it. Synopsis: compress data Arguments: data Description:
Data to compress (must be: any-string)
As with all compressed files, keep an uncompressed copy of the original data file as a backup. print compress "now is the dawning" string: form first system/words print length? string small: compress string print length? small Related: decompress
confirm
confirm
Summary: Confirms a user choice. Synopsis: confirm question Arguments: question Refinements:
Prompt to user (must be: series)
/with choices Description:
The with refinement. The choices argument. (must be: string block)
This function provides a method of prompting the user for a TRUE ("y" or "yes") or FALSE ("n" or "no") response. Alternate responses can be identified with the /WITH refinement. confirm "Answer: 14. Y or N? " confirm/with "Use A or B? " ["A" "B"] Related: ask input prin
connected?
connected?
Summary: Returns TRUE when connected to the Internet. Synopsis: connected? Arguments: Description: ???
context Summary: Defines a unique (underived) object. Synopsis: context blk Arguments:
context
blk Description:
Object variables and values. (must be: block)
This is a shortcut for MAKE OBJECT!. Related: make
copy
copy
Summary: Returns a copy of a value. Synopsis: copy value Arguments: value Refinements:
Usually a series (must be: series port bitset)
/part range /deep Description:
Limits to a given length or position. The range argument. (must be: number series port) Also copies series values within the block.
Be sure to use COPY on any string or block literal values in your code if you expect to modify them. For series, the /PART refinement will copy a given number of values (specified as either a count or as an ending series position). str: copy "with all things considered" print str strings: copy ["how" "flies"] print strings insert next strings "time" print strings Related: change clear insert make remove
cosine
cosine
Summary: Returns the trigonometric cosine in degrees. Synopsis: cosine value Arguments: value Refinements:
The value argument. (must be: number)
/radians Description:
Value is specified in radians.
Ratio between the length of the adjacent side to the length of the hypotenuse of a right triangle.
print cosine 90 print (cosine 45) = (sine 45) print cosine/radians pi Related: arccosine arcsine arctangent pi sine tangent
datatype?
datatype?
Summary: Returns TRUE for datatype values. Synopsis: datatype? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print datatype? integer! print datatype? 1234 Related: datatype!
date?
date?
Summary: Returns TRUE for date values. Synopsis: date? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print date? 1/3/69 print date? 12:39 Related: date! type?
debase Summary: Converts a string from a different base representation to binary. Synopsis: debase value Arguments:
debase
value Refinements:
The string to convert (must be: any-string)
/base base-value Description:
Allow a selection of a different base for conversion The base to convert from: 64, 16, or 2
Converts from an encoded string to the binary value. Primarily used for BASE-64 decoding. The /BASE refinement allows selection of number base as 64, 16, 2. Default is base64. probe debase "MTIzNA==" probe debase/base "12AB C456" 16 enbased: probe enbase "a string of text" probe string? enbased
; enbased value is a string
debased: probe debase enbased ; converts to binary value probe to-string debased
; converts back to original string
Related: enbase dehex
decimal?
decimal?
Summary: Returns TRUE for decimal values. Synopsis: decimal? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print decimal? 1.2 print decimal? 1 Related: decimal! number? type?
decode-cgi
decode-cgi
Summary: Converts CGI argument string to a list of words and value strings. Synopsis: decode-cgi args Arguments: args Description:
Starts at first argument word (must be: any-string)
Constructs a block of word value pairs from a name=value text string argument delineated with the "&" character. Obtain CGI queries by using DECODE-CGI to evaluate system/options/cgi/query-string, where CGI query strings are stored for reference. ex-query-string: "
[email protected]" cgi-input: make object! decode-cgi ex-query-string print probe cgi-input print ["Name: print ["Email:
" cgi-input/fname cgi-input/lname] " cgi-input/email]
decompress
decompress
Summary: Decompresses a binary series back to a string. Synopsis: decompress data Arguments: data Description:
Data to decompress (must be: binary)
If the data passed to the DECOMPRESS function has been altered or corrupted, a decompression error will occur. write %file.txt read http://www.rebol.com/ probe size? %file.txt save %file.comp compress read %file.txt probe size? %file.comp write %file.decomp decompress load %file.comp probe size? %file.decomp Related: compress enbase debase
dehex
dehex
Summary: Converts URL-style hex encoded (%xx) strings. Synopsis: dehex value Arguments: value Description:
The string to dehex (must be: any-string)
Converts the standard URL hex sequence that begins with a % followed by a valid hex value. Otherwise, the sequence is not converted and will appear as written. print dehex "www.com/a%20dir/file" print dehex "ABCD%45" Related: to-hex debase enbase
delete
delete
Summary: Deletes the specified file(s). Synopsis: delete target Arguments: target Refinements:
the file to delete (must be: file url)
/any Description:
allow wild cards
Deletes the file or URL object that is specified. If the file or URL refers to an empty directory, then the directory will be deleted. write %delete-test.r "This file is no longer needed." delete %delete-test.r Related: exists?
detab
detab
Summary: Converts tabs in a string to spaces. (tab size 4) Synopsis: detab string Arguments: string Refinements:
The string argument. (must be: any-string)
/size number Description:
Specifies the number of spaces per tab. The number argument. (must be: integer)
The REBOL language default tab size is four spaces. Use the /SIZE refinement for other sizes such as eight. DETAB will remove tabs from the entire string even beyond the first non-space character. The series passed to this function is modified as a result. text: " lots of tabs here" print detab copy text print detab/size text 8 Related: entab
difference Summary: Return the difference of two data sets. Synopsis: difference set1 set2 Arguments:
difference
set1 set2 Refinements:
First data set (must be: series bitset) Second data set (must be: series bitset)
/case /skip size Description:
Uses case-sensitive comparison. Treat the series as records of fixed size The size argument. (must be: integer)
Returns the elements of two series that are not present in both. lunch: [ham cheese bread carrot] dinner: [ham salad carrot rice] probe difference lunch dinner print difference [1 3 2 4] [3 5 4 6] string1: "CBAD" ; A B C D scrambled string2: "EDCF" ; C D E F scrambled print difference string1 string2 Related: intersect union
dir?
dir?
Summary: Returns TRUE if a file or URL is a directory. Synopsis: dir? target Arguments: target Description:
The target argument. (must be: file url)
Returns FALSE if it is not a directory. print dir? %file.txt print dir? %. Related: make-dir modified? exists?
dirize
dirize
Summary: Returns a copy of the path turned into a directory. Synopsis: dirize path Arguments: path Description:
The path argument. (must be: file string url)
Convert a file name to a directory name. For example:
probe dirize %dir
disarm
disarm
Summary: Returns the error value as an object. Synopsis: disarm error Arguments: error Description:
The error argument. (must be: error)
DISARM allows access to the values of an error object. If the error is not disarmed, it will occur again immediately. probe disarm try [1 + "x"] Related: error! trace
dispatch
dispatch
Summary: Wait for a block of ports. As events happen, dispatch port handler blocks. Synopsis: dispatch port-block Arguments: port-block Description:
Block of port handler pairs (port can be timeout too). (must be: block)
???
divide
divide
Summary: Returns the first value divided by the second. Synopsis: divide value1 value2 Arguments: value1 value2 Description:
The value1 argument. (must be: number pair char money time tuple) The value2 argument. (must be: number pair char money time tuple)
If the second value is zero, an error will occur. When dividing values of different datatypes, they must be compatible. print divide 123.1 12 print divide 10:00 4 Related: * / // multiply
do
do
Summary: Evaluates a block, file, URL, function, word, or any other value. Synopsis: do value Arguments: value Refinements:
Normally a file name, URL, or block
/args arg /next Description:
If value is a script, this will set its system/script/args Args passed to a script. Normally a string. Do next expression only. Return block with result and new position.
Accepts a block, or LOADs a string, file, or URL into a block, then evaluates the expressions of the block. Files and URLs must have a valid REBOL header. Elements are evaluated left to right. When an element encountered is a function requiring arguments, the function's arguments are first evaluated then passed to the function before it is evaluated. The value of final evaluation is returned.
The /ARGS refinement allows you to pass arguments to another script and is used with a file, or URL. Arguments passed with /ARGS are stored in system/script/args within the context of the loaded script.
The /NEXT refinement returns a block consisting of two elements. The first element is the evaluated return of the first expression encountered. The second element is the original block with the current index placed after the last evaluated expression. print do "1 + 2" do "repeat n 3 [print n]" do [print "doing"] print do [1 + 2] blk: [ [print "test"] [loop 3 [print "loop"]] ] do second blk do first blk blk: [ [1 + 2] [3 * 4] [6 / 3] ] while [not empty? blk][ set [value blk] do/next blk print value ] Related: load reduce loop repeat
do-events
do-events
Summary: Process all View events. Synopsis: do-events Arguments: Description: Process user events. When this function is called the program becomes event driven. This function does not return until all windows have been closed.
does
does
Summary: A shortcut to define a function that has no arguments or locals. Synopsis: does body Arguments: body Description:
The body block of the function (must be: block)
???
echo
echo
Summary: Copies console output to a file. Synopsis: echo target Arguments: target Description:
The target argument. (must be: file none)
Write output to a file in addition to the user console. The previous contents of a file will be overwritten. The echo can be stopped with ECHO NONE or by starting another ECHO. echo %helloworld.txt print "Hello World!" echo none Related: print trace
either
either
Summary: If condition is TRUE, evaluates the first block, else evaluates the second. Synopsis: either condition true-block false-block Arguments: condition
The condition argument.
true-block false-block Description:
The true-block argument. (must be: block) The false-block argument. (must be: block)
EITHER is identical to the if-else style comparison in other languages. In addition, EITHER returns the result of the block that it evaluates. grade: 72 either grade > 60 [ print "Passing Grade!" ][ print "Failing Grade!" ] print either grade > 60 ["Passing"]["Failing"] Related: if pick
email?
email?
Summary: Returns TRUE for email values. Synopsis: email? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print email?
[email protected] print email? http://www.REBOL.com Related: email! type?
empty?
empty?
Summary: Returns TRUE if a series is at its tail. Synopsis: empty? series Arguments: series Description:
The series argument. (must be: series port)
This is a synonym for TAIL? The check is made relative to the current location in the series. print empty? [] print empty? [1] Related: tail? none? found?
enbase
enbase
Summary: Converts a string to a different base representation. Synopsis: enbase value Arguments: value Refinements:
The string to encode (must be: any-string)
/base base-value Description:
Allow a selection of a different base for conversion The base to convert to: 64, 16, or 2
Converts from a string or binary into an encode string value. Primarily used for BASE-64 encoding. The /BASE refinement allows selection of base as 64, 16, 2. Default is base64. print enbase "Here is a string." print enbase/base #{12abcd45} 16 Related: debase dehex
entab
entab
Summary: Converts spaces in a string to tabs. (tab size 4) Synopsis: entab string Arguments: string Refinements:
The string argument. (must be: any-string)
/size number Description:
Specifies the number of spaces per tab. The number argument. (must be: integer)
The REBOL language default tab-size is four spaces. Use the /SIZE refinement for other sizes such as eight. ENTAB will only place tabs at the beginning of the line (prior to the first non-space character). The series passed to this function is modified as a result. text: { no tabs in this sentence } remove head remove back tail text probe text probe entab copy text print entab copy text probe entab/size copy text 2
print entab/size copy text 2 Related: detab
equal?
equal?
Summary: Returns TRUE if the values are equal. Synopsis: equal? value1 value2 Arguments: value1 value2 Description:
The value1 argument. The value2 argument.
String-based datatypes are equal when they are identical or differ only by character casing (uppercase = lowercase). print equal? 123 123 print equal? "abc" "abc" print equal? [1 2 3] [1 2 4] print equal? 15-June-1998 15-June-1999 print equal? 1.2.3.4 1.2.3.0 print equal? 1:23 1:23 Related: = == =? strict-equal?
error?
error?
Summary: Returns TRUE for error values. Synopsis: error? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. This is useful for determining if a TRY function returned an error. if error? try [1 + "x"][ print "Did not work." ] Related: error!
even? Summary:
even?
Returns TRUE if the number is even. Synopsis: even? number Arguments: number Description:
The number argument. (must be: number char date money time)
print even? 100 print even? 7 Related: odd? zero?
event?
event?
Summary: Returns TRUE for event values. Synopsis: event? value Arguments: value Description:
The value argument. (must be: any-type)
???
exclude
exclude
Summary: Return the first set less the second set. Synopsis: exclude set1 set2 Arguments: set1 set2 Refinements:
First data set (must be: series bitset) Second data set (must be: series bitset)
/case /skip size Description:
Uses case-sensitive comparison. Treat the series as records of fixed size The size argument. (must be: integer)
???
exists?
exists?
Summary: Determines if a file or URL exists. Synopsis: exists? target Arguments: target Description:
The target argument. (must be: file url)
Returns FALSE if the file does not exist. print exists? %file.txt print exists? %doc.r Related: read write delete modified? size?
exit
exit
Summary: Exits a function, returning no value. Synopsis: exit Arguments: Description: Use QUIT to exit the interpreter. test-str: make function! [str] [ if not string? str [exit] print str ] test-str 10 test-str "right" Related: return catch break
exp
exp
Summary: Raises E (natural number) to the power specified. Synopsis: exp power Arguments: power Description:
The power argument. (must be: number)
print exp 3 Related: log-10 log-2 log-e power
extract
extract
Summary: Extracts every n-th value from a series. Synopsis: extract block width Arguments: block width
The block argument. (must be: block hash) The width argument.
Description: Returns a new block that contains values that are spaced at regular intervals throughout a specified block. blk: extract ["This" "is" "a" "given" "block" "."] 2 This function is useful when dealing with blocks that contain records of fixed length. For example to obtain the names of the predefined VID styles: probe extract system/view/vid/vid-styles 2
fifth
fifth
Summary: Returns the fifth value of a series. Synopsis: fifth series Arguments: series Description:
The series argument. (must be: series money date port tuple event)
An error will occur if no value is found. Use the PICK function to avoid this error. print fifth "REBOL" print fifth [11 22 33 44 55 66] Related: pick first second third fourth
file?
file?
Summary: Returns TRUE for file values. Synopsis: file? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. Note that FILE? does not check for the existence of a file, but whether or not a value is the FILE! datatype. print file? %file.txt print file? "REBOL" Related: file! type?
find
find
Summary: Finds a value in a series and returns the series at the start of it. Synopsis: find series value
Arguments: series value Refinements:
The series argument. (must be: series port bitset) The value argument. (must be: any-type)
/part range /only /case /any /with wild /skip size /match /tail /last /reverse Description:
Limits the search to a given length or position. The range argument. (must be: number series port) Treats a series value as a single value. Characters are case-sensitive. Enables the * and ? wildcards. Allows custom wildcards. Specifies alternates for * and ? (must be: string) Treat the series as records of fixed size The size argument. (must be: integer) Performs comparison and returns the tail of the match. Returns the end of the string. Backwards from end of string. Backwards from the current position.
Returns NONE if the value was not found. Otherwise, returns a position in the series where the value was found. Many refinements to this function are available. /TAIL indicates that the position just past the match should be returned. The /MATCH refinement can be used to perform a character by character match of the input value to the series. The position just past the match is returned. Wildcards can be specified with /ANY and case sensitive comparisons can be made with /CASE. The /ONLY refinement applies to block values and is ignored for strings. The /LAST refinement causes FIND to search from the TAIL of the series toward the HEAD. /REVERSE searches backwards from the current position toward the head. print find "here and now" "and" print find/tail "here and now" "and" print find [12:30 123
[email protected]] 123 print find [1 2 3 4] 5 print find/match "here and now" "here" print find/match "now and here" "here" print find [1 2 3 4 3 2 1] 2 print find/last %file.fred.txt "." print find/last [1 2 3 4 3 2 1] 2 print find/any "here is a string" "s?r" Related: select pick
first
first
Summary: Returns the first value of a series. Synopsis: first series Arguments: The series argument. (must be: series pair event money date object port time tuple anyfunction library struct event)
series Description:
An error will occur if no value is found. Use the PICK function to avoid this error. print first "REBOL" print first [11 22 33 44 55 66] print first 1:30 print first 199.4.80.1 print first 12:34:56.78 Related: pick second third fourth fifth
flash
flash
Summary: Flashes a message to the user and continues. Synopsis: flash val Arguments: val Description:
The val argument.
Flash a message to the user. Similar to alert, but without a button. This function is normally used to inform the user of an action as it is occuring. The UNVIEW function can be used to remove the flash. flash "Loading file..." data: load %data.r unview The FLASH function returns the window face that is being displayed, allowing functions such as UNVIEW to explicitly refer to the flash window. fl: flash "Loading..." ... unview/only fl Related: alert
focus Summary: Focuses key events on a specific face. Synopsis:
focus
focus face Arguments: face Description:
The face argument.
Specify that the face is to receive keyboard input. Normally used with the FIELD and AREA styles. Only one face can have the focus at a time. The focus can be changed at an time by calling the FOCUS function with a new face. To remove the focus, call the UNFOCUS function. out: layout [ h2 "Focus example:" f1: field "field 1" f2: field "field 2" button "Focus 2" [focus f2] button "Focus 1" [focus f1] button "Unfocus" [unfocus] button "Close" [unview] ] focus f1 view out Focus is set automatically when a user clicks on a text face. Related: unfocus
for
for
Summary: Repeats a block over a range of values. Synopsis: for word start end bump body Arguments: word start end bump body Description:
Variable to hold current value (must be: word) Starting value (must be: number series money time date char) Ending value (must be: number series money time date char) Amount to skip each time (must be: number money time char) Block to evaluate (must be: block)
The first argument is used as a local variable to keep track of the current value. It is initially set to the START value and after each evaluation of the block the BUMP value is added to it until the END value is reached (inclusive). for num 0 30 10 [ print num ] for num 4 -37 -15 [ print num ] Related: forall foreach forever forskip
forall Summary: Evaluates a block for every value in a series. Synopsis:
forall
forall word body Arguments: word body Description:
Word set to each position in series and changed as a result (must be: word) Block to evaluate each time (must be: block)
Prior to evaluation, the WORD argument must be set to the desired starting position within the series (normally the head, but any position is valid). After each evaluation of the block, the word will be advanced to the next position within the series. cities: ["Eureka" "Ukiah" "Santa Rosa" "Mendocino"] forall cities [print first cities] chars: "abcdef" forall chars [print first chars] Related: for foreach forskip
foreach
foreach
Summary: Evaluates a block for each value(s) in a series. Synopsis: foreach word data body Arguments: word data body Description:
Word or block of words to set each time (will be local) (must be: get-word word block) The series to traverse (must be: series) Block to evaluate each time (must be: block)
For each evaluation of the block, the word will be set to the first value in the series. The WORDS argument can be a single word or a block of words. cities: ["Eureka" "Ukiah" "Santa Rosa" "Mendocino"] foreach city cities [print city] chars: "abcdef" foreach char chars [print char] Related: for forall forskip
forever
forever
Summary: Evaluates a block endlessly. Synopsis: forever body Arguments: body Description:
Block to evaluate each time (must be: block)
Evaluates a block continuously, or until a break or error condition is met.
forever [ if (random 10) > 5 [break] ] Related: loop while until
form
form
Summary: Converts a value to a string. Synopsis: form value Arguments: value Description:
The value to form
FORM creates the user-friendly format of the value, its standard PRINT format, not its molded (or source) format. When given a block of values, spaces are inserted between each values (except after a newline). To avoid the spaces between values use INSERT or JOIN. Note that FORM does not evaluate the values within a block. To do so, either use REFORM or perform a REDUCE prior to the FORM. print form 10:30 print form %image.jpg print form [123 "-string-" now] print reform [123 "-string-" now] Related: mold reform remold join
forskip
forskip
Summary: Evaluates a block for periodic values in a series. Synopsis: forskip word skip-num body Arguments: word skip-num body Description:
Word set to each position in series and changed as a result (must be: word) Number of values to skip each time (must be: integer) Block to evaluate each time (must be: block)
Prior to evaluation, the word must be set to the desired starting position within the series (normally the head, but any position is valid). After each evaluation of the block, the word's position in the series is changed by skipping the number of values specified by the second argument (see the SKIP function).
areacodes: [ "Ukiah" 707 "San Francisco" 415 "Sacramento" 916 ] forskip areacodes 2 [ print [ first areacodes "area code is" second areacodes] ] Related: for forall foreach skip
found?
found?
Summary: Returns TRUE if value is not NONE. Synopsis: found? value Arguments: value Description:
The value argument.
Returns FALSE for all other values. Not usually required because most conditional function will accept a NONE as FALSE and all other values as TRUE. if found? find
[email protected] ".com" [print "found it"] Related: find pick
fourth
fourth
Summary: Returns the fourth value of a series. Synopsis: fourth series Arguments: series Description:
The series argument. (must be: series money date port tuple event)
An error will occur if no value is found. Use the PICK function to avoid this error. print fourth "REBOL" print fourth [11 22 33 44 55 66] print fourth 199.4.80.1 Related: first second third fifth pick
free
free
Summary: Frees a REBOL resource. (Command version only)
Synopsis: free value Arguments: value Description:
The value argument. (must be: library struct)
???
func
func
Summary: Defines a user function with given spec and body. Synopsis: func spec body Arguments: spec body Description:
Help string (opt) followed by arg words (and opt type and string) (must be: block) The body block of the function (must be: block)
The spec is a block that specifies the interface to the function. It can begin with an optional string which will be printed when asking for HELP on the function. That is followed by the words that specify the arguments to the function. Each of these words may include an optional block of datatypes. These specify the valid datatypes for the argument. That may be followed by a comment string which describes the argument in more detail. The argument words may also specify a few variations on the way the argument will be evaluated. The most common is 'word which indicates that a word is expected that should not be evaluated (the function wants its name, not its value). A :word may also be given which will get the value of the argument, but not perform full evaluation. To add refinements to a function supply a slash (/) in front of an argument's word. Within the function the refinement can be tested to determine if the refinement was present. If a refinement is followed by more arguments, they will be associated with that refinement and are only evaluated when the refinement is present. Local variables are specified after a /LOCAL refinement. A function returns the last expression it evaluated. You can also use RETURN and EXIT to exit the function. A RETURN is given a value to return. EXIT returns no value. sum: func [a b] [a + b] print sum 123 321 sum: func [nums [block!] /average /local total] [ total: 0 foreach num nums [total: total + num] either average [total / (length? nums)][total] ] print sum [123 321 456 800] print sum/average [123 321 456 800] print-word: func ['word] [print form word] print-word testing Related: function make function! function? return exit
function Summary: Defines a user function with local words. Synopsis:
function
function spec vars body Arguments: spec vars body Description:
Optional help info followed by arg words (and optional type and string) (must be: block) List of words that are local to the function (must be: block) The body block of the function (must be: block)
FUNCTION is identical to FUNC but includes a block in which you can name words considered LOCAL to the function. average: function [block] [total] [ total: 0 foreach number block [total: number + total] total / (length? block) ] print average [1 10 12.34] Related: func make use function! function? return exit
function?
function?
Summary: Returns TRUE for function values. Synopsis: function? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print function? :func print function? "test" Related: any-function? function! type?
get
get
Summary: Gets the value of a word. Synopsis: get word Arguments: word Refinements:
Word to get (must be: any-word)
/any Description:
Allows any type of value, even unset.
The argument to GET must be a word, so the argument must be quoted or extracted from a block. To get the value of a word residing in an object, use the IN function.
value: 123 print get 'value print get second [the value here] print get in system/console 'prompt Related: set
get-word?
get-word?
Summary: Returns TRUE for get-word values. Synopsis: get-word? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print get-word? second [pr: :print] Related: get-word! word? set-word? lit-word?
greater-orequal?
greater-or-equal?
Summary: Returns TRUE if the first value is greater than or equal to the second value. Synopsis: greater-or-equal? value1 value2 Arguments: value1 value2 Description:
The value1 argument. The value2 argument.
Returns FALSE for all other values. The values must be of the same datatype or an error will occur. For string-based datatypes, the sorting order is used for comparison with character casing ignored (uppercase = lowercase). print greater-or-equal? "abc" "abb" print greater-or-equal? 16-June-1999 15-June-1999 print greater-or-equal? 1.2.3.4 4.3.2.1 print greater-or-equal? 1:00 11:00 Related: >= < = minimum maximum
greater?
greater?
Summary: Returns TRUE if the first value is greater than the second value. Synopsis: greater? value1 value2 Arguments: value1 value2 Description:
The value1 argument. The value2 argument.
Returns FALSE for all other values. The values must be of the same datatype or an error will occur. For string-based datatypes, the sorting order is used for comparison with character casing ignored (uppercase = lowercase). print greater? "abc" "abb" print greater? 16-June-1999 15-June-1999 print greater? 4.3.2.1 1.2.3.4 print greater? 11:00 12:00 Related: > < = = minimum maximum
halt
halt
Summary: Stops evaluation and returns to the input prompt. Synopsis: halt Arguments: Description: Useful for program debugging. div: 10 if error? try [100 / div] [ print "math error" halt ] Related: quit break exit catch
has
has
Summary: A shortcut to define a function that has local variables but no arguments. Synopsis: has locals body Arguments: locals body Description:
The locals argument. (must be: block) The body argument. (must be: block)
Defines a function that consists of local variables only. This is a shortcut for FUNC and FUNCTION.
For example: ask-name: has [name] [ name: ask "What is your name?" print ["Hello" name] ] ask-name The example above is a shortcut for: ask-name: func [/local name] [...]
hash?
hash?
Summary: Returns TRUE for hash values. Synopsis: hash? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. test-hash: make hash! [1 2 3 4] if hash? test-hash [print "It's a hash."] Related: hash! block? list?
head
head
Summary: Returns the series at its head. Synopsis: head series Arguments: series Description:
The series argument. (must be: series port)
str: "all things" print head insert str "with " here: find str "all" print here print head here Related: head? tail tail?
head? Summary:
head?
Returns TRUE if a series is at its head. Synopsis: head? series Arguments: series Description:
The series argument. (must be: series port)
cds: [ "Rockin' REBOLs" "Carl's Addiction" "Jumpin' Jim" ] print head? cds cds: tail cds print head? cds until [ cds: back cds print first cds head? cds ] Related: head tail tail?
help
help
Summary: Prints information about words and values. Synopsis: help word Arguments: word Description:
The word argument. (must be: any-type)
help quit Related: ? what
hide
hide
Summary: Hides a face or block of faces. Synopsis: hide face Arguments: face Refinements:
The face argument. (must be: object block)
/show Description:
Refreshes the area under the face being hidden.
HIDE has the opposite effect of SHOW. It temporarily removes the face from view, but does not remove the face from its parent face's pane. The face will become visible again the next time the face is shown either directly or indirectly through one of its parent faces. The example below creates a window with text and buttons. When clicked, the first two buttons will hide and show the third button. out: layout [ vh2 "Hide Button" body "Hide the extra button." button "Hide It" [hide bt] button "Show It" [show bt] bt: button "Extra Button" ] view out Multiple faces can be provided to HIDE as a block. The block normally contains face object references, but it will also accept the names of variables that hold faces. For example, to remove all of the buttons from the above example, you can hide part of its face pane (a block of faces): hide skip out/pane 2 The SKIP function skips the VH2 and BODY faces in the pane, passing only the BUTTON faces to HIDE. hide [btn1 btn2 txt2] If faces have names, they can be hidden with a block such as: hide [btn1 btn2 txt2] To permanently remove a face from view, remove it from its parent face's pane. In the earlier example the BT button could be permanently removed with: remove find out/pane bt show out The button could be put back with: append out/pane bt show out In both cases, the SHOW is used to refresh the view, showing its changes. Note that for top level faces, HIDE is used by UNVIEW to close windows. In addition, UNVIEW removes the top level face from the screen-face pane.
hide-popup
hide-popup
Summary: (missing) Synopsis: hide-popup Arguments: Description: This function is used to hide a popup window that was created with the INFORM or SHOW-POPUP functions. It will hide the most recent popup that has occurred.
inform layout [ text bold red "Warning..." button "OK" [hide-popup] ] The above example will display a popup message until the OK button is pressed and the HIDE-POPUP function is evaluated. Related: show-popup inform
if
if Summary: If condition is TRUE, evaluates the block. Synopsis: if condition then-block Arguments: condition then-block Refinements:
The condition argument. The then-block argument. (must be: block)
/else else-block Description:
If not true, evaluate this block The else-block argument. (must be: block)
Skip the block if the value is FALSE. To select an alternate result (else) use the EITHER function. IF returns the value of the block it evaluated or FALSE otherwise. age: 4 if age > 3 [print "wine is ready"] print if age > 2 ["ready"] print if age < 2 ["not ready"] Related: either switch select
image?
image?
Summary: Returns TRUE for image values. Synopsis: image? value Arguments: value Description:
The value argument. (must be: any-type)
???
import-email Summary: Constructs an email object from an email message.
import-email
Synopsis: import-email data Arguments: data Description:
The email message (must be: string)
Constructs an easily referenced object from an email message inherited by system/standard/email. The object's elements are defined by the email's header field names and are assigned the value of the corresponding fields. message: trim { To: John Doe From: Jane Doe Subject: Check Out REBOL! John, I found this great new scripting language that will be easier to use and more productive. Check out www.rebol.com! ---Jane } email: import-email message print email/from print email/to print email/content
in
in Summary: Returns the word in the object's context. Synopsis: in object word Arguments: object word Description:
The object argument. (must be: object) The word argument. (must be: word)
Return the word from within another context. This function is normally used with SET and GET. set-console: func ['word value] [ set in system/console word value ] set-console prompt "==>" set-console result "-->" Related: set get
in-window? Summary: Return true if a window contains a given face. Synopsis: in-window? window face
in-window?
Arguments: window face Description:
The window argument. The face argument.
Search all the subfaces of a face to determine if the specified face is within the window.
index?
index?
Summary: Returns the index number of the current position in the series. Synopsis: index? series Arguments: series Description:
The series argument. (must be: series port)
str: "with all things considered" print index? str print index? find str "things" blk: [264 "Rebol Dr." "Calpella" CA 95418] print index? find blk 95418 Related: length? offset? head head? tail tail? pick skip
info?
info?
Summary: Returns information about a file or url. Synopsis: info? target Arguments: target Description:
The target argument. (must be: file url)
The information is returned within an object that has SIZE, DATE, and TYPE words. These can be accessed in the same manner as other objects. info: info? %file.txt print info/size print info/date Related: exists? dir? modified? size?
inform Summary: Display an exclusive focus panel for alerts, dialogs, and requestors. Synopsis:
inform
inform panel Arguments: panel Refinements:
The panel argument. (must be: object)
/offset where /timeout time Description:
The offset refinement. Offset of panel (must be: pair) The timeout refinement. The time argument.
Display a window as a modal dialog. The inform function does not return until the user has finished with the dialog.
input
input
Summary: Inputs a string from the console. New-line character is removed. Synopsis: input Arguments: Refinements: /hide Description:
Mask input with a * character
Returns a string from the standard input device (normally the keyboard, but can also be a file or an interactive shell). The string does not include the new-line character used to terminate it. The /HIDE refinement hides input with "*" characters. prin "Enter a name: " name: input print [name "is" length? name "characters long"] Related: input? ask confirm
input?
input?
Summary: Returns TRUE if input characters are available. Synopsis: input? Arguments: Description: INPUT? can be used to determine if input is waiting to be read from the standard input device. When it returns TRUE, input is waiting to be read (with INPUT). print input? if input? [name: input] Related: input
insert
insert
Summary: Inserts a value into a series and returns the series after the insert. Synopsis: insert series value Arguments: series value Refinements:
Series at point to insert (must be: series port bitset) The value to insert (must be: any-type)
/part range /only /dup count Description:
Limits to a given length or position. The range argument. (must be: number series port) Inserts a series as a series. Duplicates the insert a specified number of times. The count argument. (must be: number)
If the value is a series compatible with the first (block or string-based datatype), then all of its values will be inserted. The series position just past the insert is returned, allowing multiple inserts to be cascaded together. This function includes many refinements. /PART allows you to specify how many elements you want to insert. /ONLY will force a block to be insert, rather than its individual elements. (Is only done if first argument is a block datatype.) /DUP will cause the inserted series to be repeated a given number of times. The series will be modified. str: copy "here this" insert str "now " print str insert tail str " message" print str insert tail str reduce [tab now] print str insert insert str "Tom, " "Tina, " print str insert/dup str "." 7 print str insert/part tail str next "!?$" 1 print str blk: copy ["hello"] insert blk 'print probe blk insert tail blk http://www.rebol.com probe blk insert/only blk [separate block] probe blk Related:
append change clear remove join
integer?
integer?
Summary: Returns TRUE for integer values. Synopsis: integer? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print integer? -1234 print integer? "string" Related: integer! type?
intersect
intersect
Summary: Create a new value that is the intersection of the two arguments. Synopsis: intersect ser1 ser2 Arguments: ser1 ser2 Refinements:
first set (must be: series bitset) second set (must be: series bitset)
/case /skip size Description:
Uses case-sensitive comparison. Treat the series as records of fixed size The size argument. (must be: integer)
Returns all elements within two blocks or series that exist in both. To obtain a unique set (to remove duplicate values) you can intersect a series with itself. lunch: [ham cheese bread carrot] dinner: [ham salad carrot rice] probe intersect lunch dinner print intersect [1 3 2 4] [3 5 4 6] string1: "CBAD" ; A B C D scrambled string2: "EDCF" ; C D E F scrambled print intersect string1 string2 items: [1 1 2 3 2 4 5 1 2] print intersect items items str: "abcacbaabcca" print intersect str str
; get unique set
Related: difference union
issue?
issue?
Summary: Returns TRUE for issue values. Synopsis: issue? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print issue? #1234-5678-9012 print issue? #467-8000 print issue? $12.56 Related: issue! type?
join
join
Summary: Concatenates values. Synopsis: join value rest Arguments: value rest Description:
Base value Value or block of values
Creates a new value as the return. The first argument determines the datatype of the returned value. When the first argument is a type of series, the return value will be that type of series (STRING, FILE, URL, BLOCK, etc.). When the first argument is a scalar value, the return will always be a string. When the second argument is a block, it will be evaluated and all of its values joined to the return value. probe join "super" "duper" probe join %file ".txt" probe join http:// ["www.rebol.com/" %index.html] probe join "t" ["e" "s" "t"] probe join 11:11 "PM" probe join [1] ["two" 3 "four"] Related: rejoin form reform mold remold insert
last
last
Summary: Returns the last value of a series. Synopsis: last series Arguments: series Description:
The series argument. (must be: series port tuple)
An error will occur if no value is found. Use the PICK function to avoid this error. print last "REBOL" print last [11 22 33 44 55 66] Related: first pick tail tail?
launch
launch
Summary: (missing) Synopsis: launch arg Arguments: arg Refinements:
The arg argument.
/secure-cmd Description:
The secure-cmd refinement.
???
layout
layout
Summary: Return a face with a pane built from style description dialect. Synopsis: layout specs Arguments: specs Refinements: /size pane-size /offset where /parent new /origin pos /styles list
Dialect block of styles, attributes, and layouts (must be: block) The size refinement. Size (wide and high) of pane face (must be: pair) The offset refinement. Offset of pane face (must be: pair) The parent refinement. Face style for pane (must be: object word block) The origin refinement. Set layout origin (must be: pair) The styles refinement. Block of styles to use (must be: block)
Description: The LAYOUT function takes a layout block as an argument and returns a layout face as a result. The block describes the layout according to the rules of the Visual Interface Dialect. The block is evaluated and a face is returned. The result of LAYOUT is can be passed directly to the VIEW function, but it can also be set to a variable or returned as the result of a function. The line: view layout block can also be written as: window: layout block view window The result of the layout function is a face and can be used in other layouts. Related: view stylize
length?
length?
Summary: Returns the length of the series from the current position. Synopsis: length? series Arguments: series Description:
The series argument. (must be: series port tuple struct)
The length is the number of values from the current position to the tail. If the current position is the head, then the length will be that of the entire series. print length? "REBOL" print length? [1 2 3 4 5] print length? [1 2 3 [4 5]] Related: head
lesser-orequal?
lesser-or-equal?
Summary: Returns TRUE if the first value is less than or equal to the second value. Synopsis: lesser-or-equal? value1 value2 Arguments: value1 value2 Description:
The value1 argument. The value2 argument.
Returns FALSE for all other values. For string-based datatypes, the sorting order is used for comparison with character casing ignored (uppercase = lowercase).
print lesser-or-equal? "abc" "abd" print lesser-or-equal? 14-June-1999 15-June-1999 print lesser-or-equal? 4.3.2.1 1.2.3.4 print lesser-or-equal? 1:23 10:00 Related: >= = minimum maximum
lesser?
lesser?
Summary: Returns TRUE if the first value is less than the second value. Synopsis: lesser? value1 value2 Arguments: value1 value2 Description:
The value1 argument. The value2 argument.
Returns FALSE for all other values. The values must be of the same datatype, or an error will occur. For stringbased datatypes, the sorting order is used for comparison with character casing ignored (uppercase = lowercase). print lesser? "abc" "abcd" print lesser? 15-June-1999 14-June-1999 print lesser? 1.2.3.4 4.3.2.1 print lesser? 1:30 2:00 Related: >= = minimum maximum
library?
library?
Summary: Returns TRUE for library values. Synopsis: library? value Arguments: value Description:
The value argument. (must be: any-type)
???
license Summary: Prints the REBOL/core license agreement. Synopsis: license
license
Arguments: Description: license Related: about
list-dir
list-dir
Summary: Prints a multi-column sorted listing of a directory. Synopsis: list-dir dir Arguments: dir Description:
Directory to list or nothing (must be: any-type)
Lists the files and directories of the specified path in a sorted multi-column output. If no path is specified, the directory specified in system/script/path is listed. Directory names are followed by a slash (/) in the output listing. list-dir To obtain a block of files for use by your program, use the LOAD function. The example below returns a block that contains the names of all files and directories in the local directory. files: load %./ print length? files probe files Related: change-dir make-dir what-dir read
list?
list?
Summary: Returns TRUE for list values. Synopsis: list? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. test-list: make list! [1 2 3 4] if list? test-list [print "It's a list."] Related: list!
lit-path? Summary: Returns TRUE for lit-path values.
lit-path?
Synopsis: lit-path? value Arguments: value Description:
The value argument. (must be: any-type)
???
lit-word?
lit-word?
Summary: Returns TRUE for lit-word values. Synopsis: lit-word? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. probe lit-word? first ['foo bar] Related: word! set-word? get-word!
load
load
Summary: Loads a file, URL, or string. Binds words to global context. Synopsis: load source Arguments: source Refinements:
The source argument. (must be: file url string any-block binary)
/header /next /library /markup /all Description:
Includes REBOL header object if present. Load the next value only. Return block with value and new position. Force file to be a dynamic library. (Command version) Convert HTML and XML to a block of tags and strings. Load all values. Does not evaluate REBOL header.
Reads and converts external data, including programs, data structures, images, and sounds into memory storage objects that can be directly accessed and manipulated by programs. The argument to LOAD can be a file, URL, string, or binary value. When a file name or URL is provided, the data is read from disk or network first, then it is loaded. In the case of a string or binary value, it is loaded directly from memory. Here are a few examples of using LOAD:
script: load %script.r data: load %database.r image: load %image.jpg sound: load %sound.wav data: load http://www.rebol.com/example.r data: load ftp://ftp.rebol.com/example.r data: load "1 2 luke
[email protected]" code: load {loop 10 [print "hello"]} LOAD is often called for a text file that contains REBOL code or data that needs to be brought into memory. The text is first searched for a REBOL header, and if a header is found, it os evaluated first. (However, unlike the DO function, LOAD does not require that there be a header.) If the load results in a single value, it will be returned. If it results in a block, the block will be returned. No evaluation of the block will be done; however, words in the block will be bound to the global context. If the header object is desired, use the /HEADER option to return it as the first element in the block. The /ALL refinement is used to load an entire script as a block. The header is not evaluated. The /NEXT refinement returns a block consisting of two elements. The first element is the first value loaded in the series. The second element is the original series with the current index just past the LOADed value. data: load "11 22 33 44" print third data set [value data] load/next data print value print data Related: read save do
load-image
load-image
Summary: Load an image through an in-memory image cache. Synopsis: load-image image-file Arguments: image-file Refinements:
Local file or remote URL (must be: file url)
/update /clear Description:
Force update from source site Purge the entire cache
When an image is used multiple times, this function allows you to load a single copy into memory and reuse it. Depending on your application, this can save considerable memory.
load-prefs Summary: Load user preferences from the prefs.r file. Synopsis: load-prefs
load-prefs
Arguments: Description: Load user preference settings from the installed base directory. Return a user-prefs object as a result.
load-thru
load-thru
Summary: Load a net file from the disk cache. Synopsis: load-thru url Arguments: url Refinements:
The url argument. (must be: url file)
/update /binary /to local-file /all /expand /check info Description:
Force update from source site Force binary mode, otherwise expects REBOL data or code. Specify local file target. The local-file argument. (must be: file none) Return block with REBOL script including unevaluated header (safe mode). Auto-decompress after transfer. Update only if date/size do not match. The info argument. (must be: block logic none)
???
log-10
log-10
Summary: Returns the base-10 logarithm. Synopsis: log-10 value Arguments: value Description:
The value argument. (must be: number)
print log-10 1234 Related: exp log-2 log-e power
log-2
log-2
Summary: Return the base-2 logarithm. Synopsis: log-2 value Arguments: value Description:
The value argument. (must be: number)
print log-2 1234 Related: exp log-10 log-e power
log-e
log-e
Summary: Returns the base-E (natural number) logarithm. Synopsis: log-e value Arguments: value Description:
The value argument. (must be: number)
print log-e 1234 print exp log-e 1234 Related: exp log-10 log-2 power
logic?
logic?
Summary: Returns TRUE for logic values. Synopsis: logic? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. Note that all conditional functions will accept more than just a LOGIC value. A NONE will act as FALSE, and all other values other than logic will act as TRUE. print logic? true print logic? 123 Related: logic! type?
loop
loop
Summary: Evaluates a block a specified number of times. Synopsis: loop count block Arguments: count block Description:
Number of repetitions (must be: integer) Block to evaluate (must be: block)
Returns the value of the final execution of the block. The BREAK function can be used to stop the loop at any time (but no value is returned). The REPEAT function is similar to LOOP, except that it keeps track of the current loop count. loop 40 [prin "*"] print "" Related: break repeat for while until
lowercase
lowercase
Summary: Converts string of characters to lowercase. Synopsis: lowercase string Arguments: string Refinements:
The string argument. (must be: any-string)
/part range Description:
Limits to a given length or position. The range argument. (must be: integer any-string)
The series passed to this function is modified as a result. print lowercase "ABCDEF" print lowercase/part "ABCDEF" 3 Related: uppercase
make
make
Summary: Constructs and returns a new value. Synopsis: make type spec Arguments: type spec Description:
The datatype or example value. (must be: any-type) The attributes of the new value. (must be: any-type)
The TYPE argument indicates the datatype to create. The form of the constructor is determined by the datatype. For most series datatypes, a number indicates the size of the initial allocation.
str: make string! 1000 blk: make block! 10 cash: make money! 1234.56 print cash time: make time! [10 30 40] print time Related: copy type? Comments: -From: lmecir_mbox.vol.cz 2-Dec-2000/9:10:44-8:00: Warning. If the first argument supplied is object!, or an object, Make modifies the Spec block. If you want to reuse the Spec argument, use Make in combination with copy/deep like: make object! copy/deep spec
make-dir
make-dir
Summary: Creates the directory structure specified. Synopsis: make-dir path Arguments: path Refinements:
The path argument. (must be: file url)
/deep Description:
The deep refinement.
Creates a new directory at the specified location. This operation can be performed for files or FTP URLs. make-dir %New-Dir/ delete %New-Dir/ Related: change-dir what-dir list-dir delete
make-face
make-face
Summary: Make a face from a given style name or example face. Synopsis: make-face style Arguments: style Refinements: /styles ss /clone /size wh
A name or a face (must be: word object) The styles refinement. Stylesheet Copy all primary facets The size refinement. Size of face (must be: pair)
/spec blk /offset xy Description:
The spec refinement. Spec block (must be: block) The offset refinement. Offset of face (must be: pair)
Make a face based on a face style. The LAYOUT function is not required. img: make-face 'image
max
max
Summary: Returns the greater of the two values. Synopsis: max value1 value2 Arguments: value1 value2 Description:
The value1 argument. (must be: number pair char money date time tuple series) The value2 argument. (must be: number pair char money date time tuple series)
???
maximum
maximum
Summary: Returns the greater of the two values. Synopsis: maximum value1 value2 Arguments: value1 value2 Description:
The value1 argument. (must be: number pair char money date time tuple series) The value2 argument. (must be: number pair char money date time tuple series)
print maximum "abc" "abd" print maximum 12:00 11:00 Related: < > minimum
min
min
Summary: Returns the lesser of the two values. Synopsis: min value1 value2 Arguments: value1 value2 Description: ???
The value1 argument. (must be: number pair char money date time tuple series) The value2 argument. (must be: number pair char money date time tuple series)
minimum
minimum
Summary: Returns the lesser of the two values. Synopsis: minimum value1 value2 Arguments: value1 value2 Description:
The value1 argument. (must be: number pair char money date time tuple series) The value2 argument. (must be: number pair char money date time tuple series)
print maximum "abc" "abd" print maximum 12:00 11:00 Related: < > maximum
modified?
modified?
Summary: Returns the last modified date of a file or URL. Synopsis: modified? target Arguments: target Description:
The target argument. (must be: file url)
Returns NONE if the file does not exist. print modified? %file.txt Related: exists?
mold
mold
Summary: Converts a value to a REBOL-readable string. Synopsis: mold value Arguments: value Refinements:
The value to mold
/only Description:
For a block value, give only contents, no outer [ ].
MOLD differs from FORM in that MOLD produces a REBOL readable string. For example, a block will contain brackets [ ] and strings will be " " quoted or use braces { } (if it is long or contains special characters). When given a block of values, spaces are inserted between each values (except after a newline). To avoid the spaces between values use INSERT to insert the block into a string. MOLD does not evaluate the values within a block. To do so use REMOLD.
print mold 10:30 print mold %image.jpg print mold [1 2 3] Related: form remold join insert reduce
money?
money?
Summary: Returns TRUE for money values. Synopsis: money? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print money? $123 print money? EUR$123 print money? 123.45 Related: money! type?
multiply
multiply
Summary: Returns the first value multiplied by the second. Synopsis: multiply value1 value2 Arguments: value1 value2 Description:
The value1 argument. (must be: number pair char money time tuple) The value2 argument. (must be: number pair char money time tuple)
The datatype of the second value may be restricted to INTEGER or DECIMAL, depending on the datatype of the first value (e.g. the first value is a time). print multiply 123 10 print multiply 3:20 3 print multiply 0:01 60 Related: * / // divide
native?
native?
Summary: Returns TRUE for native values. Synopsis: native? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. When passing a function to NATIVE? to be checked, it must be denoted with ":". This is because the ":word" notation passes a word's reference, not the word's value. NATIVE? can only determine whether or not a function is a native if it is passed the function's reference. probe native? :native? ; it's actually an ACTION! probe native? "Vichy" probe native? :if Related: native! type?
negate
negate
Summary: Changes the sign of a number. Synopsis: negate number Arguments: number Description:
The number argument. (must be: number pair money time bitset)
print negate 123 print negate 123.45 Related: + - positive? negative?
negative?
negative?
Summary: Returns TRUE if the number is negative. Synopsis: negative? number Arguments: number Description:
The number argument. (must be: number char money time)
Returns FALSE for all other values. print negative? -50 print negative? 50 Related: positive?
next
next
Summary: Returns the series at its next position. Synopsis: next series Arguments: series Description:
The series argument. (must be: series port)
If the series is at its tail, it will remain at its tail. NEXT will not go past the tail, nor will it wrap to the head. print next "ABCDE" print next next "ABCDE" print next [1 2 3 4] str: "REBOL" loop length? str [ print str str: next str ] blk: [red green blue] loop length? blk [ probe blk blk: next blk ] Related: back first head tail head? tail?
none?
none?
Summary: Returns TRUE for none values. Synopsis: none? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print none? NONE print none? pick "abc" 4 print none? find "abc" "d" Related: none none!
not
not
Summary: Returns the logic complement. Synopsis: not value Arguments: value Description:
(Only FALSE and NONE return TRUE)
Function returns TRUE if the value is FALSE, and FALSE if it is TRUE. To bitwise complement an INTEGER, use the COMPLEMENT function. print not true print not (10 = 1) Related: and or xor
not-equal?
not-equal?
Summary: Returns TRUE if the values are not equal. Synopsis: not-equal? value1 value2 Arguments: value1 value2 Description:
The value1 argument. The value2 argument.
String-based datatypes are considered equal when they are identical or differ only by character casing (uppercase = lowercase). print not-equal? "abc" "abcd" print not-equal? [1 2 4] [1 2 3] print not-equal? 12-sep-98 10:30 Related: = == equal?
now
now
Summary: Returns the current local date and time. Synopsis: now Arguments: Refinements: /year /month /day /time /zone
Returns the year only. Returns the month only. Returns the day of the month only. Returns the time only. Returns the time zone offset from GMT only.
/date /weekday /precise Description:
Returns date only. Returns day of the week as integer (Monday is day 1). Use nanosecond precision
For accuracy, first verify that the time, date and timezone are correctly set on the computer. print now print now/date print now/time print now/zone print now/weekday Related: date?
number?
number?
Summary: Returns TRUE for number values. Synopsis: number? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print number? 1234 print number? 12.34 print number? "1234" Related: integer? decimal?
object?
object?
Summary: Returns TRUE for object values. Synopsis: object? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print object? system Related: object! type?
odd?
odd?
Summary: Returns TRUE if the number is odd. Synopsis: odd? number Arguments: number Description:
The number argument. (must be: number char date money time)
print odd? 3 print odd? 100 print odd? 0 Related: even?
offset-to-caret
offset-to-caret
Summary: Returns the offset in the face's text corresponding to the offset pair. Synopsis: offset-to-caret face offset Arguments: face offset Description:
The face containing the text. (must be: object) The XY offset relative to the face. (must be: pair)
This function is provided to convert from an X-Y offset within a text face to a character index within a string. It is mainly used for text editing and text mapping operations such as for colored or hyperlinked text. Here is an interesting example. When you click your mouse on the upper text face, the string from that position forward will be shown in the lower text face. view layout [ body 80x50 "This is an example string." feel [ engage: func [face act event] [ if act = 'down [ bx/text: copy offset-to-caret face event/offset show bx ] ] ] bx: body 80x50 white black ] When the top face is clicked, the event/offset contains the X-Y offset that is converted to a string index position with offset-to-caret. The string from that point forward is copied and displayed in the lower text box (bx). Note that the string does not have to be displayed for this function to work. Also remember that when making changes to the contents of strings that are longer than 200 characters, you must set the text face line-list to NONE to force the recomputation of all line breaks.
offset?
offset?
Summary: Returns the offset between two series positions. Synopsis: offset? series1 series2 Arguments: series1 series2 Description:
The series1 argument. (must be: series) The series2 argument. (must be: series)
Return the distance between two positions within a series. Related: length? offset? head head? tail tail? pick skip
op?
op?
Summary: Returns TRUE for op values. Synopsis: op? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print op? :and print op? :+ Related: op!
open
open
Summary: Opens a new port connection. Synopsis: open spec Arguments: spec Refinements: /binary /string /direct /new /read /write /no-wait /lines
The spec argument. (must be: file url port object block) Preserves contents exactly. Translates all line terminators. Opens the port without buffering. Creates a file. (Need not already exist.) Read only. Disables write operations. Write only. Disables read operations. Returns immediately without waiting if no data. Handles data as lines.
/with end-of-line /allow access /mode args /custom params /skip length Description:
Specifies alternate line termination. The end-of-line argument. (must be: char string) Specifies the protection attributes when created. The access argument. (must be: block) Block of above refinements. The args argument. (must be: block) Allows special refinements. The params argument. (must be: block) Skips a number of bytes. The length argument. (must be: number)
Opens a port for I/O operations. The value returned from OPEN can be used to examine or modify the data associated with the port. The argument must be a fully-specified port specification, an abbreviated port specification such as a file path or URL, or a block which is executed to modify a copy of the default port specification. autos: open/new %autos.txt insert autos "Ford" insert tail autos " Chevy" close autos print read %autos.txt Related: close load do send
or
or Summary: Returns the first value ORed with the second. Synopsis: or value1 value2 Arguments: value1 value2 Description:
The value1 argument. (must be: logic number char tuple binary image) The value2 argument. (must be: logic number char tuple binary image)
An infix-operator. For LOGIC values, both must be FALSE to return FALSE; otherwise a TRUE is returned. For integers, each bit is separately affected. Because it is an infix operator, OR must be between the two values. print true or false print (10 > 20) or (20 < 100) print 122 or 1 print 1.2.3.4 or 255.255.255.0 Related: and not xor
pair? Summary: Returns TRUE for pair values. Synopsis:
pair?
pair? value Arguments: value Description:
The value argument. (must be: any-type)
???
paren?
paren?
Summary: Returns TRUE for paren values. Synopsis: paren? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. A paren is identical to a block, but is immediately evaluated when found. print paren? second [123 (456 + 7)] print paren? [1 2 3] Related: paren! type?
parse
parse
Summary: Parses a series according to rules. Synopsis: parse input rules Arguments: input rules Refinements:
Input series to parse (must be: series) Rules to parse by (must be: block string none)
/all /case Description:
Parses all chars including spaces. Uses case-sensitive comparison.
Parsing provides a means of recognizing a series of characters that appear in a particular order. Essentially, it is a method of finding and matching patterns. The rules argument supplies a block of grammar productions that are to be matched. There is also a simple parse mode that does not require rules, but takes a string of characters to use for splitting up the input string. Parse also works in conjunction with bitsets (charset) to specify groups of special characters. The result returned from a simple parse is a block of values. For rule-based parses, it returns TRUE if the parse succeeded through the end of the input string. The /ALL refinement indicates that all the characters within a string will be parsed. Otherwise, spaces, tabs, newlines, and other non-printable characters will be treated as spaces. The /CASE refinement specifies that a string is to be parsed case sensitive.
print parse "divide on spaces" none print parse "Harry Haiku, 264 River Rd., Ukiah, 95482" "," ;page: read http://www.rebol.com ;parse page [thru copy title to ] ;print title digits: charset "0123456789" area-code: ["(" 3 digits ")"] phone-num: [3 digits "-" 4 digits] print parse "(707)467-8000" [[area-code | none] phone-num] Related: trim
parse-emailaddrs
parse-email-addrs
Summary: (missing) Synopsis: parse-email-addrs data Arguments: data Description:
The data argument. (must be: string none)
???
parse-header
parse-header
Summary: Returns a header object with header fields and their values Synopsis: parse-header parent data Arguments: parent data Description:
Default header object (must be: object none) String to parse (must be: any-string)
???
parse-headerdate
parse-header-date
Summary: (missing) Synopsis: parse-header-date data Arguments: data Description:
The data argument. (must be: string none)
???
parse-xml
parse-xml
Summary: Parses XML code and returns a tree of blocks. Synopsis: parse-xml code Arguments: code Description:
XML code to parse (must be: string)
???
path?
path?
Summary: Returns TRUE for path values. Synopsis: path? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print path? first [random/seed 10] Related: path! make
pick
pick
Summary: Returns the value at the specified position in a series. Synopsis: pick series index Arguments: series index Description:
The series argument. (must be: series pair event money date time object port tuple anyfunction) The index argument. (must be: number logic)
The value is picked relative to the current position in the series (not necessarily the head of the series). The VALUE argument may be INTEGER or LOGIC. A positive integer positions forward, a negative positions backward. If the INTEGER is out of range, NONE is returned. If the value is LOGIC, then TRUE refers to the first position and FALSE to the second (same order as EITHER). An attempt to pick a value beyond the limits of the series will return NONE.
str: "REBOL" print pick str 2 print pick 199.4.80.1 3 print pick ["this" "that"] now/time > 12:00 Related: first second third fourth fifth find select
poke
poke
Summary: Returns value after changing its data at the given index. (See manual) Synopsis: poke value index data Arguments: value index data Description:
The value argument. (must be: series money date time object port tuple) The index argument. (must be: number logic) new value
Similar to CHANGE, but also takes an index into the series. str: "AXB" poke str 2 #"/" print str print poke 1.2.3.4 2 10 Related: pick change
port?
port?
Summary: Returns TRUE for port values. Synopsis: port? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. file: open %newfile.txt print port? file close file print port? "test" Related: port! make! type?
positive?
positive?
Summary: Returns TRUE if the value is positive. Synopsis: positive? number Arguments: number Description:
The number argument. (must be: number char money time)
Returns FALSE for all other values. print positive? 50 print positive? -50 Related: negative?
power
power
Summary: Returns the first number raised to the second number. Synopsis: power number exponent Arguments: number exponent Description:
The number argument. (must be: number) The exponent argument. (must be: number)
print power 10 2 print power 12.3 5 Related: ** exp log-10 log-2 log-e
prin
prin
Summary: Outputs a value with no line break. Synopsis: prin value Arguments: value Description:
The value to print
No line termination is used, so the next value printed will appear on the same line. If the value is a block, each of its values will be evaluated first then printed. prin "The value is " prin [1 + 2] prin ["The time is" now/time]
Related: print
print
print
Summary: Outputs a value followed by a line break. Synopsis: print value Arguments: value Description:
The value to print
If the value is a block, each of its values will be evaluated first, then printed. print 1234 print ["The time is" now/time] Related: prin
probe
probe
Summary: Prints a molded, unevaluated value and returns the same value. Synopsis: probe value Arguments: value Description:
The value argument.
Probe is very useful for debugging. Insert it anywhere a value is being passed and it will display the value without interfering with the code. probe ["red" "green" "blue"] if probe now/time > 12:00 [print "now"] Related: mold print
protect
protect
Summary: Protect a word or block to prevent from being modified. Synopsis: protect value Arguments: value Description:
The word or block of words to be protected (must be: word block)
Prevents a word from being modified using a set operation. An attempt to modify a locked word generates an error.
test: "This word is protected!" protect 'test if error? try [test: "Trying to change test..."] [ print "Couldn't change test!" ] print test unprotect 'test Related: unprotect
protect-system
protect-system
Summary: Protects all system functions and the system object from redefinition. Synopsis: protect-system Arguments: Description: ???
query
query
Summary: Returns information about a file or URL. Synopsis: query target Arguments: target Refinements:
The target argument. (must be: file url block port object)
/clear Description:
Clear modified state of target object
Its argument is an unopened port specification. The size, date and status fields in the port specification will be updated with the appropriate information if the query succeeds. Related: open update
quit
quit
Summary: Stops evaluation and exits the interpreter. Synopsis: quit Arguments: Description: Releases all resources back to the system. Shortcut: Q. Use EXIT to exit a function without returning a value.
time: 10:00 if time > 12:00 [ print "time for lunch" quit ] Related: halt exit
random
random
Summary: Returns a random value of the same datatype. Synopsis: random value Arguments: value Refinements:
Maximum value of result
/seed /secure /only Description:
Restart or randomize Returns a cryptographically secure random number. Return single value from series.
The value passed can be used to restrict the range of the random result. For integers random begins at one, not zero, and is inclusive of the value given. (This conforms to the indexing style used for all series datatypes, allowing random to be used directly with functions like PICK.) To initialize the random number generator to a random state, you can seed it with the current time. loop 4 [print random 10] lunch: ["Italian" "French" "Japanese" "American"] print pick lunch random 4 loop 3 [print random true] loop 5 [print random 1:00:00] random/seed now Related: now
read
read
Summary: Reads from a file, url, or port-spec (block or object). Synopsis: read source Arguments: source Refinements: /binary
The source argument. (must be: file url object block) Preserves contents exactly.
/string /direct /no-wait /lines /part size /with end-of-line /mode args /custom params /skip length Description:
Translates all line terminators. Opens the port without buffering. Returns immediately without waiting if no data. Handles data as lines. Reads a specified amount of data. The size argument. (must be: number) Specifies alternate line termination. The end-of-line argument. (must be: char string) Block of above refinements. The args argument. (must be: block) Allows special refinements. The params argument. (must be: block) Skips a number of bytes. The length argument. (must be: number)
Using READ is the simplest way to get information from a file or URL. This is a higher level port operation that opens a port, reads some or all of the data, then closes the port and returns the data that was read. When used on a file, or URL, the contents of the file, or URL are returned as a string. The /BINARY refinement forces READ to do a binary read. When used on a text file, line terminators will not be converted. The /STRING refinement translates line terminators to the operating system's line terminator. This behavior is default. The /DIRECT refinement reads without buffering, useful for reading files too large to contain in memory. The /LINES refinement returns read content as a series of lines. One line is created for each line terminator found in the read data. The /PART refinement reads the specified number of elements from the file, URL, or port. Reading a file or URL will read the specified number of characters. Used with /LINES, it reads a specified number of lines. The /WITH refinement converts characters, or strings, specified into line terminators. See the User's Guide for more detailed explanation of using READ and its refinements. write %rebol-test-file.r "text file" print read %rebol-test-file.r write %rebol-test-file.r [ {A learned blockhead is a greater man than an ignorant blockhead. -- Rooseveldt Franklin} ] probe first read/lines %rebol-test-file.r probe pick (read/lines %rebol-test-file.r) 3 probe read/part %rebol-test-file.r 9 probe read/with %rebol-test-file.r "blockhead" Related: write open close load save file! url! port!
read-io Summary: Low level read from a port.
read-io
Synopsis: read-io port buffer length Arguments: port buffer length Description:
Already opened port to read from. (must be: port) Buffer to which to append data. (must be: any-string) Maximum number of chars to read. (must be: number)
???
read-net
read-net
Summary: Read a file from the net (web). Update progress bar. Allow abort. Synopsis: read-net url Arguments: url Refinements:
The url argument. (must be: url)
/progress callback Description:
The progress refinement. Call func [total bytes] during transfer. Return true.
???
read-thru
read-thru
Summary: Read a net file from thru the disk cache. Returns binary, else none on error. Synopsis: read-thru url Arguments: url Refinements:
The url argument. (must be: url file)
/progress callback /update /expand /check info /to local-file Description:
The progress refinement. Call func [total bytes] during transfer. Return true. Force update from source site Auto-decompress after transfer. Update only if date/size do not match. The info argument. (must be: block logic none) Specify a file target, not cache. The local-file argument. (must be: file none)
???
recycle Summary: Recycles unused memory. Synopsis:
recycle
recycle Arguments: Refinements: /off /on /torture Description:
The off refinement. The on refinement. Temporary internal feature
Useful for forcing a garbage collection. You can also turn automatic memory management on and off. Default is RECYCLE/ON. recycle recycle/off recycle/on
reduce
reduce
Summary: Evaluates an expression or block expressions and returns the result. Synopsis: reduce value Arguments: value Description:
The value argument.
When given a block, evaluates each of its expressions and returns a block with all of the results. Very useful for composing blocks of values. values: reduce [1 + 2 3 + 4] print first values print second values Related: compose do foreach
refinement?
refinement?
Summary: Returns TRUE for refinement values. Synopsis: refinement? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print refinement? /any print refinement? 'any Related:
refinement!
reform
reform
Summary: Forms a reduced block and returns a string. Synopsis: reform value Arguments: value Description:
Value to reduce and form
Identical to FORM but reduces its argument first. Spaces are inserted between each value. probe reform ["the time is:" now/time] probe form ["the time is:" now/time] Related: form mold remold join rejoin
rejoin
rejoin
Summary: Reduces and joins a block of values. Synopsis: rejoin block Arguments: block Description:
Values to reduce and join (must be: block)
Similar to JOIN but accepts only one argument, the block (which will be reduced first). No spaces are inserted between values. print rejoin ["time=" now/time] Related: join form reform
remainder
remainder
Summary: Returns the remainder of first value divided by second. Synopsis: remainder value1 value2 Arguments: value1 value2 Description:
The value1 argument. (must be: number pair char money time tuple) The value2 argument. (must be: number pair char money time tuple)
If the second number is zero, an error will occur.
print remainder 123 10 print remainder 10 10 print remainder 10.2 10 If the first value is positive, then the returned remainder is nonnegative. If the first value is negative, then the returned remainder is nonpositive. Related: // * /
remold
remold
Summary: Molds a reduced block and returns a string. Synopsis: remold value Arguments: value Description:
Value to reduce and mold
Identical to MOLD, but reduces its argument first. Spaces are inserted between each values in a block. print remold ["the time is:" now/time] Related: mold reduce
remove
remove
Summary: Removes value(s) from a series and returns after the remove. Synopsis: remove series Arguments: series Refinements:
The series argument. (must be: series port bitset none)
/part range Description:
Removes to a given length or position. The range argument. (must be: number series port)
Normally removes just a single value from the current position. However, you can remove any number of values with the /PART refinement.
str: copy "send it here" remove str print str remove/part str find str "it" print str remove/part str 3 print str blk: copy [red green blue] remove next blk probe blk Related: append change clear insert sort
rename
rename
Summary: Renames a file to a new name. Synopsis: rename old new Arguments: old new Description:
path to the old file (must be: file url) new name (not a path) (must be: file url string)
This function cannot be used to move a file from one directory to another. write %testfile now rename %testfile %remove.me delete %remove.me Related: delete list-dir what-dir
repeat
repeat
Summary: Evaluates a block a number of times or over a series. Synopsis: repeat word value body Arguments: word value body Description:
Word to set each time (must be: word) Maximum number or series to traverse (must be: integer series) Block to evaluate each time (must be: block)
If the value is an integer, the word is used to keep track of the current loop count, which begins at one and continues up to and including the integer value given. If the value is a series, then the word holds the first value of each element of the series (see FOREACH). Returns the value of the final evaluation. The BREAK function can be used to stop the loop at any time (but no value is returned). The word is local to the block.
repeat num 5 [print num] Related: loop for forall foreach forskip while until Comments: -From: lmecir_mbox.vol.cz 2-Dec-2000/4:05:28-8:00: Warning. Repeat modifies its Body argument. If you need to reuse the Body (in the case of recursive functions, e.g.), use it in combination with Copy/deep as in: repeat word value copy/deep body -From: allen_rebolforces.com 15-Dec-2000/21:44:25-8:00: REPEAT operates faster than FOR, so use REPEAT in place of FOR wherever you can.
repend
repend
Summary: Appends a reduced value to a series and returns the series head. Synopsis: repend series value Arguments: series value Refinements:
The series argument. (must be: series port) The value argument.
/only Description:
Appends a block value as a block
???
replace
replace
Summary: Replaces the search value with the replace value within the target series. Synopsis: replace target search replace Arguments: target search replace Refinements:
Series that is being modified. (must be: series) Value to be replaced. Value to replace with.
/all /case Description:
Replace all occurrences. Case-sensitive replacement.
Searches target block or series for specified data and replaces it with data from the replacement block or series. Block elements may be of any datatype. The /ALL refinement replaces all occurrences of the searched data in the target block or series.
str: "a time a spec a target" replace str "a " "on " print str replace/all str "a " "on " print str fruit: ["apples" "lemons" "bananas"] replace fruit "lemons" "oranges" print fruit numbers: [1 2 3 4 5 6 7 8 9] replace numbers [4 5 6] ["four" "five" "six"] print numbers Related: insert remove change
request
request
Summary: Requests an answer to a simple question. Synopsis: request str Arguments: str Refinements:
The str argument. (must be: string block object none)
/offset xy /ok /only /confirm /timeout time Description:
The offset refinement. The xy argument. The ok refinement. The only refinement. The confirm refinement. The timeout refinement. The time argument.
Request the user to answer a question. Various refinements allow for a range of answers. The REQUEST function returns TRUE, FALSE, or NONE. TRUE is returned on an affirmative answer, FALSE is returned on a negative answer, and NONE is returned on a cancel operation. request "Do you want to save?" request/confirm "Delete the file?" request/ok "File has been removed." request ["Select action:" "Encrypt" "Decrypt" "Cancel"]
request-color Summary: Requests a color value. Synopsis: request-color
request-color
Arguments: Refinements: /color clr /offset xy Description:
The color refinement. The clr argument. The offset refinement. The xy argument.
Popup a window that requests a color selection from the user.
request-date
request-date
Summary: Requests a date. Synopsis: request-date Arguments: Refinements: /offset xy Description:
The offset refinement. The xy argument.
Popup a window that contains a calendar to request a date from the user.
requestdownload
request-download
Summary: Request a file download from the net. Show progress. Return none on error. Synopsis: request-download url Arguments: url Refinements:
The url argument. (must be: url)
/to local-file Description:
Specify local file target. The local-file argument. (must be: file none)
Begin downloading a file from a URL and show a progress bar. Return the data of the file as a binary value. The user may cancel the operation at any time, in which case a NONE is returned.
request-file
request-file
Summary: Requests a file using a popup list of files and directories. Synopsis: request-file Arguments: Refinements: /title title-line
Change heading on request. Title line of request
button-text /file name /filter filt /keep Description:
Button text for selection The file refinement. Default file name or block of file names The filter refinement. Filter or block of filters Keep previous settings and results
Popup a window to allow the user to select a file.
request-list
request-list
Summary: Requests a selection from a list. Synopsis: request-list titl alist Arguments: titl alist Refinements:
The titl argument. The alist argument.
/offset xy Description:
The offset refinement. The xy argument.
Popup a window that requests the user pick an item from a list.
request-pass
request-pass
Summary: Requests a username and password. Synopsis: request-pass Arguments: Refinements: /offset xy /user username /only /title title-text Description:
The offset refinement. The xy argument. The user refinement. The username argument. Password only. The title refinement. The title-text argument.
Pop-up a window that requests a username and password from the user. The password is obscured with *'s as it is entered. The result is returned as block that contains two strings. The first string is the username entry, the second is the password. If the user cancels the pop-up, a none is returned. For example: if user-pass: request-pass [ print ["User:" user-pass/1 "Pass:" user-pass/2] ]
You can provide a default username with the user refinement: request-pass/user "Fred" To specify a password only, use the /only refinement. To provide a different title for the pop-up, use the /title refinement.
request-text
request-text
Summary: Requests a text string be entered. Synopsis: request-text Arguments: Refinements: /offset xy /title title-text /default str Description:
The offset refinement. The xy argument. The title refinement. The title-text argument. The default refinement. The str argument.
Pop-up a window that requests text from the user. The /title refinement can be used to change the request question: print request-text/title "Enter your name:" If the user presses cancel or closes the window, a NONE is returned.
resend
resend
Summary: Relay a message Synopsis: resend to from message Arguments: to from message Description:
The to argument. The from argument. The message argument.
Resends an email message to the specified email. Resent emails are in no way altered leaving even the original "To:", "From:", and other fields intact. Messages resent must be passed to RESEND as a single string value containing the email. ;resend
[email protected] [email protected] some-message Related: send
return
return
Summary: Returns a value from a function. Synopsis: return value Arguments: value Description:
The value argument. (must be: any-type)
Exits the current function immediately, returning a value as the result of the function. To return no value, use the EXIT function. fun: make function! [this-time] [ return either this-time >= 12:00 ["after noon"][ "before noon"] ] print fun 9:00 print fun 18:00 Related: break exit catch
reverse
reverse
Summary: Reverses a series. Synopsis: reverse value Arguments: value Refinements:
The value argument. (must be: series tuple pair)
/part range Description:
Limits to a given length or position. The range argument. (must be: integer series)
Reverses the order of elements in a series or tuple. The /PART refinement reverses the specified number of elements from the current index forward. If the number of elements specified exceeds the number of elements left in the series or tuple, the elements from the current index to the end will be reversed. For tuple values the current index cannot be moved so the current index is always the beginning of the tuple. blk: copy [1 "two" 3 "four" 5 "six"] reverse blk print blk blk: copy [1 "two" 3 "four" 5 "six"] reverse/part next blk 4 print blk print reverse 1.2.3.4 text: "It is possible to reverse one word in a sentence." reverse/part (find text "reverse") (length? "reverse") print text print reverse/part 1.2.3.4 2
Related: insert replace sort
routine?
routine?
Summary: Returns TRUE for routine values. Synopsis: routine? value Arguments: value Description:
The value argument. (must be: any-type)
???
same?
same?
Summary: Returns TRUE if the values are identical. Synopsis: same? value1 value2 Arguments: value1 value2 Description:
The value1 argument. The value2 argument.
Returns TRUE if the values are identical objects, not just in value. For example, a TRUE would be returned if two strings are the same string (occupy the same location in memory). Returns FALSE for all other values. a: "apple" b: a print same? a b print same? a "apple" Related: =? equal? Comments: -From: lmecir_mbox.vol.cz 7-Dec-2000/12:45:45-8:00: My comment to this is: http://www.sweb.cz/LMecir/evaluation.html
save
save
Summary: Saves a value or a block to a file or url. Synopsis: save where value Arguments: where value Refinements:
Where to save it. (must be: file url binary) Value to save.
/header header-data /bmp /png Description:
Save it with a header Header block or object (must be: block object) Save in .BMP format Save in .PNG format
Performs the appropriate conversion and formatting to preserve datatypes. For instance, if the value is a REBOL block, it will be saved as a REBOL script that, when loaded, will be identical. save %date.r now print read %date.r date: load %date.r print date save %data.r reduce ["Data" 1234 %filename now/time] print read %data.r probe load %data.r Related: load send
script?
script?
Summary: Checks file, url, or string for a valid script header. Synopsis: script? value Arguments: value Description:
The value argument. (must be: file url string)
If the header is found, the script string will be returned as of that point. If not found, then NONE is returned. print either script? %file.txt ["found"]["not found"] Related: parse-header
second
second
Summary: Returns the second value of a series. Synopsis: second series Arguments: series
The series argument. (must be: series pair event money date object port time tuple anyfunction struct event)
Description: An error will occur if no value is found. Use the PICK function to avoid this error.
print second "REBOL" print second [11 22 33 44 55 66] print second 15-Jun-1999 print second 199.4.80.1 print second 12:34:56.78 Related: pick first third fourth fifth
secure
secure
Summary: Specifies security policies (access levels and directories). Return prior settings. Synopsis: secure level Arguments: level Description:
Levels are: quit, throw, ask, allow. Query will return settings. (must be: word block)
Controls file and network access using a dialect to specify security. You can set different security for networking, files, and specific files and directories. Levels of security offered are ALLOW, ASK, THROW, and QUIT. ALLOW removes all READ and/or WRITE restrictions. ASK restricts immediate READ and/or WRITE access and prompts the user for each access attempt requiring approval before the operation may be completed. THROW denies READ and/or WRITE access throwing an error when a restricted access attempt is made. QUIT denies READ and/or WRITE access and quits the script when restricted access is attempted. SECURE's argument may be a security setting used as a global setting, or a block containing a detailed breakdown of network and file access permissions. Access to specific files and directories is controlled using a specific file, or directory name in place of FILE. The previous secure settings are returned as a block. secure [ net allow file [ask write allow read] %. allow %.. [quit write] ] Related: open read write
select
select
Summary: Finds a value in the series and returns the value or series after it. Synopsis: select series value Arguments: series value
The series argument. (must be: series port) The value argument. (must be: any-type)
Refinements: /part range /only /case /any /with wild /skip size Description:
Limits the search to a given length or position. The range argument. (must be: number series port) Treats a series value as a single value. Characters are case-sensitive. Enables the * and ? wildcards. Allows custom wildcards. Specifies alternates for * and ? (must be: string) Treat the series as records of fixed size The size argument. (must be: integer)
Similar to the FINDfunction, but returns the next value in the series rather than the position of the match. Returns NONE if search failed. The /ONLY refinement is evaluated for a block argument and is ignored if the argument is a string. blk: [red 123 green 456 blue 789] print select blk 'red weather: [ "Ukiah" [clear 78 wind from NW at 5 MPH] "Santa Rosa" [overcast 65 wind from N at 10 MPH] "Eureka" [rain 62 wind from N at 15 MPH] ] probe select weather "Eureka" Related: find switch
send
send
Summary: Send a message to an address (or block of addresses) Synopsis: send address message Arguments: address message Refinements:
An address or block of addresses (must be: email block) Text of message. First line is subject.
/only /header header-obj Description:
Send only one message to multiple addresses Supply your own custom header The header to use (must be: object)
The first argument can be an email address or block of addresses. The value sent can be any REBOL datatype, but it will be converted to text prior to sending. For email, the message header will be constructed from the default header, unless the /HEADER refinement and a header object is provided. The /ONLY refinement will use bulk email, sending a single message to multiple email addresses. Before you can use this function you must setup your network configuration with SET-NET. This can be done interactively by running the SET-USER function defined in rebol.r.
send
[email protected] "Testing REBOL Function Summary" header: make system/standard/email [ To: [
[email protected]] From: [
[email protected]] Subject: "Message with a header" Organization: "REBOL Alliance" ] send/header
[email protected] trim { This is a longer message that also contains a header. } header Related: resend save
series?
series?
Summary: Returns TRUE for series values. Synopsis: series? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print series? "string" print series? [1 2 3] print series? 1234 Related: type? string? email? file? url? issue? tuple? block? paren?
set
set
Summary: Sets a word or block of words to specified value(s). Synopsis: set word value Arguments: word value Refinements:
Word or words to set (must be: any-word block) Value or block of values (must be: any-type)
/any Description:
Allows setting words to any value.
If the first argument is a block of words and the value is not a block, all of the words in the block will be set to the specified value. If the value is a block, then each of the words in the first block will be set to the respective values in the second block. If there are not enough values in the second block, the remaining words will be set to NONE The /ANY refinementallows words to be set any datatype including those such as UNSET! that are not normally allowed. This is useful in situations where all values must be handled.
set 'test 1234 print test set [a b] 123 print a print b set [d e] [1 2] print d print e Related: get value? unset
set-net
set-net
Summary: Network setup. All values after default are optional. Words OK for server names. Synopsis: set-net settings Arguments: settings Description:
[email-addr default-server pop-server proxy-server proxy-port-id proxy-type] (must be: block)
See the manual for a detailed description of this function. The block contains a series of values used for network settings. Use SET-NET to establish the network settings REBOL will use to access your LAN, or WAN. The first value is your email address and it is used when sending email and connecting to FTP. This value is stored in the REBOL system object at: SYSTEM/USER/EMAIL The second value is your SMTP (outgoing email) server name or address. This is stored in the REBOL system object at: SYSTEM/SCHEMES/DEFAULT/HOST The third value is an optional POP (incoming email) server name or address. This is stored at: SYSTEM/SCHEMES/POP/HOST The fourth value is an optional proxy server name or address. See the manual for a complete description. This is at: SYSTEM/SCHEMES/DEFAULT/PROXY/HOST The fifth value is an optional proxy port number. This is at: SYSTEM/SCHEMES/DEFAULT/PROXY/PORT-ID The sixth value is an optional proxy protocol. It can be socks, socks5, socks4, generic, or none. This is at: SYSTEM/SCHEMES/DEFAULT/PROXY/TYPE This is a helper function. You can always set any of the protocols directly. set-net [
[email protected] smtp.domain.name ] set-net [
[email protected] smtp.domain.name pop.domain.name proxy.domain.name 1080 socks ]
set-path?
set-path?
Summary: Returns TRUE for set-path values. Synopsis: set-path? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. if set-path? first [a/b/c: 10] [print "Path found"] Related: path! make
set-word?
set-word?
Summary: Returns TRUE for set-word values. Synopsis: set-word? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. if set-word? first [word: 10] [print "it will be set"] Related: set-word!
show
show
Summary: Display a face or block of faces. Synopsis: show face Arguments: face Description:
The face argument. (must be: object block)
This is a low-level View function that is used to display or update a face. The face being displayed must be part of an active pane (one that is part of a window display). The SHOW function is called frequently to update the display of a face after changes have been made. If the face contains a pane of sub-faces, all of those faces will be redisplayed. If you attempt to show a face and nothing happens, make sure that the face is part of the display hierarchy. That is, the face must be present in the pane list of another face that is being displayed. For example, if you modify any of the attributes of a face, you call the SHOW function to display the change. The code below shows this:
view layout [ bx: box 100x24 black button "Red" [bx/color: red show bx] button "Green" [bx/color: green show bx] ] The example below creates a layout face and then removes faces from its pane. The SHOW function is called each time to refresh the face and display what has happened. out: layout [ h1 "Show Example" t1: text "Text 1" t2: text "Text 2" ] view/new out wait 1 remove find out/pane t2 show out wait 1 remove find out/pane t1 show out wait 1 append out/pane t2 show out wait 1 unview
show-popup
show-popup
Summary: (missing) Synopsis: show-popup face Arguments: face Refinements:
The face argument. (must be: object)
/window window-face /away Description:
The window refinement. The window-face argument. (must be: object) The away refinement.
Show a popup window.
sine
sine
Summary: Returns the trigonometric sine in degrees. Synopsis: sine value Arguments: value Refinements:
The value argument. (must be: number)
/radians Description:
Value is specified in radians.
Ratio between the length of the opposite side to the length of the hypotenuse of a right triangle. print sine 90 print (sine 45) = (cosine 45) print sine/radians pi Related: arccosine arcsine arctangent cosine pi tangent
size-text
size-text
Summary: Returns the size of the text in a face. Synopsis: size-text face Arguments: face Description:
The face argument. (must be: object)
Returns the xy size of face text. This function can be used to determine the size of text in advance, allowing code to make adjustments before displaying the text. Note that the face does not need to be shown for this function to work correctly. f: make face [text: "Hello there"] size-text f
size?
size?
Summary: Returns the size of a file or URL's contents. Synopsis: size? target Arguments: target Description:
The target argument. (must be: file url)
If the file or URL is a directory, it returns the number of entries in the directory. print size? %file.txt Related: modified? exists?
skip Summary: Returns the series forward or backward from the current position. Synopsis: skip series offset Arguments:
skip
series offset Description:
The series argument. (must be: series port) Can be positive, negative, or zero. (must be: number)
For example, SKIP series 1 is the same as NEXT. If skip attempts to move beyond the head or tail it will be stopped at the head or tail. str: "REBOL" print skip str 3 blk: [11 22 33 44 55] print skip blk 3 Related: at index? next back
sort
sort
Summary: Sorts a series. Synopsis: sort series Arguments: series Refinements:
The series argument. (must be: series port)
/case /skip size /compare comparator /part length /all /reverse Description:
Case sensitive sort. Treat the series as records of fixed size. Size of each record. (must be: integer) Comparator offset, block or function. The comparator argument. (must be: integer block function) Sort only part of a series. Length of series to sort. (must be: integer) Compare all fields Reverse sort order
If you are sorting records of a fixed size, you will need to use the /SKIP refinement to specify how many elements to ignore. Normally sorting is not sensitive to character cases, but you can make it sensitive with the /CASE refinement. A /COMPARE function can be specified to perform the comparison. This allows you to change the ordering of the SORT. Sorting will modify the series passed as the argument. blk: [799 34 12 934 -24 0] print sort blk names: ["Fred" "fred" "FRED"] print sort/case names name-ages: [ "Larry" 45 "Curly" 50 "Mo" 42 ] print sort/skip name-ages 2
names: [ "Larry" "Curly" "Mo" ] print sort/compare names func [a b] [a < b] print sort "edcba" Related: append change clear insert remove
source
source
Summary: Prints the source code for a word. Synopsis: source word Arguments: word Description:
The word argument. (must be: word)
Useful for learning how mezzanine (higher level) functions are defined. If the function is a native, SOURCE returns the function's specification block. source copy source source Related: help ?
span?
span?
Summary: Returns a block of [min max] bounds for all faces Synopsis: span? pane Arguments: pane Refinements:
The pane argument. (must be: block)
/part count Description:
The part refinement. Limit the number of faces (must be: integer)
This function examines all the faces that are provided in a block, and returns the minimum and maximum positions that includes all of those faces. In other words this function returns the rectangle that would enclose all of the faces provided in the block. This is useful if you want to create a special rectangular area that encloses a set of faces. This function returns a block that contains the coordinate pairs of the upper left and lower right bounds. For example: out: layout [h1 "Heading" button "Test"] probe span out/pane
split-path
split-path
Summary: Splits a file or URL path. Returns a block containing path and target. Synopsis: split-path target Arguments: target Description:
The target argument. (must be: file url)
Returns a block consisting of two elements, the path and the file. Can be used on URLs and files alike. probe split-path %tests/math/add.r set [path file] split-path http://www.rebol.com/graphics/logo.gif print path print file Related: clean-path
square-root
square-root
Summary: Returns the square root of a number. Synopsis: square-root value Arguments: value Description:
The value argument. (must be: number)
print square-root 2 Related: exp log-10 log-2 log-e power
strict-equal?
strict-equal?
Summary: Returns TRUE if the values are equal and of the same datatype. Synopsis: strict-equal? value1 value2 Arguments: value1 value2 Description:
The value1 argument. The value2 argument.
Strict equality requires the values to not differ by datatype (so 1 would not be equal to 1.0) nor by character casing (so "abc" would not be equal to "ABC"). print strict-equal? 123 123 Related:
== =
strict-notequal?
strict-not-equal?
Summary: Returns TRUE if the values are not equal and not of the same datatype. Synopsis: strict-not-equal? value1 value2 Arguments: value1 value2 Description:
The value1 argument. The value2 argument.
A FALSE is returned if the values differ by datatype (so 1 would not be equal to 1.0) nor by character casing (so "abc" would not be equal to "ABC"). print strict-not-equal? 124 123 print strict-not-equal? 12-sep-98 10:30 Related: = ==
string?
string?
Summary: Returns TRUE for string values. Synopsis: string? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print string? "with all things considered" print string? 123 Related: string! type?
struct?
struct?
Summary: Returns TRUE for struct values. Synopsis: struct? value Arguments: value Description: ???
The value argument. (must be: any-type)
stylize
stylize
Summary: Return a style sheet block. Synopsis: stylize specs Arguments: specs Refinements:
A block of: new-style: old-style facets (must be: block)
/master /styles styls Description:
Add to or change master style sheet The styles refinement. Base on existing style sheet (must be: block)
This function allows you to define a set of face styles that can be used in multiple layouts. For instance, if you want to define a standard style of text or a standard button style, you can place it in a stylesheet using STYLIZE. The stylesheet can then be used in one or more layouts. Each style is specified in a format that is similar to LAYOUT. The STYLIZE function returns a stylesheet block that can be used in a layout. The code below defines a stylesheet that contains three styles: text-styles: stylize [ big-text: text font-size 50 red-text: text red bold-blue-text: text bold blue font-size 50 ] view layout [ styles text-styles big-text "One big heading..." red-text "This text will appear red." big-bold-blue-text "This is big, bold, and blue." ] Multiple stylesheets can be used in a layout. The stylize function also allows you to modify the master styles for your current REBOL session. However, be careful, as all scripts that are run after modifying the master stylesheet will be affected. Related: layout
subtract
subtract
Summary: Returns the second value subtracted from the first. Synopsis: subtract value1 value2 Arguments: value1 value2 Description:
The value1 argument. (must be: number pair char money date time tuple) The value2 argument. (must be: number pair char money date time tuple)
When subtracting values of different datatypes the values must be compatible.
print subtract 123 1 print subtract 1.2.3.4 1.0.3.0 print subtract 12:00 11:00 print subtract 1-Jan-2000 1 Related: - + add absolute
switch
switch
Summary: Selects a choice and evaluates what follows it. Synopsis: switch value cases Arguments: value cases Refinements:
Value to search for. Block of cases to search. (must be: block)
/default case Description:
The default refinement. Default case if no others are found.
Switch also returns the value of the block it executes. The cases can be any datatype. If none of the other cases match, use the /DEFAULT refinement to specify a default case. switch 22 [ 11 [print "here"] 22 [print "there"] ] person: 'mom switch person [ ; words dad [print "here"] mom [print "there"] kid [print "everywhere"] ] file: %user.r switch file [ %user.r [print "here"] %rebol.r [print "everywhere"] %file.r [print "there"] ] url: ftp://ftp.rebol.org switch url [ http://www.rebol.com [print "here"] http://www.cnet.com [print "there"] ftp://ftp.rebol.org [print "everywhere"] ] html-tag: print switch html-tag [
["Preformatted text"]
["Page title"]
["Bulleted list item"] ] time: 12:30 switch time [ 8:00 [send [email protected] "Hey, get up"] 12:30 [send [email protected] "Join me for lunch."] 16:00 [send [email protected] "Dinner anyone?"] ] car: pick [Ford Chevy Dodge] random 3 print switch car [ Ford [351 * 1.4] Chevy [454 * 5.3] Dodge [154 * 3.5] ] Related: select find
tag?
tag?
Summary: Returns TRUE for tag values. Synopsis: tag? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print tag? print tag? "title" Related: tag!
tail
tail
Summary: Returns the series at the position after the last value. Synopsis: tail series Arguments: series Description:
The series argument. (must be: series port)
Access to the tail allows insertion at the end of a series (because insertion always occurs before the specified element).
blk: copy [11 22 33] insert tail blk [44 55 66] print blk Related: tail? head head?
tail?
tail?
Summary: Returns TRUE if a series is at its tail. Synopsis: tail? series Arguments: series Description:
The series argument. (must be: series port)
This function is the best way to detect the end of a series while moving through it. print tail? "string" print tail? tail "string" str: "Ok" print tail? tail str print tail? next next str items: [oven sink stove blender] while [not tail? items] [ print first items items: next items ] blk: [1 2] print tail? tail blk print tail? next next blk Related: empty? tail head head?
tangent
tangent
Summary: Returns the trigonometric tangent in degrees. Synopsis: tangent value Arguments: value Refinements:
The value argument. (must be: number)
/radians Description:
Value is specified in radians.
Ratio between the length of the opposite side to the length of the adjacent side of a right triangle.
print tangent 30 print tangent/radians 2 * pi Related: arccosine arcsine arctangent cosine pi tangent
third
third
Summary: Returns the third value of a series. Synopsis: third series Arguments: The series argument. (must be: series money date port time tuple any-function struct event object)
series Description:
An error will occur if no value is found. Use the PICK function to avoid this error. print third "REBOL" print third [11 22 33 44 55 66] print third 15-Jun-1999 print third 199.4.80.1 print third 12:34:56.78 Related: first second fourth fifth pick
throw
throw
Summary: Throws control back to a previous catch. Synopsis: throw value Arguments: value Refinements:
Value returned from catch (must be: any-type)
/name word Description:
Throws to a named catch. The word argument. (must be: word)
CATCH and THROW go together. They provide a method of exiting from a block without evaluating the rest of the block. To use it, provide CATCH with a block to evaluate. If within that block a THROW is evaluated, the script will return from the CATCH at that point. The result of the CATCH will be the value that was passed as the argument to the THROW. When using multiple CATCH functions, provide them with a name to identify which one will CATCH which THROW. print catch [ if exists? %file.txt [throw "Doc file!"] ]
Related: catch return exit
throw-on-error
throw-on-error
Summary: Evaluates a block, which if it results in an error, throws that error. Synopsis: throw-on-error blk Arguments: blk Description:
The blk argument. (must be: block)
???
time?
time?
Summary: Returns TRUE for time values. Synopsis: time? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print time? 12:00 print time? 123 Related: time! type?
to
to Summary: Constructs and returns a new value after conversion. Synopsis: to type spec Arguments: type spec Description:
The datatype or example value. (must be: any-type) The attributes of the new value. (must be: any-type)
???
to-binary Summary: Converts to binary value. Synopsis: to-binary value
to-binary
Arguments: value Description:
Value to convert
Converts other values to BINARY. probe to-binary "123456" Related: binary!
to-bitset
to-bitset
Summary: Converts to bitset value. Synopsis: to-bitset value Arguments: value Description:
Value to convert
Converts other values to BITSET. probe to-bitset [#"a" - #"z" #"A" - #"Z"] Related: bitset!
to-block
to-block
Summary: Converts to block value. Synopsis: to-block value Arguments: value Description:
Value to convert
Converts other values to BLOCK. print to-block "123 10:30" Related: block!
to-char
to-char
Summary: Converts to char value. Synopsis: to-char value Arguments: value Description:
Value to convert
Converts other values to CHAR. print to-char "a" print to-char 65 Related: char!
to-date
to-date
Summary: Converts to date value. Synopsis: to-date value Arguments: value Description:
Value to convert
Converts other values to DATE. print to-date "12-April-1999" Related: date!
to-decimal
to-decimal
Summary: Converts to decimal value. Synopsis: to-decimal value Arguments: value Description:
Value to convert
Converts other values to DECIMAL. print to-decimal 12.3 Related: decimal!
to-email
to-email
Summary: Converts to email value. Synopsis: to-email value Arguments: value Description:
Value to convert
Converts other values to EMAIL.
print to-email [luke rebol.com] Related: email!
to-event
to-event
Summary: Converts to event value. Synopsis: to-event value Arguments: value Description:
Value to convert
???
to-file
to-file
Summary: Converts to file value. Synopsis: to-file value Arguments: value Description:
Value to convert
Converts other values to FILE. print to-file ask "What file would you like to create? " Related: file!
to-get-word
to-get-word
Summary: Converts to get-word value. Synopsis: to-get-word value Arguments: value Description:
Value to convert
Converts other values to GET-WORD. probe to-get-word "test" Related: get-word!
to-hash
to-hash
Summary: Converts to hash value. Synopsis: to-hash value Arguments: value Description:
Value to convert
Converts other values to HASH. test-hash: to-hash [Bob Tina Fred Sandra Linda] print find test-hash 'Fred Related: hash!
to-hex
to-hex
Summary: Converts an integer to a hex issue!. Synopsis: to-hex value Arguments: value Description:
Value to be converted (must be: integer)
print to-hex 123 Related: binary!
to-idate
to-idate
Summary: Returns a standard Internet date string. Synopsis: to-idate date Arguments: date Description:
The date argument. (must be: date)
Internet date format is day, date, month, year, time (24-hour clock), timezone offset from GMT. print to-idate now Related: date! date?
to-image Summary: Converts to image value. Synopsis:
to-image
to-image value Arguments: value Description:
Value to convert
???
to-integer
to-integer
Summary: Converts to integer value. Synopsis: to-integer value Arguments: value Description:
Value to convert
Converts other values to INTEGER. print to-integer "123" print to-integer 123.9 print to-integer #"A" Related: integer!
to-issue
to-issue
Summary: Converts to issue value. Synopsis: to-issue value Arguments: value Description:
Value to convert
Converts other values to ISSUE. print to-issue "1234-56-7890" Related: issue!
to-list
to-list
Summary: Converts to list value. Synopsis: to-list value Arguments: value Description:
Value to convert
Converts other values to LIST. test-list: to-list [Bob Tina Fred Sandra Linda] insert next test-list "Alice" print test-list Related: list!
to-lit-path
to-lit-path
Summary: Converts to lit-path value. Synopsis: to-lit-path value Arguments: value Description:
Value to convert
???
to-lit-word
to-lit-word
Summary: Converts to lit-word value. Synopsis: to-lit-word value Arguments: value Description:
Value to convert
Converts other values to LIT-WORD. probe to-lit-word "test" Related: lit-word!
to-logic
to-logic
Summary: Converts to logic value. Synopsis: to-logic value Arguments: value Description:
Value to convert
Converts other values to LOGIC. print to-logic 1 print to-logic 0 Related: logic!
to-money
to-money
Summary: Converts to money value. Synopsis: to-money value Arguments: value Description:
Value to convert
Converts other values to MONEY. print to-money 123.4 print to-money [AUS 123.4] Related: money!
to-none
to-none
Summary: Converts to none value. Synopsis: to-none value Arguments: value Description:
Value to convert
Converts other values to NONE. Related: none! Comments: -From: giesse_writeme.com 8-Dec-2000/7:11:56-8:00: I still can't see the use for this. Is it here just for simmetry?
to-pair
to-pair
Summary: Converts to pair value. Synopsis: to-pair value Arguments: value Description:
Value to convert
???
to-paren Summary: Converts to paren value.
to-paren
Synopsis: to-paren value Arguments: value Description:
Value to convert
Converts other values to PAREN. print to-paren "123 456" Related: paren!
to-path
to-path
Summary: Converts to path value. Synopsis: to-path value Arguments: value Description:
Value to convert
Converts other values to PATH. colors: make object! [reds: ["maroon" "brick" "sunset"]] p-reds: to-path [colors reds] print form :p-reds print p-reds insert tail p-reds "bright" print colors/reds print p-reds Related: path!
to-refinement
to-refinement
Summary: Converts to refinement value. Synopsis: to-refinement value Arguments: value Description:
Value to convert
Converts other values to REFINEMENT. Related: refinement!
to-set-path
to-set-path
Summary: Converts to set-path value. Synopsis: to-set-path value Arguments: value Description:
Value to convert
Converts other values to SET-PATH. colors: make object! [blues: ["sky" "sea" "midnight"]] ps-blues: to-set-path [colors blues] print form :ps-blues print ps-blues ps-blues compose [(ps-blues) "light"] print colors/blues print ps-blues Related: set-path!
to-set-word
to-set-word
Summary: Converts to set-word value. Synopsis: to-set-word value Arguments: value Description:
Value to convert
Converts other values to SET-WORD. probe to-set-word "test" Related: set-word!
to-string
to-string
Summary: Converts to string value. Synopsis: to-string value Arguments: value Description:
Value to convert
Converts other values to STRING. print to-string [123 456] Related:
string!
to-tag
to-tag
Summary: Converts to tag value. Synopsis: to-tag value Arguments: value Description:
Value to convert
Converts other values to TAG. print to-tag ";comment:" Related: tag!
to-time
to-time
Summary: Converts to time value. Synopsis: to-time value Arguments: value Description:
Value to convert
Converts other values to TIME. print to-time 75 Related: time!
to-tuple
to-tuple
Summary: Converts to tuple value. Synopsis: to-tuple value Arguments: value Description:
Value to convert
Converts other values to TUPLE. print to-tuple [12 34 56] Related: tuple!
to-url
to-url
Summary: Converts to url value. Synopsis: to-url value Arguments: value Description:
Value to convert
Converts other values to URL. print to-url "[email protected]" Related: url!
to-word
to-word
Summary: Converts to word value. Synopsis: to-word value Arguments: value Description:
Value to convert
Converts other values to WORD. print to-word "test" Related: word!
trace
trace
Summary: Enables and disables evaluation tracing. Synopsis: trace mode Arguments: mode Refinements:
The mode argument. (must be: logic)
/net /function Description:
Enable/disable network tracing. Enable/disable function call tracing.
Used for debugging a script. TRACE ON turns it on. TRACE OFF turns it off. To limit the amount of output selective place trace around the parts of the script that need it. TRACE/NET allows watching what the network protocols are doing. Related: echo probe
trim
trim
Summary: Removes whitespace from a string. Default removes from head and tail. Synopsis: trim series Arguments: series Refinements:
The series argument. (must be: series port)
/head /tail /auto /lines /all /with str Description:
Removes only from the head. Removes only from the tail. Auto indents lines relative to first line. Removes all line breaks and extra spaces. Removes all whitespace. The with refinement. Same as /all, but removes characters in 'str'. (must be: char string)
Generally, TRIM is for removing spaces from the head and tail of a string. However, there are several other useful modes of operation. One of the most useful is /AUTO which will do a "smart" trim of the indentation of text lines. You can restrict the trim to the /HEAD or the /TAIL. Or, you can also remove /ALL space. If you TRIM/LINES then all line breaks will be replaced with spaces. This is useful for word wrapping and web page kinds of applications. The string provided for the argument will be modified by this function str: " string " print trim str str: { Now is the winter of our discontent made glorious summer by this sun of York. } print trim/auto copy str Related: parse
try
try
Summary: Tries to DO a block and returns its value or an error. Synopsis: try block Arguments: block Description:
The block argument. (must be: block)
TRY provides a useful means of capturing errors and handling them within a script. For instance, use TRY to test an expression that could fail and stop the script. TRY returns an error value if an error happened, otherwise it returns the normal result of the block. if error? try [1 + "x"] [print "Did not work."] if error? try [load "$10,20,30"] [print "No good"]
Related: error? disarm do
tuple?
tuple?
Summary: Returns TRUE for tuple values. Synopsis: tuple? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print tuple? 1.2.3.4 version: 0.1.0 if tuple? version [print version] Related: tuple! type?
type?
type?
Summary: Returns a value's datatype. Synopsis: type? value Arguments: value Refinements:
The value argument. (must be: any-type)
/word Description:
Returns the datatype as a word.
To check for a single datatype, use its datatype test function (e.g. string?, time?) The /WORD refinement returns the type as a word so you can use if for FIND, SELECT, SWITCH, and other functions. print type? 10 print type? :type? value: 10:30 print switch type?/word value [ integer! [value + 10] decimal! [to-integer value] time! [value/hour] date! [first value/time] ] Related: make none? logic? integer? decimal? money? tuple? time? date? character? string? email? file? url? issue? word? block? paren? path? native? function? object? port?
unfocus
unfocus
Summary: Removes the current key event focus. Synopsis: unfocus Arguments: Description: Removes the focus from the current focal face. The face was previously specified with the FOCUS function to set it as the focal point for input events. If the face had text highlighted, the highlighting is cleared. out: layout [ h2 "Input your info:" f1: field button "Unfocus" [unfocus] button "Close" [unview] ] focus f1 view out If UNFOCUS is called when there is no focal face, it will be ignored. Related: focus
union
union
Summary: Creates a new set that is the union of the two arguments. Synopsis: union set1 set2 Arguments: set1 set2 Refinements:
first set (must be: series bitset) second set (must be: series bitset)
/case /skip size Description:
Use case-sensitive comparison Treat the series as records of fixed size The size argument. (must be: integer)
Returns all elements present within two blocks or strings ignoring the duplicates. To obtain a unique set (to remove duplicate values) you can union a series with itself. lunch: [ham cheese bread carrot] dinner: [ham salad carrot rice] probe union lunch dinner print sort union [1 3 2 4] [3 5 4 6] string1: "CBDA" ; A B C D scrambled string2: "EDCF" ; C D E F scrambled print sort union string1 string2 items: [1 1 2 3 2 4 5 1 2] print union items items ; get unique set
str: "abcacbaabcca" print union str str Related: difference intersect
unique
unique
Summary: Returns a set with duplicate values removed. Synopsis: unique set Arguments: set Refinements:
The set argument. (must be: series)
/case /skip size Description:
Use case-sensitive comparison Treat the series as records of fixed size The size argument. (must be: integer)
???
unprotect
unprotect
Summary: Unprotects a word or block of words. Synopsis: unprotect value Arguments: value Description:
The value argument. (must be: word block)
Unlocks a word locked with PROTECT so its value may be modified. test: "I'm protected, no-one may change me!" protect 'test if error? try [test: "Trying to change test..."] [ print "Couldn't change test!" ] print test unprotect 'test if error? try [test: "Trying to change test..."] [ print "Couldn't change test!" ] Related: protect
unset Summary: Unsets the value of a word.
unset
Synopsis: unset word Arguments: word Description:
Word or block of words (must be: word block)
Using UNSET, the word's current value will be lost. If a block is specified, all the words within the block will be unset. test: "a value" unset 'test print value? 'test Related: set
unset?
unset?
Summary: Returns TRUE for unset values. Synopsis: unset? value Arguments: value Description:
The value argument. (must be: any-type)
Returns TRUE if a value is UNSET. Normally you should use VALUE? to test if a word has a value. if unset? do [print "test"] [print "Nothing was returned"] Related: value? unset!
until
until
Summary: Evaluates a block until it is TRUE. Synopsis: until block Arguments: block Description:
The block argument. (must be: block)
Evaluates a block until the block returns a TRUE value (that is, the last expression in the block is TRUE). str: "string" until [ print str tail? str: next str ] Related: while repeat for
unview
unview
Summary: Closes window views, except main view. Synopsis: unview Arguments: Refinements: /all /only face Description:
Close all views, including main view The only refinement. Close a single view (must be: object)
The UNVIEW function is used to close a window previously opened with the VIEW function. By default, the last window that has been opened will be closed. To close a specific window, use the /only refinement and specify the window's face (that which was returned from a layout, for example). All windows can be closed with the /all refinement. The example below opens a window that displays a Close button. Clicking on the button will evaluate the UNVIEW function and the window will be closed. view layout [button "Close" [unview]] Note that the VIEW function will not return until all windows have been closed. (Use VIEW/new to return immediately after the window is opened.) The next example will open two windows, then use UNVIEW/only to close each one separately. out1: layout [button "Close 2" [unview out2]] out2: layout [button "Close 1" [unview out1]] view/new out1 view/new out2 do-events You could have closed both windows with the line: unview/all Related: view show hide flash inform
update
update
Summary: Updates the data related to a port. Synopsis: update port Arguments: port Description:
The port argument. (must be: port)
Updates the input or output of a port. If input is expected, the port is checked for more input. If output is pending then that output is written.
out: open/new %trash.me insert out "this is a test" update out insert out "this is just a test" close out Related: read write insert remove query
upgrade
upgrade
Summary: Download a new version of REBOL if available. Synopsis: upgrade Arguments: Description: Checks your version of REBOL against the latest released version (requires a network connection) and prompts you to download the latest version if your current version is outdated. If your current version of REBOL is up to date, this is indicated. ;upgrade Related: about license
uppercase
uppercase
Summary: Converts string of characters to uppercase. Synopsis: uppercase string Arguments: string Refinements:
The string argument. (must be: any-string)
/part range Description:
Limits to a given length or position. The range argument. (must be: integer any-string)
The series passed to this function is modified as a result. print uppercase "abcdef" print uppercase/part "abcdef" 1 Related: lowercase
url? Summary: Returns TRUE for url values. Synopsis:
url?
url? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. print url? http://www.REBOL.com print url? "test" Related: url! type?
usage
usage
Summary: Prints command-line arguments. Synopsis: usage Arguments: Description: This includes command line options and examples. usage Related: help ?
use
use
Summary: Defines words local to a block. Synopsis: use words body Arguments: words body Description:
Local word(s) to the block (must be: block word) Block to evaluate (must be: block)
The first block contains a list of words which will be local to the second block. The second block will be evaluated and its results returned from the USE. total: 1234 nums: [123 321 456] use [total] [ total: 0 foreach n nums [total: total + n] print total ] print total Related: function! object!
Comments: -From: lmecir_mbox.vol.cz 2-Dec-2000/9:06:25-8:00: Warning. Use modifies its Body argument. If you need to reuse it (in the case you are writing a recursive function, e.g.) , use it in combination with copy/deep as in: use words copy/deep body
value?
value?
Summary: Returns TRUE if the word has been set. Synopsis: value? value Arguments: value Description:
The value argument.
Returns FALSE for all other values. The word can be passed as a literal or as the result of other operations. test: 1234 print value? 'test print value? second [test this] Related: unset? equal? strict-equal? same?
view
view
Summary: Displays a window face. Synopsis: view view-face Arguments: view-face Refinements:
The view-face argument. (must be: object)
/new /offset xy /options opts /title text Description:
Creates a new window and returns immediately The offset refinement. Offset of window on screen (must be: pair) The options refinement. Window options [no-title no-border resize] (must be: block word) The title refinement. Window bar title (must be: string)
The view function creates and updates windows. It takes a face as its argument. The contents of the window is determined from a face that holds a block of the graphical objects. The window face is normally created with the LAYOUT function, but faces can be constructed directly from face objects and displayed as well. The example below opens a window and displays some text and a button.
view layout [ h2 "The time is currently:" h3 form now button "Close" [unview] ] The position and size of the window is determined from the face to be displayed. In the example above, the size of the window is automatically computed by the LAYOUT function. The window is shown in the default position in the upper left area of the screen. The window's caption will be default be the title of the script that is being run. To provide a different caption, use the /title refinement and a string. view/title layout [h1 "Window"] "A Window" The first use of view within an application is special. It displays the window and initializes the graphical interface system. Subsequent calls to VIEW update the window, they do not create new windows unless the /new refinement is provided. view layout [ button "Change" [ view layout [button "Stop" [unview] ] ] The first call to the VIEW function will not return immediately. At that point your code becomes event driven, calling the functions associated with various faces. While the first call to VIEW remains active, any other calls to VIEW will return immediately. The first call will return only after all windows have been closed. Additionally, calls to view can specify options, such as whether the window has borders and is resizable. Single options are provided as a word and multiple options are specified in a block. out: layout [vh1 "This is a window."] view/options out [resize no-title] Related: unview hide show flash inform
wait
wait
Summary: Waits for a duration, port, or both. Synopsis: wait value Arguments: value Refinements:
The value argument. (must be: number time port block none)
/all Description:
Returns all events in a block
If the value is a TIME, delay for that period. If the value is a DATE/TIME, wait until that DATE/TIME. If the value is an INTEGER or DECIMAL, wait that number of seconds. If the value is a PORT, wait for an event from that port. If a block is specified, wait for any of the times or ports to occur. Return the port that caused the wait to complete or return NONE if the timeout occurred.
print now/time wait 1 print now/time wait 0:00:01 print now/time Related: time! date!
what
what
Summary: Prints a list of globally-defined functions. Synopsis: what Arguments: Description: Related: help ?
what-dir
what-dir
Summary: Prints the active directory path Synopsis: what-dir Arguments: Description: Returns the value of system/script/path, the default directory for file operations. print what-dir Related: change-dir make-dir list-dir
while
while
Summary: While a condition block is TRUE, evaluates another block. Synopsis: while cond-block body-block Arguments: cond-block body-block Description:
The cond-block argument. (must be: block) The body-block argument. (must be: block)
BREAK can be used to escape from the block at any point.
str: "string" while [not tail? str: next str] [ print ["length of" str "is" length? str] ] Related: loop repeat for until
within?
within?
Summary: Return TRUE if the point is within the rectangle bounds. Synopsis: within? point offset size Arguments: point offset size Description:
XY position (must be: pair) Offset of area (must be: pair) Size of area (must be: pair)
This function is used to determine if a point is within a graphical area. You provide the position of the point, the upper left corner of the area, and the area's size. The function will return TRUE if the point is within that area, or FALSE otherwise. For example, this returns TRUE because the point 50x50 is within the bounds of the area: print within? 50x50 20x30 200x300
word?
word?
Summary: Returns TRUE for word values. Synopsis: word? value Arguments: value Description:
The value argument. (must be: any-type)
Returns FALSE for all other values. To test for "word:", ":word", or "'word", use the SET?, GET?, and LITERAL? functions. print word? second [1 two "3"] Related: word! type?
write Summary: Writes to a file, url, or port-spec (block or object). Synopsis: write destination value Arguments:
write
destination value Refinements:
The destination argument. (must be: file url object block) The value argument.
/binary /string /direct /append /no-wait /lines /part size /with end-of-line /allow access /mode args /custom params Description:
Preserves contents exactly. Translates all line terminators. Opens the port without buffering. Writes to the end of an existing file. Returns immediately without waiting if no data. Handles data as lines. Reads a specified amount of data. The size argument. (must be: number) Specifies alternate line termination. The end-of-line argument. (must be: char string) Specifies the protection attributes when created. The access argument. (must be: block) Block of above refinements. The args argument. (must be: block) Allows special refinements. The params argument. (must be: block)
WRITE is typically used to write a file to disk, but many other operations, such as writing data to URLs and ports, are possible. Normally a string or binary value is provided to this function, but other types of data such as a number or a time can be written. They will be converted to text. The /BINARY refinement will write out data as its exact representation. This is good for writing image, sound and other binary data. The /STRING refinement translates line terminators to the operating system's line terminator. This behavior is default. The /APPEND refinement is useful logging purposes, as it won't overwrite existing data. The /LINES refinement can take a block of values and will write each value to a line. By default, WRITE will write the block of values as a concatonated string of formed values. The /PART refinement will read the specified number of elements from the data being written. The /WITH refinement converts characters, or strings, specified into line terminators. See the User's Guide for more detailed explanation of using READ and its refinements. write %junkme.txt "This is a junk file." write %datetime.txt now write/binary %data compress "this is compressed data" write %rebol-test-file.r "some text" print read %rebol-test-file.r write/append %rebol-test-file.r "some more text" print read %rebol-test-file.r write %rebol-test-file.r reduce ["the time is:" form now/time] print read %rebol-test-file.r write/lines %rebol-test-file.r reduce ["time is:" form now/time] print read %rebol-test-file.r write/part %rebol-test-file.r "this is the day!" 7
print read %rebol-test-file.r Related: read open close load save file! url! form
write-io
write-io
Summary: Low level write to a port. Synopsis: write-io port buffer length Arguments: port buffer length Description:
Already opened port to write to (must be: port) Buffer to use for write. (must be: any-string) Maximum number of chars to write (must be: number)
???
xor
xor
Summary: Returns the first value exclusive ORed with the second. Synopsis: xor value1 value2 Arguments: value1 value2 Description:
The value1 argument. (must be: logic number char tuple binary image) The value2 argument. (must be: logic number char tuple binary image)
For integers, each bit is exclusively-or'd. For logic values, this is the same as the not-equal function. print 122 xor 1 print true xor false print false xor false print 1.2.3.4 xor 1.0.0.0 Related: and or not
zero?
zero?
Summary: Returns TRUE if the number is zero. Synopsis: zero? number Arguments: number Description:
The number argument. (must be: number pair char money time tuple)
Check the value of a word is zero.
print zero? 50 print zero? 0 Related: positive? negative?