Rocket Software Homepage
Forum Home Forum Home > AccuTerm Knowledge Base (read only) > Scripting & Automation
  New Posts New Posts RSS Feed - Alternative to Session.Copy
  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 LockedAlternative to Session.Copy

 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: Alternative to Session.Copy
    Posted: January 22 2019 at 7:37am
I use
s = Session.getText()
quite often to grab a single line from the terminal. This works great and it bypasses the clipboard.

However, I am now in the need of grabbing multiple lines from a session, and the only way I know to do this is by using 
Session.Copy()
s = Clipboard
as there is an option for top and bottom arguments (in .getText(), there is only the argument for a single line).

Is there any method that would effectively do something like this (without the syntax error):

Dim s As String
s = Session.Copy(0,1,10,2)
' 1 = top line, 2 = bottom line - Could contain vbCrLf like .Copy or any other delimiter 

I do not like to use the clipboard because I have had issues in the past with AccuTerm locking the clipboard up and me having to add extra code to restore the original clipboard's contents before the .Copy, such as:

Dim sOldClipboard as String, s as string
sOldClipboard = Clipboard
Session.Copy()
s = Clipboard
Clipboard sOldClipboard 

and is rather inconvenient, especially considering that getText() only requires a single line. I've tried to find better documentation of session.getBlock(), but doesn't appear to do what I need or I just can't find the proper way to use it.

Btw, I am (still) using AccuTerm 2K2 Ermm
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: January 22 2019 at 8:00am
In the meantime, I created this function to mimic what I am wanting to do, but if someone knows of a native way to accomplish this I am all ears!

Function GetText2(ByVal Left%, ByVal Top%, ByVal Right%, ByVal Bottom%) As String
    Dim i As Integer, retArr() As String
    ReDim retArr(Top To Bottom)
    For i = Top To Bottom
        retArr(i) = pubSession.GetText(Left, i, Right - Left + 1)
    Next
    GetText2 = Join(retArr, vbCrLf)
End Function

(pubSession is essentially just a global variable / Session obj I use so I don't have to pass the session as an argument between Subs)
Back to Top
PSchellenbach View Drop Down
Admin Group
Admin Group

Moderator

Joined: December 15 2003
Location: United States
Status: Offline
Points: 2150
Post Options Post Options   Thanks (2) Thanks(2)   Quote PSchellenbach Quote  Post ReplyReply Direct Link To This Post Posted: January 22 2019 at 2:21pm
Another alternative would be to select the area you want to get, then use the Selection property:
Function GetText3(Session As Session, ByVal Left As Integer, ByVal Top As Integer, ByVal Right As Integer, ByVal Bottom As Integer) As String
    Dim Lines As String
    Session.SetSelection Left,Top,Right,Bottom
    Lines = Session.Selection
    Session.ClearSelection
    GetText3 = Lines
End Function
Thanks, Pete

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: January 23 2019 at 9:47am
Ahh, a method without a loop, nice!

Thanks for the response
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.