Variables not readable outside if statement

I wrote a small app that opens a shell script, sets it to background, and then allows the user to exit that same background script. The problem is that anything that is stored to the “pid” variable in the first if block can’t be read by anything in the else if block below.

property pid : 2

on clicked theObject
   if title of theObject = "Activate" then
       do shell script "/Dev/ClearPDF/ &> /dev/null & echo $!"
       set pid to the result
       -- #1
       do shell script "renice +20 -p " & pid
       --do shell script "kill " & pid
   else if title of theObject = "Restore" then
       -- #2
       display dialog pid
       --do shell script "kill " & pid
   end if
end clicked

on choose menu item theObject
   display dialog "Help"
   -- #3
   display dialog pid
end choose menu item

Here’s the wierd thing:

#1 → Stores the correct PID value.
#2 → Stores nothing (AppleScript gives “pid not defined” error).
#3 → Stores the correct PID value.

I’ve gone over all the scope rules several times and I still can’t figure this out. PLEASE help!

MacBook Pro, OS X 10.4.8, Xcode 2.4.1. All running the most recent updates.

Model: MacBook Pro, 2.33GHz Core 2 Duo, 2 GB RAM, 160 GB HDD
AppleScript: Xcode 2.4.1
Browser: Safari 419.3
Operating System: Mac OS X (10.4)