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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extra basic 4.3 and Extra for NetWare 6.3 macro functions 2

Status
Not open for further replies.

VeraV

Technical User
Mar 23, 2004
9
0
0
US
Hi there. Please I need your help. I am a novice in macros, but with the manual (on line help) I developed a few macros that I run when using Attachmate Extra! v 4.3. Our company don't want to use in the future Attachmate, that's why we don't have the latest version. We use Extra 4.3 and 6.3. My problem is that some functions from 4.3 are not supported anymore in 6.3 and next (like GetFieldLength, GetStringFromField, SearchSession (option 4, from bottom up). Please anybody have replacement code for those functions?

Here is a simple macro in 4.3 that I can't make it work in 6.3

'The file which contains constants for the EXTRA! functions:
'$Include: "extra!.ebh"
' MACRO NAME..."DUPLICATE" copies the info from the field above (protected or unprotected)
Sub Main
'
' Connect to a terminal session. Refer to extra!.ebh for more information on GetFirstSession()
'
SessID$ = GetFirstSession()
If SessID$ = "" Then
MsgBox "No session available. Macro playback cancelled."
Exit Sub
End If
rc% = ConnectSession(SessID)
If rc% <> 1 and rc% <> 5 Then
MsgBox "Failed to connect to session " + SessID$ +" Macro playback cancelled."
rc% = ResetSystem()
Exit Sub
End If
'
' Recorded macro code:
'
' The SettleTime% parameter is used by the function WaitHostQuiet
' to control the amount of time the system waits for the X() on
' the OIA line to be absent. In this case, the default is set to
' 2000 milliseconds (2 seconds).
SettleTime% = 2

Pos% = GetCursorLocation()
Row% = RowColumn(pos%,0)-1
Col% = RowColumn(pos%,1)

rc% = GetFieldPosition(Row%,Col%,0)
Buffer$ = string$(GetFieldLength(row%,col%,0)," ")
rc% = GetStringFromField(RowColumn (rc%,0), RowColumn (rc%,1),Buffer$, Len(Buffer$)) 'copies info from the field above the cursor

rc% = SendHostKeys(Buffer$)

'
' Reset the EXTRA! system
'
rc% = ResetSystem()

End Sub




Please I will appreciate any help. Thank you


Vera
 
I've not used the field functions in the past, but in 6.3 I believe you would be able to use something like this:

Pos% = GetCursorLocation()
Row% = RowColumn(pos%,0)-1
Col% = RowColumn(pos%,1)

rc% = GetString(Row%,Col%, MyString$,Length of field)
rc% = SendString(NewRowPosition,NewColPosition, MyString$)

This is totally from memory from a few years back, so you'll have to check the help files about the functions.

Hope this help,
calculus

 
Thank you Calculus for your help. The problem is the my field above have different length; sometimes is 2 characters, or 5 or 7. In the Extra 4.3,the GetFieldLength would sense it. I can't believe if the new Extra versions don't support a function, they don't provide another functional way to replace it. Thanks again
 
Attachmate told me the reason they don't support previous versions (past 1 or 2) is because they provide the updated version free of charge. I don't know if this is always the case tho. Did you check their website for answers to this issue? Actually, I think that functions is supported in later version if you record the screens and writing your code to work with those recordings.
 
Thanks JeaShe. I am not sure that I understand what you mean by "they provide the updated version free of charge"?!?
Updated version of what? You mean I can get an update of Extra 6.3 which will support that function? I couldn't find anything related to this matter on their website.
 
If there is only spaces or blanks after the fields (as in most cases) you can use the Trim functions to remove unneeded spaces and the beggining and end of strings.

I used to use the function for determining if a field was bold in previous versions, but I've not been able to find anything in previous versions to match it.

calculus
 
To be honest I don't know how to do it (if it works). Here is my screen; starting from row 14, column 2 I have these info; I want to duplicate the field above; so my cursor would be on an empty row (16) and I want to copy certain fields from row 15 (the last row with info); but in other situations my last row can look like row 14.

column nr
2 5 13 21 26 33 36

Typ Hours Client Prod Job Tk MOA TX Rate
RT 1.25 P30 020 Z31333 00 FEB/03 N 230.00 <-row 14
B 21.25 P4 RIS B31344 00 FEB/03 N 285.00 <-row 15
<-row 16

the field
Typ can have 1 or 2 characters
Hours can have from 3 (.25) to 6 (125.75) cha
Client 2 or 3 ch
Prod 3
Job 5 or 6
Tk always 2
MOA 6
TX 1
Rate 2 to 6 characters


With my macro for EXTRA 4.3, when I have the cursor on row 16 col 2 and run the macro, it paste the info from the field above, meaning B; if the cursor is on row 16 col 26 it paste B31344. The new Extra treats the whole row as a field, so how can I make it decide to copy only 1 or 2 characters when I am on R16,C2 and 2 or 3 when cursor is on R 16,C 13?

Hope is not very confusing
 
Damned, they are not aligned properly.

col 2 is first space for Typ field
col 26 first space for Job field
col 13 first space for Client field
 
With the spacing going haywire, it's pretty hard to understand your delima.

I can tell you how to get a string from R16,C2 for 2 characters: (See post above)

rc% = GetString(16,2, MyString$,2)

To send this string to R16,C13:
rc% = SendString (16,13,MyString$)

These methods don't care where the cursor is. The only hurdle I see is that you noted the last field could be at a different location. You can also get the whole row, then only look at the last 2 characters in the string if you're sure it will always be 2 characters.

Assume Row is 60 columns.
Trim will remove leading and trailing spaces.
rc% = Trim(GetString(15,1,MyRow$,60))
Then the right 2 characters are:
MyString$ = Right(MyRow$,2)

