#!/usr/bin/env ruby lib = File.join(File.dirname(__FILE__), '..', 'lib') $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include? lib require 'dde' require 'win/gui/message' include Win::DDE include Win::GUI::Message # console output redirection (may need to wrap it in synchronization code, etc) def cout *args print *args end # std::queue q; // Queue contains the tables to output # Creating DDE server and staring service with default name 'excel' and default callback cout "Starting DDE server with service 'excel'\n" server = DDE::XlServer.new.start_service # Command line args define actions to be run after each successful DDE data transaction server.actions = ARGV.empty? ? [:timer] : ARGV # Starting message loop (necessary for DDE message processing) cout "Starting DDE message loop\n" msg = Msg.new # pointer to Msg FFI struct while msg = get_message(msg) translate_message(msg); dispatch_message(msg); end