Skip to content

Instantly share code, notes, and snippets.

@gsherman
Last active December 11, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gsherman/4611867 to your computer and use it in GitHub Desktop.
Save gsherman/4611867 to your computer and use it in GitHub Desktop.
example of using DDE (Dynamic Data Exchange) with Clarify
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' Product : DDE Example Code
'
' Name : 411.cbs
'
' Description : Messaging changes to New Case Form for DDE Example
'
' Author : First Choice Software, Inc.
' 14412 Spicewood Springs Road
' Austin, TX 78759
' (512) 418-2905
'
' Platforms : This version supports Clarify 4.5 and later
'
' Copyright (C) 1999 First Choice Software, Inc.
' All Rights Reserved
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Functional Declarations
'
' Copyright (C) 1999 First Choice Software, Inc.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
OPTION EXPLICIT
Global dde_key As Long
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Form Load Method
'
' Copyright (C) 1999 First Choice Software, Inc.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub Form_Load()
' Do default action
Me.DoDefault
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Message Handler
'
' Copyright (C) 1999 First Choice Software, Inc.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub Message(ByVal message As Long, ByVal info As String)
Dim c_rec As Record ' Record for contextual objects
' If message is:
' 1. cbCloseMessage - Close this form
Me.DoDefault
Select Case message
Case cbCloseMessage
Me.Close cbCloseChildren
Case cbFirstMessage + 30
' Get the contact/site information. If
' no forms have set key, and my data
' is not yet set, I'll be the new
' case form for the DDE
Set c_rec = Cobj_CONTACT_VIEW.Contents
If dde_key = -1 And c_rec.GetField("objid") = 0 Then
dde_key = Me.Key
End If
Case cbFirstMessage + 31
' Set the phone number (ANI) and find the caller
PRIMARY_PHONE.Text = info
FINDCALLER.Value = True
Case cbFirstMessage + 32
' Set the called number for product and find
' the product
ENT_PART_NUMBER.Text = info
ENT_PART_SELECT.Value = True
End Select
End Sub

example of using DDE with Clarify

It shows examples for:

  • Posting a new case form, putting in data, and then doing a Find Caller operation
  • Posting an existing case

DDE Server:

  • 411.cbs is code for new case form
  • dde_globals.cbs is the globals code

DDE Client:

  • dde.cbs is a test driver program - call it using cbbatch
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' Product : DDE Example Code
'
' Name : dde.cbs
'
' Description : Driver module to show of DDE Execute verb
'
' Author : First Choice Software, Inc.
' 14412 Spicewood Springs Road
' Austin, TX 78759
' (512) 418-2905
'
' Platforms : This version supports Clarify 4.5 and later
'
' Copyright (C) 1999 First Choice Software, Inc.
' All Rights Reserved
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Functional Declarations
'
' Copyright (C) 1999 First Choice Software, Inc.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
OPTION EXPLICIT
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Test Driver
'
' Copyright (C) 1999 First Choice Software, Inc.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub dde_test()
Dim dde_channel As Integer ' DDE channel to use
Dim phone As String ' Phone number called from
Dim to_phone As String ' Phone number called
Dim operation As String ' Operation they select
Dim case_id As String ' Case they use
' Open channel to Clarify
' If can't, exit
dde_channel = DDEInitiate("ClarifyApp", "Clarify")
If dde_channel <= 0 Then
Exit Sub
End If
' Set initial values
' Loop forever
phone = "408-573-1000"
to_phone = "800-555-1212"
While 1 > 0
get_op:
' Ask them what they want to do
operation = InputBox("Press 1 for a new case, 2 for an existing case, 3 to exit the program", "DDE Example Program")
Select Case operation
Case "1"
' If a new case, ask for phone nums
' NOTE: In a CTI system, these two phone
' nums are already available
' Now, post the new case form
phone = InputBox("What is the phone number of the caller?", "DDE Example Program", phone)
to_phone = InputBox("What is the phone number that they called? (800-555-1212 for Word, 800-321-1234 for Excel", "DDE Example Program", to_phone)
DDEExecute dde_channel, "pop_new_case," + phone + "," + to_phone
Case "2"
' Ask for the case ID
' Post that case
case_id = InputBox("What is the case ID you are calling about?", "DDE Example Program")
DDEExecute dde_channel, "show_case," + case_id
Case "3"
' We're done!
Goto end_driver
Case Else
' Invalid operation
MsgBox "You must select a valid operation!!", "DDE Example Program"
Goto get_op
End Select
Wend
' We're done
' Close the channel
end_driver:
DDETerminate dde_channel
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' Product : DDE Global Code
'
' Name : dde_global.cbs
'
' Description : Routines to execute in Clarify for DDE test
'
' Author : First Choice Software, Inc.
' 14412 Spicewood Springs Road
' Austin, TX 78759
' (512) 418-2905
'
' Platforms : This version supports Clarify 4.5 and later
'
' Copyright (C) 1999 First Choice Software, Inc.
' All Rights Reserved
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Functional Declarations
'
' Copyright (C) 1999 First Choice Software, Inc.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
OPTION EXPLICIT
Global dde_key As Long
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Show an Existing Case
'
' Copyright (C) 1999 First Choice Software, Inc.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub show_case(case_id As String)
Dim t_ret As New BulkRetrieve ' Structure to query the DB
Dim case_list As List ' List of returned cases
Dim case_rec As Record ' One returned case
' Query for the case
' Get the results
t_ret.SimpleQuery 0, "case"
t_ret.AppendFilter 0, "id_number", cbEqual, case_id
t_ret.RetrieveRecords
Set case_list = t_ret.GetRecordList(0)
' If case not found, error message
' Else, post the case
If case_list.Count = 0 Then
App.MsgBox "Customer keyed in case " + case_id + ", but that case is not found in the database."
Else
Set case_rec = case_list.ItemByIndex(0)
App.ShowCase case_rec
End If
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Pop New Case Form. Filter on Supplied Data
'
' Copyright (C) 1999 First Choice Software, Inc.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub pop_new_case(phone_num As String, to_phone As String)
Dim dummy As New Form ' Form to use for messaging
Dim my_nc As Long ' Key to use for specific form to notify
' Start with no new case form
' Post the new case form
dde_key = -1
App.NewCase
' Tell all 411's to identify one
' Wait until that happens
' Get the key of the form to speak with
dummy.NotifyByID 411, cbFirstMessage + 30
While dde_key = -1
sleep(1)
Wend
my_nc = dde_key
' Tell the form the phone number
' And the product (if they called one of
' the special numbers)
dummy.NotifyByKey my_nc, cbFirstMessage + 31, phone_num
Select Case to_phone
Case "800-555-1212"
to_phone = "MS Word"
Case "800-321-1234"
to_phone = "MS Excel"
Case Else
Goto next_one
End Select
' Tell the form the product code
dummy.NotifyByKey my_nc, cbFirstMessage + 32, to_phone
next_one:
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment