BASIC4PPC  COMPILER
PROGRAM  EXAMPLE:


10 USER DEFINED
CUSTOM BUTTONS
This program example will
let you defined 10 custom
keys that you can use to
send ASCII characters to
the BlueSmiRF module
using a wireless Bluetooth serial port link.
The Pocket PC used in this example is an HP IPAQ H2200 PDA with:

     64 MB of system RAM
     32 MB of system flash ROM  ( Dated: 5/22/2003 )
     OS Version:  Windows CE 4.20
     Display Resolution:  240 horizontal pixels  by  320 vertical pixels
     Processor Type:  Intel PXA255
     Bluetooth
     1 SDIO Card Slot
     1 Compact Flash Card Slot
     Headset / Microphone Jack

This HP H2200 PDA was manufactured in 2003.  Any of the newer Pocket PCs with Bluetooth
capability running the latest version of the Basic4ppc Compiler should be able to run this simple
program example.

The embedded bluetooth hardware module used in this example is a BlueSmiRF module.  You
can search the Internet and find a variety of embedded bluetooth module boards and fully
packaged plug-and-go bluetooth dongles.

The microcontroller used in this example is the: Athena.  The Athena micro is a PIC microcontroller
that is pre-programmed with a BASIC Interpreter.  The Athena can be programmed easily in BASIC
using the IDE software written to run on a Windows compatible desktop PC or laptop.
BASIC4PPC Program Code Listing: No Comments
Sub Globals
        blip_color=5
        tmr_flag=0
        tmr_count=0
        tmr_count_1=0
        tmr_count_2=0
        msdelay=0
        portflag = 0
        strlabel0="COM 8: 9600,N,8,1"
        strlabel1=" [OFF]"
        strlabel2=" [ ON]"
        strlabeltemp=""
        strval=""        
        x=0
        portflag = 0

        PGM_1_FLAG = 0
        PGM_2_FLAG = 0
        PGM_3_FLAG = 0
        PGM_4_FLAG = 0
        PGM_5_FLAG = 0
        PGM_6_FLAG = 0
        PGM_7_FLAG = 0
        PGM_8_FLAG = 0
        PGM_9_FLAG = 0
        PGM_10_FLAG = 0

        PGM_1_TEXT = ""
        PGM_2_TEXT = ""
        PGM_3_TEXT = ""
        PGM_4_TEXT = ""
        PGM_5_TEXT = ""
        PGM_6_TEXT = ""
        PGM_7_TEXT = ""
        PGM_8_TEXT = ""
        PGM_9_TEXT = ""
        PGM_10_TEXT = ""
        
        PGM_1_VALUE = ""
        PGM_2_VALUE = ""
        PGM_3_VALUE = ""
        PGM_4_VALUE = ""
        PGM_5_VALUE = ""
        PGM_6_VALUE = ""
        PGM_7_VALUE = ""
        PGM_8_VALUE = ""
        PGM_9_VALUE = ""
        PGM_10_VALUE = ""
End Sub

Sub App_Start
      Form1.show
      label1.color=128,255,128
      Textbox1.Text=""
      Textbox2.Text=""
      serial.New2 (8,9600,"N",8,1)
      Sip(False)
End Sub

Sub ImageButtonSipOn_ButtonDown
    image4.Image="r28w35.jpg"
End Sub

Sub ImageButtonSipOn_ButtonUp
    image4.Image="w28w35.jpg"
End Sub

Sub ImageButtonSipOn_Click
    Sip(true)
End Sub

Sub ImageButtonSipOff_ButtonDown
    image5.Image="r28w35.jpg"
End Sub

Sub ImageButtonSipOff_ButtonUp
    image5.Image="w28w35.jpg"
End Sub

Sub ImageButtonSipOff_Click
    Sip(False)
End Sub

Sub ImageButtonSendTX_Click
    serial.Output (textbox1.Text)
End Sub

Sub ImageButtonSendTX_ButtonDown
    image3.Image="r28w35.jpg"
End Sub

Sub ImageButtonSendTX_ButtonUp
    image3.Image="w28w35.jpg"
End Sub

Sub ImageButtonOpen_ButtonDown
    image1.Image="r28w35.jpg"
    image2.Image="w28w35.jpg"
End Sub

Sub ImageButtonOpen_Click
    Sip(false)
    If portflag = 0 Then
       serial.PortOpen=true
       portflag = 1
       serial.enableoncomm=true
       serial.Output ("*")
    End If
    Sip(true)
End Sub

