'///////////////////////////////////////////////////////////
'///////////////////////////////////////////////////////////
'//
'// Indigo Terminal Emulator
'// Timed Command Automation Script
'// Version 1.0
'//
'// shadeBlue Software
'// http://www.shadeblue.com
'//
'///////////////////////////////////////////////////////////
'///////////////////////////////////////////////////////////

'// declare program constants
Const MY_COMMAND = "date"

'//------------------------------------
'// Host connection established
'//------------------------------------
Sub Host_Connected()

    '// say hello
    Host.Post vbCrLf
    Host.Post "--------------------------------------------------------------------" & vbCrLf
    Host.Post "SCRIPT STARTED" & vbCrLf
    Host.Post "--------------------------------------------------------------------" & vbCrLf

    '// enqueue first command
    EnqueueCommand

End Sub

'//------------------------------------
'// Host connection disconnected
'//------------------------------------
Sub Host_Disconnected()

    '// clear host command queue
    Host.Queue.Clear

    '// say goodbye
    Host.Post vbCrLf
    Host.Post "--------------------------------------------------------------------" & vbCrLf
    Host.Post "SCRIPT SUSPENDED" & vbCrLf
    Host.Post "--------------------------------------------------------------------" & vbCrLf

End Sub

'//------------------------------------
'// Host attempting to send data command
'// (Return the command to process)
'//------------------------------------
Function Host_Send(Byval command)

    '// if we see our command issued, then we can enqueue the next cycle
    if (command = MY_COMMAND) then

        Host.Post "--------------------------------------------------------------------" & vbCrLf
        Host.Post "SCRIPT QUEUEING NEXT COMMAND" & vbCrLf
        Host.Post "--------------------------------------------------------------------" & vbCrLf

        EnqueueCommand

    end if

    '// transmit unmodified command
    Host_Send = command

End Function

'//-----------------------------------------------------------
'// This function queues the next command
'//-----------------------------------------------------------
Function EnqueueCommand()

    '// clear host command queue
    Host.Queue.Clear

    '// wait 10 seconds before sending command
    Host.Queue.Add MY_COMMAND, 10000

    '// begin processing the queued instructions
    Host.Queue.Send

End Function

'//-----------------------------------------------------------
'// This function is needed to configure the Indigo session
'// scripting options. This is effectively a NO-OP function
'//-----------------------------------------------------------
Function ReceiveData(ByVal sData)

    '// don't do anything here
    '// just return the data received
    ReceiveData = sData

End Function
