Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: Adding functions to an object.

From: al:bri:xtra at: 27-Feb-2002 17:55

Anton wrote:
> ; now, same again except I want the functions to be > ; added to the object. > o: make object! [ > blah: none > include [%library.r [func-one func-two]] > ]
Basically, the reason why your code is failing, is because 'do only returns the last value in the block or file it processes. So the function! value referred to by 'func-one, never appears inside the object. One simple way of do-ing it, is like this: ; Func-one.r func [] [] ; Main code o: make object! [ Func-one: do %Func-one.r ] Another way, if objects are important, is: ; Object-code.r make object! [ Local: none Func-one: func [] [] ] ; Main code o: make do %Object-code.r [ MyCustomValue: 123 ; and so on. ] Note that in both cases, only one function! or object! value is in the included file. If you need more, use more files, or use an object. I hope that helps! Andrew Martin Rebol-bound... ICQ: 26227169