Variable Scope

new topic     » topic index » view thread      » older message » newer message

Hey everybody, surprise!!!  Another question!!

I read over the part of the manual about variable scope and just want to
bounce this off everybody to make sure I'm comprehending it correctly.

Let's say I have the following:

function somefunc(integer C)
  integer a,b,c

  a=1
  b=2
  c=3
return c
end function

Ok, now in my main program, because c was returned, I'll be able to "see" that
c=3.  However, because a and b are "local" to the function, I cannot, for
instance, in my main program do:

a=a+1

and expect to get a=2 as a result.  I think I already know this cause Euphoria
already told me that a is not defined.

However, if I do this:

function somefunc(integer C)
  global integer a,b,c

  a=1
  b=2
  c=3
return c
end function

When I return from to my main program, I should be able to "see" that
a=1, b=2, etc. even though those variables weren't returned?

Thanks for the patience!!
Rich

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu