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

[REBOL] Re: Setting global from within a function.

From: ryanc:iesco-dms at: 8-Feb-2001 11:34

You probably had the right idea the first time... watch close
>> n: [1 2]
== [1 2]
>> the-funk: func [the-input] [
[ if (first the-input) = 2 [ n: 42 ] [ ]
>> the-funk n
== none
>> n
== [1 2]
>> ;correct answer, nothing happened >> the-funk head reverse n
== 42
>> n
== 42
>>;correct answer too.
If you have'nt got it yet, you were looking for 2, which was at the second position (second n). By using the head reverse instructions I actually passed [2 1] to your function causing n to be set. The REBOL part is easy, not making those damn logic errors is the difficult part! --Ryan Terry Brownell wrote:
> Hello all. > > Another question. > > How do you set a global word from a func word eg; > > n: [1 2] > > the-funk: func [the-input][ > if (first the-input) = 2 [ > {Set the global value of the-input, in this case N, to som > ething? eg: 42} > ] > ] > > the-funk n > > >> n > == 42 > > Thanks. > Terry Brownell > > -- > To unsubscribe from this list, please send an email to > [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Ryan Cole Programmer Analyst www.iesco-dms.com 707-468-5400 I am enough of an artist to draw freely upon my imagination. Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world. -Einstein