File: subroutine_global.kbs

package info (click to toggle)
basic256 2.0.99.10-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,888 kB
  • sloc: cpp: 17,185; yacc: 4,025; lex: 1,466; java: 1,091; sh: 39; xml: 33; makefile: 20
file content (32 lines) | stat: -rw-r--r-- 664 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# subroutine_global - test local and global variables
# 2012-10-06 j.m.reneau

# we should see the global variables change in the "changeroo" but not the others

global a,b$
a = 0
b$ = "a's original value is zero"
c = 1
d$ = "c's original value is one"

call display(a,b$)
call display(c,d$)
call changeroo()
call display(a,b$)
call display(c,d$)

end

subroutine display(c,d$)
   # c and d$ are not global - so local to the subroutine
   print c + " " + d$
end subroutine

subroutine changeroo()
   # change a,b$,c,d$
   # only the global variables should be changed
   a = 2
   b$ = "a's new value is two"
   c = 3
   d$ = "c's new value is three"
end subroutine