Rocket Software Homepage
Forum Home Forum Home > AccuTerm Knowledge Base (read only) > Scripting & Automation
  New Posts New Posts RSS Feed - Using Class Modules in AccuTerm
  FAQ FAQ  Forum Search   Register Register  Login Login

The AccuTerm forum has moved. Go to community.rocketsoftware.com to register for the new Rocket forum.

Forum LockedUsing Class Modules in AccuTerm

 Post Reply Post Reply
Author
Message
kbdav View Drop Down
Newbie
Newbie


Joined: July 12 2016
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote kbdav Quote  Post ReplyReply Direct Link To This Post Topic: Using Class Modules in AccuTerm
    Posted: April 02 2019 at 6:48pm
I am having some issues implementing a class module withing the 'AccuTerm Macros.atsc' code module.

At the top of the module, I use the following line to reference a class module:

#Uses "PBX_Web.cls"

This should now allow me to use this class module in my project, something like:

Dim PBX As New PBX_Web

and access the class' methods and properties. This works to the extent of when I right click the module tab > Sheet > Open Uses, it brings up the class module I referenced and I can see all the code in the IDE. However, I am immediately greeted with an error:



It appears that I somehow need to set the class' "Caption" property and I spent a few hours on Google trying to figure it out. GetMacroCaption appears to be an event to the IDE itself, and it seems to fire when I try to view the code of the class module.

I have read this topic: http://www.winwrap.com/web2/basic/#!/ref/COM-doc_getmacrocaption_event.htm and it didn't help me. The code in the class itself doesn't seem to be the problem, as I've even tried using the example class in the AccuTerm Language Reference Manual under section 1.3.1.1 (Page 10).

Any ideas how I can implement my class into my project?
Back to Top
kbdav View Drop Down
Newbie
Newbie


Joined: July 12 2016
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote kbdav Quote  Post ReplyReply Direct Link To This Post Posted: April 04 2019 at 6:18pm
Some progress has been made.

It appears that in the script editor, it only expects to have 2 open modules simultaneously. Every time I open AccuTerm, there is the 'viewscript.atsc' script that runs and it also opens the Macro 'AccuTerm Macro Script [AccuTerm Macros.atsc]'. When these two remain open, and I click "Open Uses" and open a third and make it active, the above error occurs.

However, when I close down the 'viewscript.atsc' window (now I only have 1 visible module), then perform the same action of opening uses, the error is non existent.

This now makes some sense on the error itself: Subscript out of range. The range is '2', but I have 3 modules open. Now I am needing to figure out how to overcome this issue. Is it possible to "open uses" when the AccuTerm instance starts thus allowing it to expect all 3 modules?

Side note: When I don't have the class module open ("Open Uses"), it still references the class but I lose IntelliSense and I am unable to modify the class code in the editor; so the code within the class does work.
Back to Top
TonyG View Drop Down
Beta Tester
Beta Tester


Joined: February 04 2004
Location: United States
Status: Offline
Points: 127
Post Options Post Options   Thanks (0) Thanks(0)   Quote TonyG Quote  Post ReplyReply Direct Link To This Post Posted: May 03 2019 at 3:28pm
Just bumping this thread with a few random thoughts...

1) It sucks that we don't see more discussions like this, about using AccuTerm in more sophisticated ways, with external components, solving real-world problems using what people still often call "the old DOS system".

2) I'm surprised no one from Zumasys responded. I'm guessing Pete or someone else there simply missed this thread.

3) AccuTerm2K3? Time to update! The problem described might have been solved 15 years ago. :)

4) PBX caught my attention. Are you doing some integration with a phone system? I've been doing this for years but in the Pick world, unlike the rest of the world, for some reason no one seems to care. So I'm curious about the high-level business case, and what tools you're using to approach specific phone/PBX challenges.
Tony Gravagno Nebula Research & Development
TG@ Nebula-RnD . com
http://Nebula-RnD.com/blog
http://Twitter.com/TonyGravagno
http://groups.google.com/group/mvdbms
https://www.linkedin.com/groups/64935
Back to Top
kbdav View Drop Down
Newbie
Newbie


Joined: July 12 2016
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote kbdav Quote  Post ReplyReply Direct Link To This Post Posted: May 06 2019 at 7:40pm
Thanks for your interest, TonyG.

For your point # 3, I have tested this on newest version of AccuTerm as well and I received the same results.

And on # 4 - Yes, I have integrated this into our web based PBX software. It's not very pretty because it it contains no APIs for us to use, so I was left with using IE and web elements. It's nothing special so if you wanted to take a look at this class I will add the code below.

VERSION 1.0 CLASS
BEGIN
    MultiUse = -1
END
Attribute VB_Name = "PBX_Web"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclareID = False
Attribute VB_Exposed = False
'#Reference {EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}#1.1#0#C:\Windows\System32\ieframe.dll#Microsoft Internet Controls
'#Reference {3050F1C5-98B5-11CF-BB82-00AA00BDCE0B}#4.0#0#C:\Windows\System32\mshtml.tlb#Microsoft HTML Object Library

Option Explicit

Private oPBX As InternetExplorer
Private oPhoneBox As HTMLInputElement
Public Enum Campaign
    Manual_Outbound = 7
    Legal_Outbound = 13
