Visual IRC '96/'97's DDE interface (0.65 and above) =================================================== IMPORTANT NOTE!! This has changed EXTENSIVELY in 0.65. Your old DDE stuff will not work. ViRC '97 currently supports two types of DDE requests: IRC_ParseVars and IRC_Execute. IRC_ParseVars evaluates an expression, parsing the variables and functions out, and IRC_Execute causes ViRC '97 to execute an IRC command as if it were typed at the keyboard. Thus "front-end" programs can be written to control ViRC '97. This is, of course, a very powerful capability. Usage examples -------------- The first lot of examples provided are written in Visual Basic, and, at the bottom of this file, you'll also find some routines to show how this can be done in Delphi. The technique should be easy to do in C++ too. IRC_ParseVars ------------- Create a label on a VB form and call it txDDE. Then execute the following code: txDDE.LinkTopic = "VIRC96|DDE" txDDE.LinkItem = "IRC_ParseVars" txDDE.LinkMode = 1 txDDE.LinkExecute "$rand(100)" The will parse the text $rand(100), returning a random number between 0 and 99, and setting the caption of txDDE to the returned random number. You can return the value of any text, for example, you could use the following code: txDDE.LinkTopic = "VIRC96|DDE" txDDE.LinkItem = "IRC_ParseVars" txDDE.LinkMode = 1 txDDE.LinkExecute "My nickname is $N." This would return the string "My nickname is ". IRC_Execute ----------- Causes ViRC '96 to execute an IRC command, as if it were entered at the keyboard. Example: txDDE.LinkTopic = "VIRC96|IRC_Execute" txDDE.LinkMode = 2 txDDE.LinkExecute "Join #quake" This will make ViRC '96 join the channel #quake. Any valid IRC command may be placed in the LinkExecute field. Examples for Delphi 1.0/2.0/3.0 =============================== // This routine takes a string (which may contain ViRC '97 variables and // functions) and uses ViRC '97 to evaluate it using DDE. // // Example: ShowMessage(ViRC97_ParseString('I''m running ViRC ''97 version $ver.')); function ViRC97_ParseString(x: string): string; var ddeC: TDDEClientConv; ddeI: TDDEClientItem; begin ddeC := TDDEClientConv.Create(nil); ddeI := TDDEClientItem.Create(nil); ddeI.DDEConv := ddeC; if (ddeC.SetLink('VIRC97', 'DDE')) then begin ddeI.DdeItem := 'IRC_ParseVars'; ddeC.ExecuteMacro(PChar(x), True); Result := ddeI.Text; end; ddeC.Free; ddeI.Free; end; // This routine executes a single ViRC '97 command. // // Example: ViRC97_Execute('MessageBox ViRC ''97 says "Hello" by DDE!!'); procedure ViRC97_Execute(x: string); var ddeC: TDDEClientConv; begin ddeC := TDDEClientConv.Create(nil); if (ddeC.SetLink('VIRC97', 'IRC_Execute')) then ddeC.ExecuteMacro(PChar(x), True); ddeC.Free; end;