Sub ImageButtonClose_ButtonDown
    image1.Image="w28w35.jpg"
    image2.Image="r28w35.jpg"
End Sub

Sub ImageButtonClose_Click
    If portflag = 1 Then
       TextBox1.Text=""
       serial.Output ("^")
       serial.enableoncomm=false
       serial.PortOpen=false
       portflag = 0
    End If
End Sub

Sub ImageButtonPGMEnter1_Click
    If PGM_1_FLAG=1 Then
        PGM_1_TEXT=textbox3.Text
                imagebuttonPGM1.Text=PGM_1_TEXT
                PGM_1_VALUE=textbox4.Text
        End If

        If PGM_2_FLAG=1 Then
                PGM_2_TEXT=textbox3.Text
                imagebuttonPGM2.Text=PGM_2_TEXT
                PGM_2_VALUE=textbox4.Text
        End If

        If PGM_3_FLAG=1 Then
                PGM_3_TEXT=textbox3.Text
                imagebuttonPGM3.Text=PGM_3_TEXT
                PGM_3_VALUE=textbox4.Text
        End If

        If PGM_4_FLAG=1 Then
                PGM_4_TEXT=textbox3.Text
                imagebuttonPGM4.Text=PGM_4_TEXT
                PGM_4_VALUE=textbox4.Text
        End If

        If PGM_5_FLAG=1 Then
                PGM_5_TEXT=textbox3.Text
                imagebuttonPGM5.Text=PGM_5_TEXT
                PGM_5_VALUE=textbox4.Text
        End If

        If PGM_6_FLAG=1 Then
                PGM_6_TEXT=textbox3.Text
                imagebuttonPGM6.Text=PGM_6_TEXT
                PGM_6_VALUE=textbox4.Text
        End If

        If PGM_7_FLAG=1 Then
                PGM_7_TEXT=textbox3.Text
                imagebuttonPGM7.Text=PGM_7_TEXT
                PGM_7_VALUE=textbox4.Text
        End If

        If PGM_8_FLAG=1 Then
                PGM_8_TEXT=textbox3.Text
                imagebuttonPGM8.Text=PGM_8_TEXT
                PGM_8_VALUE=textbox4.Text
        End If

        If PGM_9_FLAG=1 Then
                PGM_9_TEXT=textbox3.Text
                imagebuttonPGM9.Text=PGM_9_TEXT
                PGM_9_VALUE=textbox4.Text
        End If

        If PGM_10_FLAG=1 Then
                PGM_10_TEXT=textbox3.Text
                imagebuttonPGM10.Text=PGM_10_TEXT
                PGM_10_VALUE=textbox4.Text
        End If
End Sub

Sub ImageButtonPGMClear_Click
        textbox3.Text=""
        textbox4.Text=""

        checkbox1.Checked=false
        checkbox2.Checked=false
        checkbox3.Checked=false
        checkbox4.Checked=false
        checkbox5.Checked=false
        checkbox6.Checked=false
        checkbox7.Checked=false
        checkbox8.Checked=false
        checkbox9.Checked=false
        checkbox10.Checked=false

        PGM_1_FLAG=0
        PGM_2_FLAG=0
        PGM_3_FLAG=0
        PGM_4_FLAG=0
        PGM_5_FLAG=0
        PGM_6_FLAG=0
        PGM_7_FLAG=0
        PGM_8_FLAG=0
        PGM_9_FLAG=0
        PGM_10_FLAG=0
End Sub

Sub CheckBox1_Click
        PGM_1_FLAG=1
        PGM_2_FLAG=0
        PGM_3_FLAG=0
        PGM_4_FLAG=0
        PGM_5_FLAG=0
        PGM_6_FLAG=0
        PGM_7_FLAG=0
        PGM_8_FLAG=0
        PGM_9_FLAG=0
        PGM_10_FLAG=0
        checkbox2.Checked=false
        checkbox3.Checked=false
        checkbox4.Checked=false
        checkbox5.Checked=false
        checkbox6.Checked=false
        checkbox7.Checked=false
        checkbox8.Checked=false
        checkbox9.Checked=false
        checkbox10.Checked=false
End Sub

Sub CheckBox2_Click
        PGM_1_FLAG=0
        PGM_2_FLAG=1
        PGM_3_FLAG=0
        PGM_4_FLAG=0
        PGM_5_FLAG=0
        PGM_6_FLAG=0
        PGM_7_FLAG=0
        PGM_8_FLAG=0
        PGM_9_FLAG=0
        PGM_10_FLAG=0
        checkbox1.Checked=false
        checkbox3.Checked=false
        checkbox4.Checked=false
        checkbox5.Checked=false
        checkbox6.Checked=false
        checkbox7.Checked=false
        checkbox8.Checked=false
        checkbox9.Checked=false
        checkbox10.Checked=false
