[REBOL] Re: Return of a function
From: sunandadh:aol at: 19-Apr-2002 6:09
Philippe:
> 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..
> So what I have to do to have a global variable ??
Hm is the _local _name for the _value_ (not, in this case, variable) passed
in.
What is returned is a _value_ not a variable. Try this:
test-func: func [value] [
value: value + 200
return value
]
print test-func 100
print value
the first 'print correctly prints 300. The second fails as the word 'value
only has a meaning within the function. If you want a global variable 'value
too, then:
value: test-func 100
print value ;; prints the global 'value, ie 300
another-value: test-func 500
print another-value ;; prints 700
print value ;; prints 300. Changing 'value in the func doesn't affect the
global variable
Sunanda.