From: Jake McArthur Date: 2006-05-25T03:24:43+09:00 Subject: Re: ifs and scope On May 24, 2006, at 1:13 PM, newbie wrote: > if (something) > #do a bunch of stuff > firstif = TRUE > end > > if (somethingelse && firstif) > # the above always fails since the second if doesn't see firstif) > #do other stuff that is dependent on the first bunch of stuff > firstif = FALSE > end Two ways to do this. First way: if (something) #do a bunch of stuff if (somethingelse) #do more stuff end end If you can't just nest them for one reason or another, here is another way: firstif if (something) #do a bunch of stuff firstif = true end if (somethingelse && firstif) # the above always fails since the second if doesn't see firstif) #do other stuff that is dependent on the first bunch of stuff firstif = false end Notice that mentioning the variable outside of the scope makes it available to both ifs. - Jake McArthur