Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with HLLAPI Function Call 1

Status
Not open for further replies.

jdsenter

MIS
Sep 23, 2003
4
US
Can someone please help me figure out a problem using HLLAPI function calls. This should be easy but my solution hasn’t worked yet. I have several Excel 2000 files that pass information with VBA to Extra 6.7 using HLLAPI function calls ... now I need a field of data to pass the other way too ... from Extra to Excel.

My current process requires the user to manually intervene at certain points to get information from the Extra screen, place it into Excel and then continue running the VBA. I want to remove this manual portion of the work by having the VBA code pull the field from the screen. The information is always 3 characters long and always in the same screen position.

I prefer to handle this routine using HLLAPI function calls since all the other interaction between Extra and Excel is through HLLAPI. All the timing issues have already been addressed with HLLAPI … so I don’t want to change to VBA screen scraping since timing problems are likely to pop up again.

The HLLAPI documentation reads as though this should be an easy task. Function 8 and/or 34 should accomplish this. I’ve used function 8 many times when I wanted to get a string and compare it to another string using function 6. Using these functions together works great when I am searching for a known string.

In this case, the three-character field could be anything. I simply want to use the HLLAPI function to return the string into a variable so I can place it into the spreadsheet. This isn’t working for me. Hopefully, I’ve just made a dumb mistake that someone can point out.

To simply my problem, I prepared the following sample VBA code:


Private Func As Integer, Astr As String, Alen As Integer, RetC As Integer

Private Declare Function HLLAPI Lib "C:\Program Files\EXTRA!\EHLAPI32.DLL" (Func%, ByVal Buffer$, bSize%, RetC%) As Long


'create the HLLAPI function, call the proper DLL file, display the returned value is a message box
Private Function HLL(Func, Astr, Alen, RetC)
HLLAPI Func, Astr, Alen, RetC
MsgBox ("astr = " & Astr & " alen = " & Alen & " retc = " & RetC)
End Function


'copy screen location row 2 column 4 (position 84) to string (3 characters only)
Sub TestCopy()
'connect to presentation space (ps)
Call HLL(1, "A", 0, 1)
'set function 8 copy ps to string, allocate empty space to hold string, set length, set screen position
Call HLL(8, " ", 3, 84)
End Sub


The returned values work okay for the Length and the Return Code; however, the Data String that I need does not return. When I use API trace, the proper values are reported; however, they don’t make it back through my code.

Below are the results of an API trace:

CONNECT (Function 1)
Entry: Length 0 PS Position 1
1DA7:0000 : 41 . A
Exit : Length 0 Return 0

COPY PRESENTATION SPACE TO STRING (Function 8)
Entry: Length 3 PS Position 84
Exit : Length 3 Return 0
1DA7:0000 : 46 57 44 . FWD


Notice that function 8 returned the string “FWD” for this example. Unfortunately, the string was not passed to the variable in the MsgBox; however, the Length and the Return Code were passed okay.

I have also tried function 34 with the same results. Any comments and/or suggestions are welcome and appreciated. Thanks in advance.
 
This info is also in the FAQ referenced below, but this will get the string you want alot faster:

Sub MySub()
'Extra Objects
Dim System As Object
Dim Sessions As Object
Dim Sess0 As Object

Code:
    Set System = CreateObject("EXTRA.System")   ' Gets the system object
    If (System Is Nothing) Then MsgBox "Could not create the EXTRA System object.  Stopping macro playback.": Stop
    Set Sessions = System.Sessions
    If (Sessions Is Nothing) Then: MsgBox "Could not create the Sessions collection object.  Stopping macro playback.": Stop
    Set Sess0 = System.ActiveSession
    If (Sess0 Is Nothing) Then MsgBox "Could not create the Session object.  Stopping macro playback.": Stop
'--------------------------------------------------------------------------------

MyString = Sess0.Screen.GetString(2,4,3)            '(Row,Col,StringLength)

Set System = Nothing
Set Sessions = Nothing
Set Sess0 = Nothing

End Sub

faq99-4069 How do I use VB(A) to manipulate attachmate (6.5+)?

calculus
 
Your input is certainly appreciated. I’ve read your earlier posts in the forum as well as the FAQ you referenced. Your posts are always helpful; however, in this situation, I still prefer to use the HLLAPI call to get the information I need.

Using HLLAPI keeps me in sync with the other thousand or so lines of code already in the application. It should only require but a couple more lines of code to get the information I want … if I can just get past this issue.

Another reason I want consistent use of HLLAPI function calls is that these functions are standard across several emulator platforms. A few of my users aren’t working with Extra … most are but some aren’t. Using HLLAPI, the function calls perform well with all our emulators … making my life easier since I don’t have to declare objects, write code, or otherwise support for every brand and version emulator … something I certainly don’t have the knowledge or expertise to handle.

Any other suggestions would be appreciated too. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top