End Sub

Sub CheckBox3_Click
        PGM_1_FLAG=0
        PGM_2_FLAG=0
        PGM_3_FLAG=1
        PGM_4_FLAG=0
        PGM_5_FLAG=0
        PGM_6_FLAG=0
        PGM_7_FLAG=0
        PGM_8_FLAG=0
        PGM_9_FLAG=0
        PGM_10_FLAG=0
        checkbox1.Checked=false
        checkbox2.Checked=false
        checkbox4.Checked=false
        checkbox5.Checked=false
        checkbox6.Checked=false
        checkbox7.Checked=false
        checkbox8.Checked=false
        checkbox9.Checked=false
        checkbox10.Checked=false
End Sub

Sub CheckBox4_Click
        PGM_1_FLAG=0
        PGM_2_FLAG=0
        PGM_3_FLAG=0
        PGM_4_FLAG=1
        PGM_5_FLAG=0
        PGM_6_FLAG=0
        PGM_7_FLAG=0
        PGM_8_FLAG=0
        PGM_9_FLAG=0
        PGM_10_FLAG=0
        checkbox1.Checked=false
        checkbox2.Checked=false
        checkbox3.Checked=false
        checkbox5.Checked=false
        checkbox6.Checked=false
        checkbox7.Checked=false
        checkbox8.Checked=false
        checkbox9.Checked=false
        checkbox10.Checked=false
End Sub

Sub CheckBox5_Click
        PGM_1_FLAG=0
        PGM_2_FLAG=0
        PGM_3_FLAG=0
        PGM_4_FLAG=0
        PGM_5_FLAG=1
        PGM_6_FLAG=0
        PGM_7_FLAG=0
        PGM_8_FLAG=0
        PGM_9_FLAG=0
        PGM_10_FLAG=0
        checkbox1.Checked=false
        checkbox2.Checked=false
        checkbox3.Checked=false
        checkbox4.Checked=false
        checkbox6.Checked=false
        checkbox7.Checked=false
        checkbox8.Checked=false
        checkbox9.Checked=false
        checkbox10.Checked=false
End Sub

Sub CheckBox6_Click
        PGM_1_FLAG=0
        PGM_2_FLAG=0
        PGM_3_FLAG=0
        PGM_4_FLAG=0
        PGM_5_FLAG=0
        PGM_6_FLAG=1
        PGM_7_FLAG=0
        PGM_8_FLAG=0
        PGM_9_FLAG=0
        PGM_10_FLAG=0
        checkbox1.Checked=false
        checkbox2.Checked=false
        checkbox3.Checked=false
        checkbox4.Checked=false
        checkbox5.Checked=false
        checkbox7.Checked=false
        checkbox8.Checked=false
        checkbox9.Checked=false
        checkbox10.Checked=false
End Sub

Sub CheckBox7_Click
        PGM_1_FLAG=0
        PGM_2_FLAG=0
        PGM_3_FLAG=0
        PGM_4_FLAG=0
        PGM_5_FLAG=0
        PGM_6_FLAG=0
        PGM_7_FLAG=1
        PGM_8_FLAG=0
        PGM_9_FLAG=0
        PGM_10_FLAG=0
        checkbox1.Checked=false
        checkbox2.Checked=false
        checkbox3.Checked=false
        checkbox4.Checked=false
        checkbox5.Checked=false
        checkbox6.Checked=false
        checkbox8.Checked=false
        checkbox9.Checked=false
        checkbox10.Checked=false
End Sub

Sub CheckBox8_Click
        PGM_1_FLAG=0
        PGM_2_FLAG=0
        PGM_3_FLAG=0
        PGM_4_FLAG=0
        PGM_5_FLAG=0
        PGM_6_FLAG=0
        PGM_7_FLAG=0
        PGM_8_FLAG=1
        PGM_9_FLAG=0
        PGM_10_FLAG=0
        checkbox1.Checked=false
        checkbox2.Checked=false
        checkbox3.Checked=false
        checkbox4.Checked=false
        checkbox5.Checked=false
        checkbox6.Checked=false
        checkbox7.Checked=false
        checkbox9.Checked=false
        checkbox10.Checked=false
End Sub

