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

Screen Selection Area Only: Assign each row value to variable 1

Status
Not open for further replies.

alupats

Technical User
Jul 20, 2004
6
0
0
US
I' building a URL string to pass into a web-based drawing viewer. The screen selection in EXTRA! will contain the drawing numbers. The URL string will contain several drawing numbers. Currently I have a simple copy to Clipboard routine that builds the string but is limited to one drawing number only. My goal is to have this work with multiple drawing numbers selected. Each drawing number will be in a separate row of the screen selection, aligned vertically. Positionally, the screen selection area will vary.

Here's a portion of the code I'm using for a single screen selected drawing number:

----------------------------------------
Sess0.Screen.Copy

ClipboardText = (Trim(Clipboard.Gettext))

rc% = shell("C:\Program Files\Internet Explorer\iexplore.exe ----------------------------------------


A multiple drawing search string (just showing the end of the above url) should look like this:

&searchstr="&ClipboardTextONE&searchstr="&ClipboardTextTWO&searchstr="&ClipboardTextTHREE&searchstr="). . . and so on. (up to ClipboardTextSIXTEEN maximum)

Thanks in advance for any suggestions you can post.
 
Code:
While YouGetYourData
    Sess0.Screen.Copy
    ClipboardText = (Trim(Clipboard.Gettext))
    sSearch = sSearch & "&searchstr=" & ClipboardText
Wend

rc% = shell("C:\Program Files\Internet Explorer\iexplore.exe [URL unfurl="true"]http://productview.mycompanyname.com/cgi-bin/pvsearch?&searchby=DRAWING&;"[/URL] & sSearch)

Personally, I'd use GetString instead of copy. And, I'd create an Internet Explorer object instead of executing it via a shell.
Code:
While YouGetYourData
    sText = Trim(Sess0.Screen.GetString(1,1,20))
    sSearch = sSearch & "&searchstr=" & sText
Wend

sURL = "[URL unfurl="true"]http://productview.mycompanyname.com/cgi-bin/pvsearch?&searchby=DRAWING&;"[/URL] & sSearch
Set oIE = CreateObject("InternetExplorer.Application")
oIE.Navigate sURL
oIE.Visible = TRUE
 
I like the idea of appending to Ssearch however the real challenge I'm faced with is a systematic approach of copying individual data one row at a time and assinging the value to a separate variable. Let's say I have 1,1,5,8 selected. This will be 5 drawing numbers, each having 8 characters. I need to assign variable FirstNum to have a value equal to 8 characters (columns 1 thru 8) in row 1, assign variable SecondNum to have a value equal to 8 characters (columns 1 thru 8) in row 2 and so on. To complicate this more, the screen selection area can be anywhere on the screen with any number of rows or columns.

This is what I started to get into just to see how I could detect what I have to split into individual rows:


Sub Main()
Dim Sys As Object, Sess As Object, MyScreen As Object, MyAreaOne As Object, MyAreaTwo As Object
Dim MyAreaThree As Object, MyAreafour As Object, MyAreaFive As Object, MyAreaSix As Object
Dim MyAreaSeven As Object, MyAreaEight As Object, MyAreaNine As Object, MyAreaTen As Object
Dim MyAreaEleven As Object, MyAreaTwelve As Object, MyAreaThirteen As Object
Dim MyAreaFourteen As Object, MyAreaFifteen As Object, MyAreaSixteen As Object
Dim SelRows as Integer
Dim SelCols as Integer
Dim RowCount as Integer
Dim ColCount as Integer

Dim sOne as String
Dim sTwo as String
Dim sThree as String
Dim sFour as String
Dim sFive as String
Dim sSix as String
Dim sSeven as String
Dim sEight as String
Dim sNine as String
Dim sTen as String
Dim sEleven as String
Dim sTwelve as String
Dim sThirteen as String
Dim sFourteen as String
Dim sFifteen as String
Dim sSixteen as String


Set Sys = CreateObject("EXTRA.System")
Set Sess = Sys.ActiveSession
Set MyScreen = Sess.Screen

