;ROOMMATES IN A HAT ;SPEC: Every roommate gets a respective weight, based on which two are chosen (not the same two) ; to clean the house. ; Using a "pseudo-array" of strings bsaed on $ROOMMATE[1-6], we'll prompt the ; caller for a weight [1-9], and make a corresponding array of integers (called $MATEWEIGT[1-6]). ; Finally, bsaed on roommates weight, roommates are given a relative probability of drawing the ; cleaning straw. ; ;PROBLEM: The gotoif command that is invoked ater we pick a winner is non-cuntional, and I'm told in ;the CLI that my syntax is off. Since it fails on a different roomate every time I know that I am ;picking a winner, but no matter how i form that goto command i still get the same crash. The CLI ;output is at the bottom. [riah] ;who are the roommates? exten => s,1,set(__ROOMMATE[1]=Brad) exten => s,2,set(__ROOMMATE[2]=Brian) exten => s,3,set(__ROOMMATE[3]=James) exten => s,4,set(__ROOMMATE[4]=Jeff) exten => s,5,set(__ROOMMATE[5]=Marc) exten => s,6,set(__ROOMMATE[6]=Aubrey) ;for each roommate prompt for a weight exten => s,7,set(__COUNT=1) ;set roommate counter exten => s,8,while($[${COUNT}<7]) ;while we havent assigned a weight to all the roommates... exten => s,9,background(beep) ;prompt with a tone... exten => s,10,waitexten(5) ;and givem five seconds to enter an extension 0-9 exten => s,11,set(__COUNT=$[${COUNT}+1]) ;then increment the counter exten => s,12,endwhile ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;take the weight and build the array;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; exten => _X,1,set(__MATEWEIGHT[${COUNT}]= ${EXTEN}) ;give each roommate a relative weight using the counter exten => _X,n,goto(s,11) ;then repeat ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;after weights are assigned, pick roommates until we have two winners exten => s,13,set(__WINNERS=0) ;at first we have no winners exten => s,14,set(__CLEANER[1]=NoOne) ;and we'll use a new counter exten => s,15,while($[${WINNERS} < 2]) ;while we dont have two winners... exten => s,16,noop(${CLEANER[1]}) exten => s,17,goto(Brad,1) ;go to an extension based on roommate name below exten => s,18,goto(Brian,1) ;go to an extension based on roommate name below exten => s,19,goto(James,1) ;go to an extension based on roommate name below exten => s,20,goto(Jeff,1) ;go to an extension based on roommate name below exten => s,21,goto(Marc,1) ;go to an extension based on roommate name below exten => s,22,goto(Aubrey,1) ;go to an extension based on roommate name below exten => s,23,noop(END OF THE LOOP. HOW MANY WINNERS? ${WINNERS}) exten => s,24,endwhile ;;;;;;;;Go to exten ${ROOMMATEN[1-6], and use their weight to "draw" for a "win";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; exten => Brad,1,noop(we made it here ${CLEANER[1]}) ;jump to three if we have a winner exten => Brad,2,random(${MATEWEIGHT[1]},Brad,3) ;jump to three if we have a winner exten => Brad,3,goto(s,18) ;or else draw again. exten => Brad,4,gotoif($[ "${CLEANER[1]}" = "Brad"]?3) ;did we just pick him? exten => Brad,5,set(__WINNERS=$[${WINNERS}+1]) ;if not we have a winner exten => Brad,6,set(__CLEANER[${WINNERS}]=${ROOMMATE[1]}) ;and we set the CLEANER variable exten => Brad,7,noop("we made it here). ;and draw again exten => Brad,8,goto(s,18) ;and draw again ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;Go to exten ${ROOMMATEN[1-6], and use their weight to "draw" for a "win";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; exten => Brian,1,random(${MATEWEIGHT[2]},Brian,3) ;jump to three if we have a winner exten => Brian,2,goto(s,19) ;or else draw again. exten => Brian,3,gotoif($[ "${CLEANER[1]}" = "Brian"]?2) ;did we just pick him? exten => Brian,4,set(__WINNERS=$[${WINNERS}+1]) ;if not we have a winner exten => Brian,5,set(__CLEANER[${WINNERS}]=${ROOMMATE[2]}) ;and we set the CLEANER variable exten => Brian,6,goto(s,19) ;and draw again ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;Go to exten ${ROOMMATEN[1-6], and use their weight to "draw" for a "win";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; exten => James,1,random(${MATEWEIGHT[3]},James,3) ;jump to three if we have a winner exten => James,2,goto(s,20) ;or else draw again. exten => James,3,gotoif($[ "${CLEANER[1]}"="James"]?2) ;did we just pick him? exten => James,4,set(__WINNERS=$[${WINNERS}+1]) ;if not we have a winner exten => James,5,set(__CLEANER[${WINNERS}]=${ROOMMATE[3]}) ;and we set the CLEANER variable exten => James,6,goto(s,20) ;and draw again ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;Go to exten ${ROOMMATEN[1-6], and use their weight to "draw" for a "win";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; exten => James,1,random(${MATEWEIGHT[3]},James,3) ;jump to three if we have a winner exten => James,2,goto(s,20) ;or else draw again. exten => James,3,gotoif($[ "${CLEANER[1]}"="James"]?2) ;did we just pick him? exten => James,4,set(__WINNERS=$[${WINNERS}+1]) ;if not we have a winner exten => James,5,set(__CLEANER[${WINNERS}]=${ROOMMATE[3]}) ;and we set the CLEANER variable exten => James,6,goto(s,20) ;and draw again ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;Go to exten ${ROOMMATEN[1-6], and use their weight to "draw" for a "win";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; exten => Jeff,1,random(${MATEWEIGHT[4]},Jeff,3) ;jump to three if we have a winner exten => Jeff,2,goto(s,21) ;or else draw again. exten => Jeff,3,gotoif($[ "${CLEANER[1]}"="Jeff"]?2) ;did we just pick him? exten => Jeff,4,set(__WINNERS=$[${WINNERS}+1]) ;if not we have a winner exten => Jeff,5,set(__CLEANER[${WINNERS}]=${ROOMMATE[4]}) ;and we set the CLEANER variable exten => Jeff,6,goto(s,21) ;and draw again ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;Go to exten ${ROOMMATEN[1-6], and use their weight to "draw" for a "win";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; exten => Marc,1,random(${MATEWEIGHT[5]},Marc,3) ;jump to three if we have a winner exten => Marc,2,goto(s,22) ;or else draw again. exten => Marc,3,gotoif($[ "${CLEANER[1]}"="Marc"]?2) ;did we just pick him? exten => Marc,4,set(__WINNERS=$[${WINNERS}+1]) ;if not we have a winner exten => Marc,5,set(__CLEANER[${WINNERS}]=${ROOMMATE[5]}) ;and we set the CLEANER variable exten => Marc,6,goto(s,22) ;and draw again ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;Go to exten ${ROOMMATEN[1-6], and use their weight to "draw" for a "win";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; exten => Aubrey,1,random(${MATEWEIGHT[6]},Aubrey,3) ;jump to three if we have a winner exten => Aubrey,2,goto(s,23) ;or else draw again. exten => Aubrey,3,gotoif($[ "${CLEANER[1]}"="Aubrey"]?2) ;did we just pick him? exten => Aubrey,4,set(__WINNERS=$[${WINNERS}+1]) ;if not we have a winner exten => Aubrey,5,set(__CLEANER[${WINNERS}]=${ROOMMATE[6]}) ;and we set the CLEANER variable exten => Aubrey,6,goto(s,23) ;and draw again ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;spit out the winners at the end exten => s,25,noop(${CLEANER[1]} and ${CLEANER[2]} are the winners.) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CLI OUTPUT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; == Parsing '/etc/asterisk/sip_notify.conf': Found -- Executing Goto("SIP/Brian-be1d", "riah|s|1") in new stack -- Goto (riah,s,1) -- Executing Set("SIP/Brian-be1d", "__ROOMMATE[1]=Brad") in new stack -- Executing Set("SIP/Brian-be1d", "__ROOMMATE[2]=Brian") in new stack -- Executing Set("SIP/Brian-be1d", "__ROOMMATE[3]=James") in new stack -- Executing Set("SIP/Brian-be1d", "__ROOMMATE[4]=Jeff") in new stack -- Executing Set("SIP/Brian-be1d", "__ROOMMATE[5]=Marc") in new stack -- Executing Set("SIP/Brian-be1d", "__ROOMMATE[6]=Aubrey") in new stack -- Executing Set("SIP/Brian-be1d", "__COUNT=1") in new stack -- Executing While("SIP/Brian-be1d", "1") in new stack -- Executing BackGround("SIP/Brian-be1d", "beep") in new stack -- Playing 'beep' (language 'en') -- Executing WaitExten("SIP/Brian-be1d", "5") in new stack == CDR updated on SIP/Brian-be1d -- Executing Set("SIP/Brian-be1d", "__MATEWEIGHT[1]= 9") in new stack -- Executing Goto("SIP/Brian-be1d", "s|11") in new stack -- Goto (riah,s,11) -- Executing Set("SIP/Brian-be1d", "__COUNT=2") in new stack -- Executing EndWhile("SIP/Brian-be1d", "") in new stack -- Executing While("SIP/Brian-be1d", "1") in new stack -- Executing BackGround("SIP/Brian-be1d", "beep") in new stack -- Playing 'beep' (language 'en') -- Executing WaitExten("SIP/Brian-be1d", "5") in new stack == CDR updated on SIP/Brian-be1d -- Executing Set("SIP/Brian-be1d", "__MATEWEIGHT[2]= 9") in new stack -- Executing Goto("SIP/Brian-be1d", "s|11") in new stack -- Goto (riah,s,11) -- Executing Set("SIP/Brian-be1d", "__COUNT=3") in new stack -- Executing EndWhile("SIP/Brian-be1d", "") in new stack -- Executing While("SIP/Brian-be1d", "1") in new stack -- Executing BackGround("SIP/Brian-be1d", "beep") in new stack -- Playing 'beep' (language 'en') -- Executing WaitExten("SIP/Brian-be1d", "5") in new stack == CDR updated on SIP/Brian-be1d -- Executing Set("SIP/Brian-be1d", "__MATEWEIGHT[3]= 0") in new stack -- Executing Goto("SIP/Brian-be1d", "s|11") in new stack -- Goto (riah,s,11) -- Executing Set("SIP/Brian-be1d", "__COUNT=4") in new stack -- Executing EndWhile("SIP/Brian-be1d", "") in new stack -- Executing While("SIP/Brian-be1d", "1") in new stack -- Executing BackGround("SIP/Brian-be1d", "beep") in new stack -- Playing 'beep' (language 'en') -- Executing WaitExten("SIP/Brian-be1d", "5") in new stack == CDR updated on SIP/Brian-be1d -- Executing Set("SIP/Brian-be1d", "__MATEWEIGHT[4]= 0") in new stack -- Executing Goto("SIP/Brian-be1d", "s|11") in new stack -- Goto (riah,s,11) -- Executing Set("SIP/Brian-be1d", "__COUNT=5") in new stack -- Executing EndWhile("SIP/Brian-be1d", "") in new stack -- Executing While("SIP/Brian-be1d", "1") in new stack -- Executing BackGround("SIP/Brian-be1d", "beep") in new stack -- Playing 'beep' (language 'en') -- Executing WaitExten("SIP/Brian-be1d", "5") in new stack == CDR updated on SIP/Brian-be1d -- Executing Set("SIP/Brian-be1d", "__MATEWEIGHT[5]= 0") in new stack -- Executing Goto("SIP/Brian-be1d", "s|11") in new stack -- Goto (riah,s,11) -- Executing Set("SIP/Brian-be1d", "__COUNT=6") in new stack -- Executing EndWhile("SIP/Brian-be1d", "") in new stack -- Executing While("SIP/Brian-be1d", "1") in new stack -- Executing BackGround("SIP/Brian-be1d", "beep") in new stack -- Playing 'beep' (language 'en') -- Executing WaitExten("SIP/Brian-be1d", "5") in new stack == CDR updated on SIP/Brian-be1d -- Executing Set("SIP/Brian-be1d", "__MATEWEIGHT[6]= 0") in new stack -- Executing Goto("SIP/Brian-be1d", "s|11") in new stack -- Goto (riah,s,11) -- Executing Set("SIP/Brian-be1d", "__COUNT=7") in new stack -- Executing EndWhile("SIP/Brian-be1d", "") in new stack -- Executing While("SIP/Brian-be1d", "0") in new stack -- Executing Set("SIP/Brian-be1d", "__WINNERS=0") in new stack -- Executing Set("SIP/Brian-be1d", "__CLEANER[1]=NoOne") in new stack -- Executing While("SIP/Brian-be1d", "1") in new stack -- Executing NoOp("SIP/Brian-be1d", "NoOne") in new stack -- Executing Goto("SIP/Brian-be1d", "Brad|1") in new stack -- Goto (riah,Brad,1) -- Executing NoOp("SIP/Brian-be1d", "we made it here NoOne") in new stack -- Executing Random("SIP/Brian-be1d", " 9|Brad|3") in new stack -- Executing Goto("SIP/Brian-be1d", "s|18") in new stack -- Goto (riah,s,18) -- Executing Goto("SIP/Brian-be1d", "Brian|1") in new stack -- Goto (riah,Brian,1) -- Executing Random("SIP/Brian-be1d", " 9|Brian|3") in new stack -- Executing Goto("SIP/Brian-be1d", "s|19") in new stack -- Goto (riah,s,19) -- Executing Goto("SIP/Brian-be1d", "James|1") in new stack -- Goto (riah,James,1) -- Executing Random("SIP/Brian-be1d", " 0|James|3") in new stack -- Executing Goto("SIP/Brian-be1d", "s|20") in new stack -- Goto (riah,s,20) -- Executing Goto("SIP/Brian-be1d", "Jeff|1") in new stack -- Goto (riah,Jeff,1) -- Executing Random("SIP/Brian-be1d", " 0|Jeff|3") in new stack -- Executing Goto("SIP/Brian-be1d", "s|21") in new stack -- Goto (riah,s,21) -- Executing Goto("SIP/Brian-be1d", "Marc|1") in new stack -- Goto (riah,Marc,1) -- Executing Random("SIP/Brian-be1d", " 0|Marc|3") in new stack -- Executing Goto("SIP/Brian-be1d", "s|22") in new stack -- Goto (riah,s,22) -- Executing Goto("SIP/Brian-be1d", "Aubrey|1") in new stack -- Goto (riah,Aubrey,1) -- Executing Random("SIP/Brian-be1d", " 0|Aubrey|3") in new stack -- Executing Goto("SIP/Brian-be1d", "s|23") in new stack -- Goto (riah,s,23) -- Executing NoOp("SIP/Brian-be1d", "END OF THE LOOP. HOW MANY WINNERS? 0") in new stack -- Executing EndWhile("SIP/Brian-be1d", "") in new stack -- Executing While("SIP/Brian-be1d", "1") in new stack -- Executing NoOp("SIP/Brian-be1d", "NoOne") in new stack -- Executing Goto("SIP/Brian-be1d", "Brad|1") in new stack -- Goto (riah,Brad,1) -- Executing NoOp("SIP/Brian-be1d", "we made it here NoOne") in new stack -- Executing Random("SIP/Brian-be1d", " 9|Brad|3") in new stack -- Executing Goto("SIP/Brian-be1d", "s|18") in new stack -- Goto (riah,s,18) -- Executing Goto("SIP/Brian-be1d", "Brian|1") in new stack -- Goto (riah,Brian,1) -- Executing Random("SIP/Brian-be1d", " 9|Brian|3") in new stack Apr 17 04:46:45 WARNING[2082]: pbx.c:6455 ast_parseable_goto: Goto requires an argument (optional context|optional extension|priority) -- Random branches to (riah,Brian,2) == Spawn extension (riah, Brian, 1) exited non-zero on 'SIP/Brian-be1d'