Sub CheckBox9_Click
        PGM_1_FLAG=0
        PGM_2_FLAG=0
        PGM_3_FLAG=0
        PGM_4_FLAG=0
        PGM_5_FLAG=0
        PGM_6_FLAG=0
        PGM_7_FLAG=0
        PGM_8_FLAG=0
        PGM_9_FLAG=1
        PGM_10_FLAG=0
        checkbox1.Checked=false
        checkbox2.Checked=false
        checkbox3.Checked=false
        checkbox4.Checked=false
        checkbox5.Checked=false
        checkbox6.Checked=false
        checkbox7.Checked=false
        checkbox8.Checked=false
        checkbox10.Checked=false
End Sub

Sub CheckBox10_Click
        PGM_1_FLAG=0
        PGM_2_FLAG=0
        PGM_3_FLAG=0
        PGM_4_FLAG=0
        PGM_5_FLAG=0
        PGM_6_FLAG=0
        PGM_7_FLAG=0
        PGM_8_FLAG=0
        PGM_9_FLAG=0
        PGM_10_FLAG=1
        checkbox1.Checked=false
        checkbox2.Checked=false
        checkbox3.Checked=false
        checkbox4.Checked=false
        checkbox5.Checked=false
        checkbox6.Checked=false
        checkbox7.Checked=false
        checkbox8.Checked=false
        checkbox9.Checked=false
End Sub

Sub ImageButtonPGM1_Click
          textbox1.Text=textbox1.Text & PGM_1_VALUE
          serial.Output (PGM_1_VALUE)
End Sub

Sub ImageButtonPGM2_Click
          textbox1.Text=textbox1.Text & PGM_2_VALUE
          serial.Output (PGM_2_VALUE)
End Sub

Sub ImageButtonPGM3_Click
          textbox1.Text=textbox1.Text & PGM_3_VALUE
          serial.Output (PGM_3_VALUE)
End Sub

Sub ImageButtonPGM4_Click
          textbox1.Text=textbox1.Text & PGM_4_VALUE
          serial.Output (PGM_4_VALUE)
End Sub

Sub ImageButtonPGM5_Click
          textbox1.Text=textbox1.Text & PGM_5_VALUE
          serial.Output (PGM_5_VALUE)
End Sub

Sub ImageButtonPGM6_Click
          textbox1.Text=textbox1.Text & PGM_6_VALUE
          serial.Output (PGM_6_VALUE)
End Sub

Sub ImageButtonPGM7_Click
          textbox1.Text=textbox1.Text & PGM_7_VALUE
          serial.Output (PGM_7_VALUE)
End Sub

Sub ImageButtonPGM8_Click
          textbox1.Text=textbox1.Text & PGM_8_VALUE
          serial.Output (PGM_8_VALUE)
End Sub

Sub ImageButtonPGM9_Click
          textbox1.Text=textbox1.Text & PGM_9_VALUE
          serial.Output (PGM_9_VALUE)
End Sub

Sub ImageButtonPGM10_Click
          textbox1.Text=textbox1.Text & PGM_10_VALUE
          serial.Output (PGM_10_VALUE)
End Sub

Sub ImageButtonView_Click
        If PGM_1_FLAG=1 Then
                textbox3.Text=PGM_1_TEXT
                textbox4.Text=PGM_1_VALUE
        End If

        If PGM_2_FLAG=1 Then
                textbox3.Text=PGM_2_TEXT
                textbox4.Text=PGM_2_VALUE
        End If

        If PGM_3_FLAG=1 Then
                textbox3.Text=PGM_3_TEXT
                textbox4.Text=PGM_3_VALUE
        End If

        If PGM_4_FLAG=1 Then
                textbox3.Text=PGM_4_TEXT
                textbox4.Text=PGM_4_VALUE
        End If

        If PGM_5_FLAG=1 Then
                textbox3.Text=PGM_5_TEXT
                textbox4.Text=PGM_5_VALUE
        End If

        If PGM_6_FLAG=1 Then
                textbox3.Text=PGM_6_TEXT
                textbox4.Text=PGM_6_VALUE
        End If

        If PGM_7_FLAG=1 Then
                textbox3.Text=PGM_7_TEXT
                textbox4.Text=PGM_7_VALUE
        End If

        If PGM_8_FLAG=1 Then
                textbox3.Text=PGM_8_TEXT
                textbox4.Text=PGM_8_VALUE
        End If

        If PGM_9_FLAG=1 Then
                textbox3.Text=PGM_9_TEXT
                textbox4.Text=PGM_9_VALUE
        End If

        If PGM_10_FLAG=1 Then
                textbox3.Text=PGM_10_TEXT
                textbox4.Text=PGM_10_VALUE
        End If
