Local and Level

If you're looking for mapping help or you reckon you're a mapping guru, post your questions / solutions here

Moderator: Moderators

Post Reply
omniscient
Major General
Posts: 694
Joined: Tue Sep 16, 2003 12:02 am

Local and Level

Post by omniscient »

okay some variable are named local.variable and some are level.variable
how do u know which one to use?
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

a local variable has meaning only inside the thread it is in . A level variable has the same meaning in all threads . If I had 2 threads like this

level.me = 1
thread thread1
thread thread2

thread1:

local.me = 1
while(1)
{
iprintln " local number 1 is " local.me
wait 2
local.me++
level.me++
}

thread2:

local.me = 100
while(1)
{
iprintln " local number 2 is " local.me
wait 2
local.me++
level.me++
iprinln "level number is " level.me
}

you will get

local number 1 is 1
local number 2 is 100
level number is 3 // both threads add to the level variable

local number 1 is 2
local number 2 is 101
level number is 5

local number 1 is 3
local number 2 is 102
level number is 7

etc etc
omniscient
Major General
Posts: 694
Joined: Tue Sep 16, 2003 12:02 am

Post by omniscient »

thanks a lot, that cleared it up.
Image
Post Reply