calculus
 
case 1

RT 1.25 P30 020 Z31333 00 FEB/03 N 230.00 <-row 14

when my cursor is in R15C2, mymacro has to paste in R15,C2 what is in R14, C2 .... RT; when my cursor is in R15,C13 (under P30, client code), mymacro has to paste in R15,C13 P30


case 2

B 21.25 P4 RIS B31344 00 FEB/03 N 285.00 <-row 14

when the cursor is in R15,C2 the same mymacro has to paste in R15,C2 what is in R14, C2 .... B; when the cursor is in R15,C13 the macro has to paste in R15,C13 P4 (from R14,C13).



similarly the same macro has to copy from any of my 9 fields, above where my cursor is (that is the main issue, when my cursor is in one place it has to copy only the field above it one row, not the whole row), because not every field above has to be duplicated, in some I will enter new info, only for what is going to be redundat in the new row, I want instead to type just to copy/paste from the row/field above.

thanks
 
Case 1 and Case 2 look the same to me other than the length of the string.

The code would be something like this:

Pos% = GetCursorLocation()
Row% = RowColumn(pos%,0)
Col% = RowColumn(pos%,1)

If Col% = 2 or Col% = 13 then
rc% = Trim(GetString(Row%-1,Col%, MyString$,3))
rc% = SendString(Row%,Col%, MyString$)
End If

Keep in mind I can't test this as your using an old version of EB.

calculus
 
Col 2 has 2 cha in case 1 and 1 char in case 2

Col 13 has 3 char in case 1 and 2 char in case 2

It seems to me that the only way to solve this is to use 7 if conditions (for 7 fields).

If cursor locations is Col 2, the lenght of the field above is 2.... COPY Field

If cur loc is col 5, the L=7 (this field has room for 7 characters even if in my example has only 4 or 5)

If cur loc is col 13, the L=3... COPY field

If cur loc is col 21, the L=3

If cur loc is col 26, L=6

If cur loc is col 33, L=2

If cur loc is col 36, L=6


something like this the code should look like. Please calculus, can you help me in this new scenario? Thank you so much and I appologize for the confusion.

 
Actually, the code in my previous post will work for all situations.

Lets look at the code in a bit more detail:

'These 3 lines just get the row/col position
Pos% = GetCursorLocation()
Row% = RowColumn(pos%,0)
Col% = RowColumn(pos%,1)

If Col% = 2 or Col% = 13 then
'This is where the heavy lifting is done. This 1 line of code grabs the row above it, same column. It will grab 3 characters in every case. The "Trim" function will then remove leading and trailing spaces so that the resultant will be a string between 1 and 3 characters long.

rc% = Trim(GetString(Row%-1,Col%, MyString$,3))
ElseIf Col% = 5 or Col% = 26 or Col= 36 then
'This section has been added to accomodate your other situations. Get 7 characters, then we'll trim the trailing space below if necessary.
rc% = Trim(GetString(Row%-1,Col%, MyString$,7))
End If

MyString$ = Trim(MyString$)
'You may need to use functions like this:
MyString$ = LTrim(RTrim(MyString$))
rc% = SendString(Row%,Col%, MyString$)

calculus
 
Thank you so much Calculus, it's working.
Do you think that you have any suggestions how to make the other function, SearchSession, work, searching upwards from the bottom of the screen, R23C80?
This is what is written in the ebh file func_3, where Extra for NetWare 6.3 declairs functions:
(this is my note; even if below they say "Note: The search options are not implemented.", is weird but only Option 4 (searching from the bottom right to the top left of the target session) doesn't work))



Function: SearchSession

Parameters: row% The beginning row position to search in
the connected host session.

column% The beginning column position to search
in the connected host session.


searchString$ The string you want to locate
searchOption% An integer indicating which type of
search to perform.

--------------------------------------------------
searchOption% Options:
-------------------------
Value Description


SearchAll: Searches the entire screen of the connected session.

SearchFrom: Searches the location specified by the row% and column% parameters and returns
the position of the first occurrence of the string, if found.
SearchAt: Searches for the string at the specified location in the row% and column% parameters only.


Return Value: 1 Successful
0 String not found
-9 System Error

Side Effects: If function fails, ModEBLastError is set appropriately.

Description: Searches the current session for a specific string according to the options specified for searchOption% parameter.


The following search options are available:
- Search the entire host screen of the connected session
- Begin searching at the specified location and return the position of the first occurrence of the string
- Search for the string at a specified location only
- Search the connected session starting at the location specified; searching from the bottom right to the top left of the target session.

Note: The search options are not implemented.
************************************************************
Function SearchSession (Row%, Column%, SearchString$, SearchOption% ) As Integer
On Error Goto StartHandler
Dim Area As Object

If SearchOption = SearchAll Then
Set Area = ModSessObj.Screen.Search(SearchString$)
ElseIf SearchOption = SearchFrom Then
Set Area = ModSessObj.Screen.Search(SearchString$, Row%, Column%)
ElseIf SearchOption = SearchAt Then
Set Area = ModSessObj.Screen.Search(SearchString$, Row%, Column%)
If Area.Top <> Row Or Area.Left <> Column Then
Set Area = Nothing
End If
End If

If Not Area Is Nothing Then
If Area.Top <> -1 And Area.Left <> -1 Then
SearchSession = 1
Else
SearchSession = 0
End If
Else
SearchSession = 0
End If
Exit Function

StartHandler:
ModEBLastError = "SearchSession function call failed."
SearchSession = -9
Resume EndHandler
EndHandler:
End Function
 
This function does work (although slightly modified) in version 6.7. I don't have the version your working on to test it. It is a valuable function, good luck getting it to work.

calculus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top