End Sub

Sub ImageButtonClearAll_Click
        ImageButtonPGM1.Text=""
        ImageButtonPGM2.Text=""
        ImageButtonPGM3.Text=""
        ImageButtonPGM4.Text=""
        ImageButtonPGM5.Text=""
        ImageButtonPGM6.Text=""
        ImageButtonPGM7.Text=""
        ImageButtonPGM8.Text=""
        ImageButtonPGM9.Text=""
        ImageButtonPGM10.Text=""

        textbox1.Text=""
        textbox2.Text=""
        textbox3.Text=""
        textbox4.Text=""

        checkbox1.Checked=false
        checkbox2.Checked=false
        checkbox3.Checked=false
        checkbox4.Checked=false
        checkbox5.Checked=false
        checkbox6.Checked=false
        checkbox7.Checked=false
        checkbox8.Checked=false
        checkbox9.Checked=false
        checkbox10.Checked=false

        PGM_1_FLAG = 0
        PGM_2_FLAG = 0
        PGM_3_FLAG = 0
        PGM_4_FLAG = 0
        PGM_5_FLAG = 0
        PGM_6_FLAG = 0
        PGM_7_FLAG = 0
        PGM_8_FLAG = 0
        PGM_9_FLAG = 0
        PGM_10_FLAG = 0

        PGM_1_TEXT = ""
        PGM_2_TEXT = ""
        PGM_3_TEXT = ""
        PGM_4_TEXT = ""
        PGM_5_TEXT = ""
        PGM_6_TEXT = ""
        PGM_7_TEXT = ""
        PGM_8_TEXT = ""
        PGM_9_TEXT = ""
        PGM_10_TEXT = ""

        PGM_1_VALUE = ""
        PGM_2_VALUE = ""
        PGM_3_VALUE = ""
        PGM_4_VALUE = ""
        PGM_5_VALUE = ""
        PGM_6_VALUE = ""
        PGM_7_VALUE = ""
        PGM_8_VALUE = ""
        PGM_9_VALUE = ""
        PGM_10_VALUE = ""
End Sub

Sub ImageButtonClearTX_Click
        textbox1.Text=""
End Sub

Sub ImageButtonClearRX_Click
        textbox2.Text=""
End Sub

Sub ImageButtonPGM1_ButtonDown
        If blip_color=1 Then
                image6.Image="r28w35.jpg"
        End If
        If blip_color=2 Then
                image6.Image="b28w35.jpg"
        End If
        If blip_color=3 Then
                image6.Image="g28w35.jpg"
        End If
        If blip_color=4 Then
                image6.Image="y28w35.jpg"
        End If
        If blip_color=5 Then
                image6.Image="r28w35.jpg"
        End If
End Sub

Sub ImageButtonPGM1_ButtonUp
        image6.Image="w28w35.jpg"
End Sub

Sub ImageButtonPGM2_ButtonDown
        If blip_color=1 Then
                image7.Image="r28w35.jpg"
        End If
        If blip_color=2 Then
                image7.Image="b28w35.jpg"
        End If
        If blip_color=3 Then
                image7.Image="g28w35.jpg"
        End If
        If blip_color=4 Then
        image7.Image="y28w35.jpg"
        End If
        If blip_color=5 Then
        image7.Image="b28w35.jpg"
        End If
End Sub

Sub ImageButtonPGM2_ButtonUp
        image7.Image="w28w35.jpg"
End Sub

Sub ImageButtonPGM3_ButtonDown
        If blip_color=1 Then
                image8.Image="r28w35.jpg"
        End If
        If blip_color=2 Then
                image8.Image="b28w35.jpg"
        End If
        If blip_color=3 Then
                image8.Image="g28w35.jpg"
        End If
        If blip_color=4 Then
                image8.Image="y28w35.jpg"
        End If
        If blip_color=5 Then
                image8.Image="y28w35.jpg"
        End If
End Sub

Sub ImageButtonPGM3_ButtonUp
        image8.Image="w28w35.jpg"
End Sub

Sub ImageButtonPGM4_ButtonDown
        If blip_color=1 Then
                image9.Image="r28w35.jpg"
        End If
        If blip_color=2 Then
                image9.Image="b28w35.jpg"
        End If
        If blip_color=3 Then
                image9.Image="g28w35.jpg"
        End If
        If blip_color=4 Then
                image9.Image="y28w35.jpg"
        End If
        If blip_color=5 Then
                image9.Image="g28w35.jpg"
        End If
