Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Understanding scope of variables
#2
Actually, my question is more related to subroutines than functions. So, is the following code valid:

Code:
sub myFunction( byref total as uinteger, name$ as string )     dim length, n as ubyte     length = len(name$)     if length=0 then return     end if     for n = 0 to length-1 total = total + code(name$(n))     next n         return end sub REM Main program dim n as ubyte dim total as uinteger n = 14 myFunction(total, "Hello") print "Answer = " + str$(total) print "n = " + str$(n) stop
---with variables labelled 'n' in both the main program and the subroutine.

Thanks again
Reply


Messages In This Thread
Understanding scope of variables - by georgeo - 2021-03-11, 02:51 PM
RE: Understanding scope of variables - by georgeo - 2021-03-12, 12:13 AM
RE: Understanding scope of variables - by boriel - 2021-03-12, 11:32 PM
RE: Understanding scope of variables - by boriel - 2021-03-12, 11:26 PM
RE: Understanding scope of variables - by georgeo - 2021-03-13, 11:48 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)