The Main Function in the Ring programming language

Hello

The main function is very important, you need it when you want to write statements that uses local variables instead of the Global scope

Example

x = 10
myfunc()
See “X value = ” + X  # here i expect that x will be (10)
# but i will get another value (6) because myfunc() uses x !
Func myfunc
for x = 1 to 5
See x + nl
next
Output
1
2
3
4
5
X value = 6
Now using the Main function
Func Main
x = 10
myfunc()
See “X value = ” + X

Func myfunc
for x = 1 to 5
See x + nl
next

Output
1
2
3
4
5
X value = 10
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s