End Sub

Sub ImageButtonPGM4_ButtonUp
        image9.Image="w28w35.jpg"
End Sub

Sub ImageButtonPGM5_ButtonDown
        If blip_color=1 Then
                image10.Image="r28w35.jpg"
        End If
        If blip_color=2 Then
                image10.Image="b28w35.jpg"
        End If
        If blip_color=3 Then
                image10.Image="g28w35.jpg"
        End If
        If blip_color=4 Then
                image10.Image="y28w35.jpg"
        End If
        If blip_color=5 Then
                image10.Image="r28w35.jpg"
        End If
End Sub

Sub ImageButtonPGM5_ButtonUp
        image10.Image="w28w35.jpg"
End Sub

Sub ImageButtonPGM6_ButtonDown
        If blip_color=1 Then
                image11.Image="r28w35.jpg"
        End If
        If blip_color=2 Then
                image11.Image="b28w35.jpg"
        End If
        If blip_color=3 Then
                image11.Image="g28w35.jpg"
        End If
        If blip_color=4 Then
                image11.Image="y28w35.jpg"
        End If
        If blip_color=5 Then
                image11.Image="r28w35.jpg"
        End If
End Sub

Sub ImageButtonPGM6_ButtonUp
        image11.Image="w28w35.jpg"
End Sub

Sub ImageButtonPGM7_ButtonDown
        If blip_color=1 Then
                image12.Image="r28w35.jpg"
        End If
        If blip_color=2 Then
                image12.Image="b28w35.jpg"
        End If
        If blip_color=3 Then
                image12.Image="g28w35.jpg"
        End If
        If blip_color=4 Then
                image12.Image="y28w35.jpg"
        End If
        If blip_color=5 Then
                image12.Image="b28w35.jpg"
        End If
End Sub

Sub ImageButtonPGM7_ButtonUp
        image12.Image="w28w35.jpg"
End Sub

Sub ImageButtonPGM8_ButtonDown
        If blip_color=1 Then
                image13.Image="r28w35.jpg"
        End If
        If blip_color=2 Then
                image13.Image="b28w35.jpg"
        End If
        If blip_color=3 Then
                image13.Image="g28w35.jpg"
        End If
        If blip_color=4 Then
                image13.Image="y28w35.jpg"
        End If
        If blip_color=5 Then
                image13.Image="y28w35.jpg"
        End If
End Sub

Sub ImageButtonPGM8_ButtonUp
        image13.Image="w28w35.jpg"
End Sub

Sub ImageButtonPGM9_ButtonDown
        If blip_color=1 Then
                image14.Image="r28w35.jpg"
        End If
        If blip_color=2 Then
                image14.Image="b28w35.jpg"
        End If
        If blip_color=3 Then
                image14.Image="g28w35.jpg"
        End If
        If blip_color=4 Then
                image14.Image="y28w35.jpg"
        End If
        If blip_color=5 Then
                image14.Image="g28w35.jpg"
        End If
End Sub

Sub ImageButtonPGM9_ButtonUp
        image14.Image="w28w35.jpg"
End Sub

Sub ImageButtonPGM10_ButtonDown
        If blip_color=1 Then
                image15.Image="r28w35.jpg"
        End If
        If blip_color=2 Then
                image15.Image="b28w35.jpg"
        End If
        If blip_color=3 Then
                image15.Image="g28w35.jpg"
        End If
        If blip_color=4 Then
                image15.Image="y28w35.jpg"
        End If
        If blip_color=5 Then
                image15.Image="r28w35.jpg"
        End If
End Sub

Sub ImageButtonPGM10_ButtonUp
        image15.Image="w28w35.jpg"
End Sub

