How do i take a line of code from the terminal window?

Hi i’ve got my BB2/AtomPro28 set up with a PS2 controller i’ve got the different buttons and sticks giving me different outputs in the Terminal window. I want to use those terminal outputs to turn on/off the pis on my BB2. could anyone help me with how to do this? Here’s a copy of my code:

;-----PS2 Control-----

DAT con P12
CMD con P13
SEL con P14
CLK con P15

index var byte
temp var byte(19)
mode var byte

Forward var byte
Backward var byte
Left var byte
Right var byte

ShoulderL var byte
ShoulderR var byte
ShoulderU var byte
ShoulderD var byte

ElbowU var byte
ElbowD var byte
WristL var byte
WristR var byte

Clawopen var byte
Clawclose var byte

Cameraswitch var byte
lightswitch var byte
powerswitch var byte

;Initialize PS2 Controller
high CLK

low SEL ;makes P14 an output and sets it low (0v) 40
shiftout CMD,CLK,FASTLSBPRE, $1\8,$43\8,$0\8,$1\8,$0\8] ;CONFIG-MODE-ENTER ?configuring the PS2 controller?
high SEL ;makes P14 an output and sets it high (5v)
pause 1

low SEL ;makes P14 an output and sets it low (0v)
shiftout CMD,CLK,FASTLSBPRE, $01\8,$44\8,$00\8,$01\8,$03\8,$00\8,$00\8,$00\8,$00\8] ;SET-MODE-AND-LOCK
high SEL ;makes P14 an output and sets it high (5v)
pause 100

low SEL ;makes P14 an output and sets it low (0v) ;50
shiftout CMD,CLK,FASTLSBPRE, $01\8,$4F\8,$00\8,$FF\8,$FF\8,$03\8,$00\8,$00\8,$00\8] ;SET-DS2-NATIVE-MODE
high SEL ;makes P14 an output and sets it high (5v)
pause 1

low SEL ;makes P14 an output and sets it low (0v)
shiftout CMD,CLK,FASTLSBPRE, $01\8,$43\8,$00\8,$00\8,$5A\8,$5A\8,$5A\8,$5A\8,$5A\8] ;CONFIG-MODE-EXIT-DS2-NATIVE
high SEL ;makes P14 an output and sets it high (5v)
pause 1

low SEL ;makes P14 an output and sets it low (0v) 60
shiftout CMD,CLK,FASTLSBPRE, $01\8,$43\8,$00\8,$00\8,$00\8,$00\8,$00\8,$00\8,$00\8] ;CONFIG-MODE-EXIT
high SEL ;makes P14 an output and sets it high (5v)
pause 10

Main
;-----PS2 Mode-----
low SEL
shiftout CMD,CLK,FASTLSBPRE, $1\8] ;Reading controller mode
shiftin DAT,CLK,FASTLSBPOST, [mode\8]
high SEL ;70

pause 1

;-----PS2 Data-----
low SEL
shiftout CMD,CLK,FASTLSBPRE,$1\8,$42\8] ; reading data from controller
shiftin DAT,CLK,FASTLSBPOST,[temp(0)\8,temp(1)\8,temp(2)\8,temp(3)\8,temp(4)\8,temp(5)\8,temp(6)\8,temp(7)\8,temp(8)\8, |
temp(9)\8,temp(10)\8,temp(11)\8,temp(12)\8,temp(13)\8,temp(14)\8,temp(15)\8,temp(16)\8,temp(17)\8,temp(18)\8]
high SEL

pause 1

;-----Basic Micro IDE terminal------
serout S_OUT,i57600,[13, hex2 mode\2] ; Basic Micro IDE <= 02.2.1.1
for index = 1 to 18 ; temp(0) contains a dummy variable so we don’t send it to the PC
; sending all the data to the PC
serout S_OUT,i57600," ", dec3 temp(index)\3] ; Basic Micro IDE <= 02.2.1.1
next

goto main
;-----Track Moter Control-----

Forward = Temp(6) ;Up = Forward
Backward = Temp(6) ;Down = Back
Left = Temp(5) ;Left = Left
Right = Temp(5) ;Right = Right

;-----Arm Control-----
ShoulderL = Temp(7);D-Left = Shoulder Left
ShoulderR = Temp(8) ;Right = Shoulder Right
ShoulderU = Temp(9) ;Up = Shoulder Out
ShoulderD = Temp(10) ;Down = Shoulder In

ElbowU = Temp(9) + Temp(17) ;Up + L2 = Elbow Out
ElbowD = Temp(10) + Temp(17) ;Down + L2 = Elbow In
WristL = Temp(7) + Temp(17) ;Left + L2 = Wrist Left
WristR = Temp(8) + Temp(17) ;Right + L2 = Wrist Right

Clawopen = Temp(16) ;R1 = Open Claw
Clawclose = Temp(18) ;R2 = Close Claw

;-----Camera Control-----
Cameraswitch = Temp(11).bit5;TRIANGLE Button

;-----Light Control-----
lightswitch = Temp(14).bit5;SQUARE Button

;-----System Control------
powerswitch = Temp(13).bit5;X Button