Introduction
Overview
Installing Rebol
Hello World
Data Types
Built-In Functions
  • append
  • insert
File Handling
Networking

insert

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Insert into the beginning of a string

str: copy " Users"
insert str 100

print str

100 Users

Insert into the end of a string

str: copy "Copyright "
insert tail str now/year

print str

Copyright 2018

Insert into a specific position of a string

str: copy "You have new messages"
insert at str 10 "5 "

print str

You have 5 new messages

Insert a value, up to a specified length, into a string

str: copy "The number Pi is "
num: 3.1415926535
insert/part tail str num 4

print str

The number Pi is 3.14

Insert a value, a specified number of times, into a string

str: copy "1234"
insert/dup str "*" 12

print ["Credit Card Number:" str]

Credit Card Number: ****1234

str: copy " ASCII Art "
insert/dup str "0o" 3
insert/dup tail str "o0" 3

print str

0o0o0o ASCII Art o0o0o0

Insert into the beginning of a block

blk: copy ["rope" "dagger"]
insert blk "key"

prin "Your backpack contains a "

forall blk [
    prin first blk
    if not tail? next blk [prin ", "]
]

Your backpack contains a key, rope, dagger

Insert into the end of a block

blk: copy [
    1 ["name" "John Smith" "age" 35]
    2 ["name" "Mary Smith" "age" 25]
]

insert tail blk [
    3 ["name" "Paul Smith" "age" 45]
]

foreach [id user] blk [
    print [id "-" user/2 "is" user/4]
]

1 - John Smith is 35
2 - Mary Smith is 25
3 - Paul Smith is 45

Insert into a specific position of a block

blk: copy ["Arthur" "Dent"]
insert at blk 2 "Philip"

print form blk

Arthur Philip Dent

Insert a value, up to a specified length, into a block

top: copy []
all: copy [99 "REN" 92 "NTS" 84 "WFG" 78 "BGO" 68 "PKD" 42 "APD"]
insert/part top all 6

print "Top 3 Scores"

forskip top 2 [print ["**" first top second top "**"]]

Top 3 Scores
** 99 REN **
** 92 NTS **
** 84 WFG **

Insert a value, a specified number of times, into a block

blk: copy []

random/seed now
num: random 3

insert/dup blk "... ><((('>" num

print ["You have caught" num "fish!"]
print form blk

You have caught 3 fish!
… ><(((‘> … ><(((‘> … ><(((‘>

TODO: Add description

avatar: copy ["Name" "Adventure Hero" "Spells" "Equipment"]
spells: copy ["Summoning the Daemon Spirits" "Scourge of Invisible Hemiptera"]
insert/only next find avatar "spells" spells

print "Avatar Profile"

foreach [key val] avatar [
    if void? :val [val: "None"]
    
    print ["^/ " key]
    
    either block? val [
        foreach item val [print ["   " item]]
    ][
        print ["   " val]
    ]
]

TODO

Copyright © 2018 Rebol Software Foundation