Sub ImageButtonReadFile_Click
        FileOpen (c1,"Button.txt",cRead,,cASCII)

        ImageButtonPGM1.Text = FileRead (c1)
        PGM_1_TEXT = ImageButtonPGM1.Text

        ImageButtonPGM2.Text = FileRead (c1)
        PGM_2_TEXT = ImageButtonPGM2.Text

        ImageButtonPGM3.Text = FileRead (c1)
        PGM_3_TEXT = ImageButtonPGM3.Text

        ImageButtonPGM4.Text = FileRead (c1)        
        PGM_4_TEXT = ImageButtonPGM4.Text

        ImageButtonPGM5.Text = FileRead (c1)
        PGM_5_TEXT = ImageButtonPGM5.Text

        ImageButtonPGM6.Text = FileRead (c1)
        PGM_6_TEXT = ImageButtonPGM6.Text

        ImageButtonPGM7.Text = FileRead (c1)
        PGM_7_TEXT = ImageButtonPGM7.Text

        ImageButtonPGM8.Text = FileRead (c1)
        PGM_8_TEXT = ImageButtonPGM8.Text

        ImageButtonPGM9.Text = FileRead (c1)
        PGM_9_TEXT = ImageButtonPGM9.Text

        ImageButtonPGM10.Text = FileRead (c1)
        PGM_10_TEXT = ImageButtonPGM10.Text

        PGM_1_VALUE = FileRead (c1)
        PGM_2_VALUE = FileRead (c1)
        PGM_3_VALUE = FileRead (c1)
        PGM_4_VALUE = FileRead (c1)
        PGM_5_VALUE = FileRead (c1)
        PGM_6_VALUE = FileRead (c1)
        PGM_7_VALUE = FileRead (c1)
        PGM_8_VALUE = FileRead (c1)
        PGM_9_VALUE = FileRead (c1)
        PGM_10_VALUE = FileRead (c1)

        FileClose (c1)
End Sub

Sub ImageButtonSaveFile_Click
        FileOpen (c1,"Button.txt",cWrite,,cASCII)

        FileWrite (c1,PGM_1_TEXT)
        FileWrite (c1,PGM_2_TEXT)
        FileWrite (c1,PGM_3_TEXT)
        FileWrite (c1,PGM_4_TEXT)
        FileWrite (c1,PGM_5_TEXT)
        FileWrite (c1,PGM_6_TEXT)
        FileWrite (c1,PGM_7_TEXT)
        FileWrite (c1,PGM_8_TEXT)
        FileWrite (c1,PGM_9_TEXT)
        FileWrite (c1,PGM_10_TEXT)

        FileWrite (c1,PGM_1_VALUE)
        FileWrite (c1,PGM_2_VALUE)
        FileWrite (c1,PGM_3_VALUE)
        FileWrite (c1,PGM_4_VALUE)
        FileWrite (c1,PGM_5_VALUE)
        FileWrite (c1,PGM_6_VALUE)
        FileWrite (c1,PGM_7_VALUE)
        FileWrite (c1,PGM_8_VALUE)
        FileWrite (c1,PGM_9_VALUE)
        FileWrite (c1,PGM_10_VALUE)

        FileClose (c1)
End Sub

Sub Timer1_Tick
        serial.Output ("T")
        textbox1.Text=textbox1.Text & "T"
End Sub

Sub Timer2_Tick
        tmr_count_1=tmr_count
End Sub

Sub Timer3_Tick
        tmr_count_2=tmr_count
        If tmr_count_1=tmr_count_2 Then
                   label1.fontcolor=cRed
                   label1.color=cBlack
                   label1.Text="OUT"
        End If
End Sub

Sub ImageButtonRangeTestOn_Click
        timer1.Interval=500
        timer1.Enabled=true

        timer2.Interval=1000
        timer2.Enabled=true

        timer3.Interval=2000
        timer3.Enabled=true
        tmr_flag=1
End Sub

Sub ImageButtonStopRangeTest_Click
        timer1.Enabled=false
        timer2.Enabled=false
        timer3.Enabled=false
        textbox1.Text=""
        textbox2.Text=""
        label1.color=128,255,128
        label1.text=""
        tmr_flag=0
End Sub

Sub ImageButtonRangeTestOn_ButtonDown
        ImageButtonRangeTestOn.Image="r35w35.jpg"
End Sub

Sub ImageButtonRangeTestOn_ButtonUp
        ImageButtonRangeTestOn.Image="g35w35.jpg"
End Sub

Sub ImageButtonStopRangeTest_ButtonDown
        ImageButtonStopRangeTest.Image="r35w35.jpg"
End Sub

Sub ImageButtonStopRangeTest_ButtonUp
        ImageButtonStopRangeTest.Image="g35w35.jpg"
End Sub

Sub serial_OnCom
        strval=serial.InputString
        TextBox2.Text=TextBox2.Text & strval

        If tmr_flag=1 Then
                   If strval = "T" Then
                      label1.color=cGreen
                      label1.fontcolor=cBlack
                      label1.text="  IN"
                      Sound("beep.wav")
                      tmr_count=tmr_count + 1
                   End If
        End If
End Sub

