第九章 函数

1.概论
REBOL提供如下几种函数:
        NATIVE、FUNCTION、MEZZANINE、OPERATOR、ROUTINE

2.求值函数
2.1参数
friend: [email protected]
message: "message in a bottle"

send friend message

send [email protected] "message in a bottle"

send friend
** Script Error: send is missing its message argument.
** Where: send friend

send friend message "urgent"

send friend detab copy message

send friend (detab (copy message))

file: %image
insert tail insert file %graphics/ %.jpg
print file
graphics/image.jpg

insert (tail (insert file %graphics/)) %.jpg


2.2参数数据类型
send 1234 "numbers"
** Script Error: send expected address argument of type: email block.
** Where: send 1234 "numbers"

help send
USAGE:
    SEND address message /only /header header-obj
DESCRIPTION:
    Send a message to an address (or block of addresses)
    SEND is a function value.
ARGUMENTS:
    address -- An address or block of addresses (Type: email block)
    message -- Text of message. First line is subject. (Type: any)
REFINEMENTS:
    /only -- Send only one message to multiple addresses
    /header -- Supply your own custom header
        header-obj -- The header to use (Type: object)

send [email protected] $1000.00


2.3精化

copy/part  (copy just part of a string)

find/tail  (return the tail of the match)

load/markup  (return XML/HTML tags and strings)

find/case/tail (match case and return tail)

insert/only/dup (insert entire block multiple times)

string: "no time like the present"
print copy string
no time like the present

print copy/part string 7
no time

help copy
USAGE:
    COPY value /part range /deep
DESCRIPTION:
     Returns a copy of a value.
     COPY is an action value.
ARGUMENTS:
     value -- Usually a series (Type: series port bitset)
REFINEMENTS:
     /part -- Limits to a given length or position.
         range -- (Type: number series port)
     /deep -- Also copies series values within the block.

str: "test"
insert/dup/part str "this one" 4 5
print str
this this this this test

str: "test"
insert/part/dup str "this one" 4 5
print str
thisthisthisthisthistest



猜你喜欢

转载自ch0707.iteye.com/blog/813664