Problem with key-press vars in GotoIf's to jump between contexts

I have FreePBX 2.8.1.5 with Asterisk 1.8.11. Everything works
great and I have: SPA3102, SPA2102, and softphones all working together.
I don’t use a SIP provider. My setup mainly bridges my PBX with the PSTN.

I do have an “extensions_custom.conf” customization issue:

I can’t use key-press variables to jump between contexts. I’ve based my file
off of several examples I’ve found on-line. I don’t want my main IVR logic scattered in the
extension blocks. I want them in a central block within a single context.
I use vi in the Linux CLI for editing the “extensions_custom.conf” file.
Here is what I’m trying to accomplish:

  1. Internal caller dials 778 and gets IVR menu with these selections:
    a. Press 4 to reach #4 misc. dest. (forthcoming weather AGI)
    b. Press 7 to reach #7 misc. dest. (forthcoming sys. uptime AGI)
    c. Press 8 to hangup
    d. Press 9 to reach #9 misc. dest. (forthcoming water gauge AGI)

Below is my code with comments. It may also need some heirarchy tweaks.
Thanks. --jay555

11/26/2012 update: All GotoIf’s work. Using: “same => n,” to start the GotoIf lines
made a difference. Using the “NoOp” for debugging also helped. These questions remain:

  1. Why do my GotoIf’s only work if within the extension block? Why do they also only work
    when inter-context if they are preceded by a Goto?

  2. Is there a better way to capture key press values besides setting a var in an extension block or using EXTEN? I’ve seen Numpress(reserved word?) and ACCEPT used but I’ve had no luck with them.

#********************************************************************

BEGIN - Test Simple IVR Menu (/etc/asterisk/extensions_custom.conf)

#--------------------------------------------------------------------

[subTest1-pressed]
exten => 7,1,Wait(1)
same => n,Set(dtmf-pressed=7)
same => n,SayDigits(${dtmf-pressed}) ; works
same => n,WaitExten(2)
same => n,GotoIf($["${dtmf-pressed}" = “7”]?subTest1-seven,1,1:ivrTest1-menu,778,2) ; WORKS!

exten => 8,1,Wait(1)
same => n,Set(dtmf-pressed=8)
same => n,SayDigits(${dtmf-pressed}) ; line works
same => n,WaitExten(1)
same => n,Goto(subTest1-main,1,1) ; this works

same => n,Goto(subTest1-hangup,1,1) ; works, but commented

same => n,GotoIf($[${dtmf-pressed} = 8]?subTest1-hangup,1,1) ; works

exten => 9,1,Wait(1)
same => n,Set(dtmf-pressed=9)
same => n,SayDigits(${dtmf-pressed}) ; works
same => n,WaitExten(1)
same => n,Goto(subTest1-main,1,1) ; this works

[ivrTest1-menu]
;4 7 8 9 ph button presses
include => subTest1-hangup
include => subTest1-nine
include => subTest1-seven
include => subTest1-pressed
include => subTest1-main
exten => _778,1,Answer
exten => _778,2,Wait(1)
exten => _778,3,SayDigits(${EXTEN}) ; works, says: 778
exten => _778,4,Wait(2)
exten => _778,5,Set(COUNT=1) ; works
exten => _778,6(start),Background(number)
exten => _778,7,SayDigits(${COUNT}) ; works, for debugging
exten => _778,8,Background(Press1-2-5-6-test-ivr) ; --custom audio menu–
exten => _778,9,Wait(1)
exten => _778,10,WaitExten(2)
#exten => _778,n,GotoIf($["${dtmf-pressed}" = “8”]?subTest1-hangup,1,1) ; doesn’t work, releases call
#exten => _778,n,GotoIf($["${dtmf-pressed}" = “9”]?subTest1-nine,1,1:ivrTest1-menu,778,2) ; doesn’t work, releases call
#exten => _778,10,Set(COUNT=$[${COUNT} + 1])
#exten => _778,11,Wait(1)
#exten => _778,12,SayDigits(${COUNT}) ; works, says: 2
#exten => _778,11,Goto(ivrTest1-menu,778,2) ; works
exten => _778,11,GotoIf($[${COUNT} < 3]?:subTest1-hangup,1,1) ; works now
exten => _778,12,Background(count) ; works
exten => _778,13,SayNumber(${COUNT}) ; works, for debugging
exten => _778,14,Set(COUNT=$[${COUNT} + 1])
exten => _778,15,Goto(start) ; works

same => n(goodbye),Hangup()

exten => _4,1,Wait(1)
exten => _4,2,Background(you-entered) ; works
same => n,SayDigits(${EXTEN}) ; works says: 4
same => n,Wait(1)
same => n,Goto(ivrTest1-menu,778,1) ; works

[subTest1-main]

main menu test

exten => 1,1,Wait(1)
same => n,NoOp(dtmf-pressed = ${dtmf-pressed})
same => n,NoOp(RINGTIME = ${RINGTIME})
same => n,NoOp(CHANNEL = ${CHANNEL})
same => n,NoOp(CONTEXT = ${CONTEXT})
same => n,NoOp(DIALEDTIME = ${DIALEDTIME})
same => n,NoOp(PRIORITY = ${PRIORITY})
same => n,NoOp(TRANSFERCAPABILITY = ${TRANSFERCAPABILITY})
same => n,NoOp(ANSWEREDTIME = ${ANSWEREDTIME})
same => n,NoOp(SIPCALLID = ${SIPCALLID})
same => n,NoOp(SIPUSERAGENT = ${SIPUSERAGENT})
same => n,GotoIf($[${dtmf-pressed} = 8]?subTest1-hangup,1,1) ; works
same => n,GotoIf($[${dtmf-pressed} = 9]?subTest1-nine,1,1:ivrTest1-menu,778,2) ; works

[subTest1-seven]

should press 7 to get here…works

exten => 1,1,Wait(1)
exten => 1,2,Background(you-entered) ; works
exten => 1,3,Playback(digits/7) ; works
exten => 1,4,Wait(1)
exten => 1,5,Goto(ivrTest1-menu,778,1) ;works

[subTest1-hangup]

should press 8 to get here…works

exten => 1,1,Wait(1)
exten => 1,2,Playback(digits/8)
exten => 1,3,Wait(1)
exten => 1,4,Background(to-hang-up)
exten => 1,5,Wait(1)
exten => 1,6,Background(goodbye)
exten => 1,7,Wait(1)
exten => 1,8,Hangup

[subTest1-nine]

should press 9 to get here…works

exten => 1,1,Wait(1)
exten => 1,2,Background(you-entered)
exten => 1,3,Playback(digits/9)
exten => 1,4,Wait(1)
exten => 1,5,Goto(ivrTest1-menu,778,1)

#--------------------------------------------------------------------

END - Test Simple IVR Menu (/etc/asterisk/extensions_custom.conf)

#********************************************************************