End Enum
Public Enum CallResult
    AnswerMachine_MessageLeft = 15
    Contact = 26
    No_Answer = 16
    Wrong_Phone_Number = 14
    Busy = 9
    Dead_Air = 2
    Operator_Intercept = 7
    Third_Party = 27
End Enum

Private Function Doc As HTMLDocument
    Set Doc = oPBX.document
End Property
Private Property Get oPhoneMain() As HTMLDivElement
    Set oPhoneMain = Doc.getElementById("phone")
End Property
Private Property Get oStatus() As HTMLDivElement
    Set oStatus = oPhoneMain.getElementsByClassName("connected")(0)
End Property
Private Property Get oDetails() As HTMLDivElement
    Set oDetails = Doc.getElementById("agent-top").getElementsByClassName("call_info")(0).getElementsByClassName("info")(0).getElementsByTagName("p")(1)
End Property



Public Property Let PhoneNumber(sPhone As String)
    oPhoneBox.value = sPhone
    Debug.Print "PBX_Web: PhoneNumber changed to " & sPhone
End Property
Public Property Get PhoneNumber() As String
    PhoneNumber = oPhoneBox.value
End Property
Public Property Let AccountID(sID As String)
    Doc.querySelector("input.account_id").value = sID
    Debug.Print "PBX_Web: AccountID Box Changed to " & sID
End Property
Public Property Let ManualCampaign(CampaignValue As Campaign)
    Dim o As HTMLSelectElement, sValue As String
    Set o = Doc.querySelector("div#phone > div.manual_call > select.campaign")
    Doc.querySelector("div#phone > div.manual_call.internal > select.campaign").value = "12"
    o.value = CStr(CampaignValue)
    Debug.Print "PBX_Web: ManualCampaign Value changed to " & CampaignValue
End Property
Public Property Let Call_Result(ResultValue As CallResult)
    With Doc.getElementById("agent-top").getElementsByClassName("call_wrap")(0).getElementsByClassName("wrap")(0)
        .getElementsByClassName("call_result")(0).getElementsByTagName("select")(0).value = CStr(ResultValue)
    End With
    Debug.Print "PBX_Web: Call_Result Changed to " & ResultValue
End Property
Public Property Get Call_Result() As CallResult
    With Doc.getElementById("agent-top").getElementsByClassName("call_wrap")(0).getElementsByClassName("wrap")(0)
        Call_Result = .getElementsByClassName("call_result")(0).getElementsByTagName("select")(0).value
    End With
End Property


Public Sub DialNumber()
    Dim VerifyValue As String
    VerifyValue = PhoneNumber
    Doc.querySelector("div#phone > div.manual_call > div.button").click
    Debug.Print "PBX_Web: Dialing Phone Number: " & PhoneNumber & ". Waiting on confirmation."
    ConfirmCall VerifyValue
    Debug.Print "PBX_Web: Confirmed call connected"
End Sub
Public Sub HoldCall()
    Static onHold As Boolean
    Doc.querySelector("div#phone > div.line > div.buttons > div.onhold").click
    If Not onHold Then
        Debug.Print "PBX_Web: Call placed on hold."
        onHold = True
    Else
        Debug.Print "PBX_Web: Call removed from hold."
        onHold = False
    End If
End Sub
Public Sub HangupCall()
    Doc.querySelector("div#phone > div.line > div.buttons > div.hangup").click
    Debug.Print "PBX_Web: Hungup Call"
End Sub
Public Sub SaveAndFinishCall()
    While Doc.getElementsByClassName("submit")(0).getAttribute("style") <> "display: table-row;"
        DoEvents
    Wend
    Sleep 150
    Doc.getElementById("submit_call").click
    Debug.Print "PBX_Web: Saved and Finished Call."
End Sub
Public Sub WaitWithMessage(EndTime As Single)
    Do Until Timer > EndTime
        DoEvents
        Window_NoActiveCallsText = "No active calls " & Format(EndTime - Timer, "0")
    Loop
End Sub


Private Sub Class_Initialize()
    Set oPBX = GetIE(".****************.***/") 'Trying NOT to be labeled as a spammer :)
    Set oPhoneBox = Doc.querySelector("div#phone > div.manual_call > input.masked_phone")
End Sub
Private Sub ConfirmCall(ByVal sPhone As String)
    Dim StartTime As Single
    StartTime = Timer
    While oDetails Is Nothing
        DoEvents
    Wend
    While Not oDetails.innerText Like "Dialed: " & onlyDigits(sPhone) & "*"
        DoEvents
    Wend
End Sub
Private Function GetIE(sLocation As String) As InternetExplorer

    Dim objShell As Object, objShellWindows As Object, o As Object
    Dim sUrl As String
    Dim retVal As Object

    Set retVal = Nothing
    Set objShell = CreateObject("shell.application")
    Set objShellWindows = objShell.Windows

    For Each o In objShellWindows
        sUrl = ""
        On Error Resume Next
        sUrl = o.document.location
        On Error GoTo 0
        If sUrl Like "*" & sLocation & "*" Then Set retVal = o: Exit For
    Next o

    Set GetIE = retVal

End Function
Private Function onlyDigits(s As String) As String
    Dim retVal As String, i As Integer
    For i = 1 To Len(s)
        If Mid(s, i, 1) >= "0" And Mid(s, i, 1) <= "9" Then
            retVal = retVal + Mid(s, i, 1)
        End If
    Next
    onlyDigits = retVal
End Function
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.03
Copyright ©2001-2019 Web Wiz Ltd.