Sub MenuRed_Click
        ImageButtonPGM1.Image="r90w35.jpg"
        ImageButtonPGM2.Image="r90w35.jpg"
        ImageButtonPGM3.Image="r90w35.jpg"
        ImageButtonPGM4.Image="r90w35.jpg"
        ImageButtonPGM5.Image="r90w35.jpg"
        ImageButtonPGM6.Image="r90w35.jpg"
        ImageButtonPGM7.Image="r90w35.jpg"
        ImageButtonPGM8.Image="r90w35.jpg"
        ImageButtonPGM9.Image="r90w35.jpg"
        ImageButtonPGM10.Image="r90w35.jpg"
        blip_color=1
End Sub

Sub MenuBlue_Click
        ImageButtonPGM1.Image="b90w35.jpg"
        ImageButtonPGM2.Image="b90w35.jpg"
        ImageButtonPGM3.Image="b90w35.jpg"
        ImageButtonPGM4.Image="b90w35.jpg"
        ImageButtonPGM5.Image="b90w35.jpg"
        ImageButtonPGM6.Image="b90w35.jpg"
        ImageButtonPGM7.Image="b90w35.jpg"
        ImageButtonPGM8.Image="b90w35.jpg"
        ImageButtonPGM9.Image="b90w35.jpg"
        ImageButtonPGM10.Image="b90w35.jpg"
        blip_color=2
End Sub

Sub MenuGreen_Click
        ImageButtonPGM1.Image="g90w35.jpg"
        ImageButtonPGM2.Image="g90w35.jpg"
        ImageButtonPGM3.Image="g90w35.jpg"
        ImageButtonPGM4.Image="g90w35.jpg"
        ImageButtonPGM5.Image="g90w35.jpg"
        ImageButtonPGM6.Image="g90w35.jpg"
        ImageButtonPGM7.Image="g90w35.jpg"
        ImageButtonPGM8.Image="g90w35.jpg"
        ImageButtonPGM9.Image="g90w35.jpg"
        ImageButtonPGM10.Image="g90w35.jpg"
        blip_color=3
End Sub

Sub MenuYellow_Click
        ImageButtonPGM1.Image="y90w35.jpg"
        ImageButtonPGM2.Image="y90w35.jpg"
        ImageButtonPGM3.Image="y90w35.jpg"
        ImageButtonPGM4.Image="y90w35.jpg"
        ImageButtonPGM5.Image="y90w35.jpg"
        ImageButtonPGM6.Image="y90w35.jpg"
        ImageButtonPGM7.Image="y90w35.jpg"
        ImageButtonPGM8.Image="y90w35.jpg"
        ImageButtonPGM9.Image="y90w35.jpg"
        ImageButtonPGM10.Image="y90w35.jpg"
        blip_color=4
End Sub

Sub MenuMixed_Click
        ImageButtonPGM1.Image="r90w35.jpg"
        ImageButtonPGM2.Image="b90w35.jpg"
        ImageButtonPGM3.Image="y90w35.jpg"
        ImageButtonPGM4.Image="g90w35.jpg"
        ImageButtonPGM5.Image="r90w35.jpg"
        ImageButtonPGM6.Image="r90w35.jpg"
        ImageButtonPGM7.Image="b90w35.jpg"
        ImageButtonPGM8.Image="y90w35.jpg"
        ImageButtonPGM9.Image="g90w35.jpg"
        ImageButtonPGM10.Image="r90w35.jpg"
        blip_color=5
End Sub

Sub ImageButtonEXITDATAVIEW_Click
        Form2.Close
End Sub

Sub ImageButtonDATAVIEW_Click
        Form2.Show
        Label101.Text=PGM_1_TEXT
        Label102.Text=PGM_2_TEXT
        Label103.Text=PGM_3_TEXT
        Label104.Text=PGM_4_TEXT
        Label105.Text=PGM_5_TEXT
        Label106.Text=PGM_6_TEXT
        Label107.Text=PGM_7_TEXT
        Label108.Text=PGM_8_TEXT
        Label109.Text=PGM_9_TEXT
        Label110.Text=PGM_10_TEXT

        Label201.Text=PGM_1_VALUE
        Label202.Text=PGM_2_VALUE
        Label203.Text=PGM_3_VALUE
        Label204.Text=PGM_4_VALUE
        Label205.Text=PGM_5_VALUE
        Label206.Text=PGM_6_VALUE
        Label207.Text=PGM_7_VALUE
        Label208.Text=PGM_8_VALUE
        Label209.Text=PGM_9_VALUE
        Label210.Text=PGM_10_VALUE
End Sub