Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

crat

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

script an object using bind

Suppose you have a robot object with methods like
move , attack etc. You can store a "script" in a block to automate the object

   1  
   2  rebol []
   3  
   4  robot: make object! [
   5  move: func [amount] [...] ; whatever
   6  turn: func [angle][..] 
   7  fire: func [] [...]
   8  run: func [code][
   9                     do bind code 'self
  10  ]
  11  ]
  12  
  13  script: [
  14             move 100
  15             turn 45
  16             fire
  17             turn 23
  18             move 34
  19  ]
  20  ; etc
  21  
  22  robbie: make robot []
  23  
  24  robbie/run script
  25  
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS