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

[REBOL] Re: Return of a function

From: ingo::2b1::de at: 19-Apr-2002 13:11

Hi Philippe, Philippe Oehler wrote:
> Why hm is local to function ? There's no /local refinement + The hm is > called outside. So in my understanding, hm shouldn't be local..
_All_ arguments to functions are local to that function. Think about it: do you really want all arguments to functions be defined in the global context? hm is not _called_ outside the function, it only gets its _value_ from outside.
> So what I have to do to have a global variable ??
In Rebol, by default, everything is global, except when explicitly noted. So, for you, just just change it like this: transfo-time: func [hm-arg] [ hm: parse hm-arg "." hm/1: to-integer hm/1 hm/2: to-integer hm/2 hm: to-time join hm/1 [":" hm/2] hm ] Now hm is not explicitly listed as local, and thus it's global. (A word to the wise, I would _not_ recommend to program it this way.)
> why do u write heure: transfo-time heure.. ?
transfo-time returns the last value, which is hm. Now Sunanda sets the word heure - which held the time string in the beginning - to the value returned by transfo-time, which is the computed time value. I hope that helps, Ingo