Set MyAreaOne = MyScreen.Selection

MyString$ = MyString$ + "Top Row = " + Str$(MyAreaOne.Top)
MyString$ = MyString$ + "; Left Column = " + Str$(MyAreaOne.Left)
MyString$ = MyString$ + "; Bottom Row = " + Str$(MyAreaOne.Bottom)
MyString$ = MyString$ + "; Right Column = " + Str$(MyAreaOne.Right)


Set MyAreaOne = MyScreen.Area(MyAreaOne.Top,MyAreaOne.Left,MyAreaOne.Bottom,MyAreaOne.Right)

MsgBox MyString$

MsgBox "The text in your selection is: " + MyAreaOne.Value


ColCount = ((MyAreaOne.Right - MyAreaOne.Left) + 1)

msgbox "Number of Columns = " + Str$(ColCount)

RowCount = ((MyAreaOne.Bottom - MyAreaOne.Top) + 1)

msgbox "Number of Rows = " + Str$(RowCount)

End Sub
 
This what you're looking for it to do?
Code:
Sub Main()
    Dim Sys As Object
    Dim Sess As Object
    Dim MyScreen As Object
    Dim MyAreaOne As Object
    Dim oIE As Object
    Dim iLen As Integer
    Dim iRow As Integer
    Dim sSearch As String
    Dim sURL As String

    Set Sys = CreateObject("Extra.System")
    Set Sess = Sys.ActiveSession
    Set MyScreen = Sess.Screen
    Set MyAreaOne = MyScreen.Selection

    iLen = MyAreaOne.Right - MyAreaOne.Left
    For iRow = MyAreaOne.Top To MyAreaOne.Bottom
        sSearch = sSearch & "&searchstr=" & MyScreen.GetString(iRow,MyAreaOne.Left,iLen)
    Next

    sURL = "[URL unfurl="true"]http://productview.mycompanyname.com/cgi-bin/pvsearch?&searchby=DRAWING&;"[/URL] & sSearch
    Set oIE = CreateObject("InternetExplorer.Application")
    oIE.Navigate sURL
    oIE.Visible = TRUE
End Sub
 
So close, almost there! It works if all drawing numbers are the same lenth however that's not always the case so somehow we have to "TRIM" the data row by row.

Here's what a screen selection looks like:

S9128818
167030
S9174017

As you can see the second row is only 6 characters versus 8 for rows 1 & 3.

Here's what the end of the url string looks like:
&searchstr=S9128818&searchstr=167030%20%20&searchstr=S9174017

Here's the latest code, had to make a few tweaks like add one to the column, play with the "&" seperator, and changed MyAreaOne to just MyArea:


Sub Main()
Dim Sys As Object
Dim Sess As Object
Dim MyScreen As Object
Dim MyArea As Object
Dim oIE As Object
Dim iLen As Integer
Dim iRow As Integer
Dim sSearch As String
Dim sURL As String

Set Sys = CreateObject("Extra.System")
Set Sess = Sys.ActiveSession
Set MyScreen = Sess.Screen
Set MyArea = MyScreen.Selection

iLen = ((MyArea.Right - MyArea.Left) + 1)
For iRow = MyArea.Top To MyArea.Bottom
sSearch = sSearch & "&searchstr=" & MyScreen.GetString(iRow,MyArea.Left,iLen)
Next

sURL = " sSearch
Set oIE = CreateObject("InternetExplorer.Application")
oIE.Navigate sURL
oIE.Visible = TRUE
End Sub
 
Add Trim infront of the screen object. It works now.



For iRow = MyArea.Top To MyArea.Bottom
sSearch = sSearch & "&searchstr=" & Trim(MyScreen.GetString(iRow,MyArea.Left,iLen))
Next


Thank You so much. This will be used by eighteen engineers on a daily basis. A big time saver.

thanks again. I really appreciate the time you spent on it.
 
Closed, Thanks to Skie. Great Job!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top