Results 1 to 1 of 1

Thread: TBEM sample - Add an event

  1. #1

    TBEM sample - Add an event

    Here is a sample how to add an event.

    [code=thinbasic]'
    ' TBEM sample script - AddEvent
    ' Michael Hartlef
    ' October 18th, 2008

    uses "CONSOLE", "TBEM"

    dim myEvent as long
    dim sKey as string
    dim run as long value %TRUE

    'Define all event types we need.
    begin const
    %evtType1
    end const

    '**************************************************
    function tbmain()
    '**************************************************
    'Add an event
    myEvent = TBEM_AddEvent("SampleFunc",%evtType1)

    'Fire a trigger to run the event for one time
    TBEM_AddTrigger(%evtType1)

    console_writeline ("Press q for quit, a to add a new trigger" + $CRLF)
    while run = %TRUE
    'Run all active events which triggers were fired
    tbem_Run()

    'Check now for a keypress
    sKey = console_inkeyb

    'if the "a" key was pressed, add another trigger
    if sKey = "a" then TBEM_AddTrigger(%evtType1)
    'if "q" key was pressed, end this script
    if sKey = "q" then run = %FALSE

    wend
    end function

    '**************************************************
    sub SampleFunc()
    '**************************************************
    static count as long

    count += 1

    console_writeline("Hello from function SampleFunc")
    console_writeline("count = " + count)

    end sub
    [/code]
    Attached Files Attached Files

Similar Threads

  1. TBEM - Event manager module V1.10
    By Michael Hartlef in forum TBEM module - thinBasic Event Manager module
    Replies: 20
    Last Post: 19-10-2008, 07:34

Members who have read this thread: 1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •