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!

activate session revisited

Status
Not open for further replies.

vzachin

Technical User
Feb 10, 2006
305
US
hi,

there was a post from Mr Milson
which i tried to use but ran into problems.

what i'm trying to accomplish is to list all the active sessions and then be able to select the session that i want to activate.

i modified an Attachmate macro sample that i found. i have 2 DropListBox which are basically doing the same thing (i'm trying to learn the differences)

i'm not able to list all the sessions however i can list the active session.

is there a way to list the all the sessions?
if yes, then is there a way to select a session and activate that session?

Code:
Sub Main
    Dim Sys As Object
    Set Sys = CreateObject("Extra.System")
    Dim SessionNames() As String
    SessionCount = Sys.Sessions.Count
    
    For SessionCnt = 0 To Sys.Sessions.Count
    ReDim Preserve SessionNames(SessionCnt)
    SessionNames(Sessions) = Sys.Sessions.Item(SessionCnt).Name

    Next

        Begin Dialog dlgHouseSample 0, 1, 285, 193, "Open Sessions"
           ButtonGroup .ButtonPressed
           OkButton  225, 10, 50, 14
           CancelButton  225, 30, 50, 14
           PushButton  225, 50, 50, 14, "&Reset", .btnReset
           
    
           Text  12, 5, 202, 9, "Open Sessions"
           DropListBox 10, 15,95,55, SessionNames(),.ListBox1
           
           Text  12, 75, 77, 8, "Open Sessions2"
           DropListBox  12, 90, 81, 30, SessionNames(), .ListBox2
          
 
        End Dialog

    iDone = FALSE

    While (iDone = FALSE)    
        Dim dMain as dlgHouseSample

        nRet = Dialog(dMain)
        
        Select Case nRet
            Case -1                       ' -1 is returned if the user chose OK
                iDone = TRUE
                iColor = dMain.ListBox2
                
            Case 0                        ' 0 is returned if the user chose Cancel
                iDone = TRUE    
            Case 1                        ' 1 is returned if the user chose Reset
                dMain.ListBox2 = 0  
            Case Else
                msgbox "Some undefined button pressed " + str(dMain.ButtonPressed)
                
        End Select
    Wend

End Sub

i do have something similar that i use with excel (2 macros)but i'm looking for a solution using Extra.

thanks
zach
 
SessionNames(Sessioncnt[/color) = Sys.Sessions.Item(SessionCnt).Name


[small]Sometimes you gotta leave your zone of safety. You have to manufacture Inspirado. You gotta get out of the apartment. You've got to run with the wolves. You've got to dive into the ocean and fight with the sharks. Or just treat yourself to a delicious hot fudge sundae........ with nuts. - Jack Black[/small]
 
make that

SessionNames(Sessioncnt) = Sys.Sessions.Item(SessionCnt).Name


[small]Sometimes you gotta leave your zone of safety. You have to manufacture Inspirado. You gotta get out of the apartment. You've got to run with the wolves. You've got to dive into the ocean and fight with the sharks. Or just treat yourself to a delicious hot fudge sundae........ with nuts. - Jack Black[/small]
 
hi MrMilson,

thanks for that correction. how can i now activate a session by selecting from the dropdown list?

thanks again
zach
 
It'd be something like this... (typed not tested)
Code:
For SessionCnt = 0 To Sys.Sessions.Count
    If SessionNames(DlgValue("ListBox1")) = Sys.Session.Item(SessionCnt).Name Then
        Sys.Session.Item(SessionCnt).Activate
        Exit For
    End If
Next]

I don't remember for sure, but you might be able to call a Session.Item by it's name rather than number. In which case.
Code:
Sys.Session.Item(SessionNames(DlgValue("ListBox1"))).Activate
 
Hi Skie,

i'm missing something in my code
Code:
Sub Main
    Dim DroplistBox as string
    Dim Sys As Object
    Set Sys = CreateObject("Extra.System")
    Dim SessionNames() As String
    SessionCount = Sys.Sessions.Count
    For SessionCnt = 0 To Sys.Sessions.Count
    ReDim Preserve SessionNames(SessionCnt)
    SessionNames(Sessioncnt) = Sys.Sessions.Item(SessionCnt).Name
    Next
           Begin Dialog dlgHouseSample 0, 1, 285, 193, "Open Sessions"
           ButtonGroup .ButtonPressed
           OkButton  225, 10, 50, 14
           CancelButton  225, 30, 50, 14
           PushButton  225, 50, 50, 14, "&Reset", .btnReset
           Text  12, 5, 202, 9, "Open Sessions"
           DropListBox 10, 15,95,55, SessionNames(),.ListBox1
           End Dialog
   
           Dim dMain as dlgHouseSample
           nRet = Dialog(dMain)
           
Sys.Session.Item(SessionNames(DlgValue("ListBox1"))).Activate
        
For SessionCnt = 0 To Sys.Sessions.Count
    If SessionNames(DlgValue("ListBox1")) = Sys.Session.Item(SessionCnt).Name Then
        Sys.Session.Item(SessionCnt).Activate
        Exit For
    End If
Next

End Sub

i get a "no active dialog" over here
Code:
Sys.Session.Item(SessionNames(DlgValue("ListBox1"))).Activate
or here
Code:
If SessionNames(DlgValue("ListBox1")) = Sys.Session.Item(SessionCnt).Name Then
and if i continue to step through the error, i get the following "no such method or property" here
Code:
Sys.Session.Item(SessionCnt).Activate

what am i missing in my code?

thanks
zach
 
Sys.Sessions.Item(SessionCnt).Activate

[small]Sometimes you gotta leave your zone of safety. You have to manufacture Inspirado. You gotta get out of the apartment. You've got to run with the wolves. You've got to dive into the ocean and fight with the sharks. Or just treat yourself to a delicious hot fudge sundae........ with nuts. - Jack Black[/small]
 
Hi MrMilson,

Now i'm getting "the specified session is not available"

Code:
Sub Main
    Dim DroplistBox as string
    Dim Sys As Object
    Set Sys = CreateObject("Extra.System")
    Dim SessionNames() As String
    SessionCount = Sys.Sessions.Count
    For SessionCnt = 0 To Sys.Sessions.Count
    ReDim Preserve SessionNames(SessionCnt)
    SessionNames(Sessioncnt) = Sys.Sessions.Item(SessionCnt).Name
    Next
           Begin Dialog dlgHouseSample 0, 1, 285, 193, "Open Sessions"
           ButtonGroup .ButtonPressed
           OkButton  225, 10, 50, 14
           CancelButton  225, 30, 50, 14
           PushButton  225, 50, 50, 14, "&Reset", .btnReset
           Text  12, 5, 202, 9, "Open Sessions"
           DropListBox 10, 15,95,55, SessionNames(),.ListBox1
           

           
           
           End Dialog
   
           Dim dMain as dlgHouseSample
           nRet = Dialog(dMain)
           
Sys.Session[COLOR=red]s[/color].Item(SessionCnt).Activate 
End Sub

i feel we're getting close...



zach
 
got it, i think. need to tidy it up a bit.

thanks again to MrMilson & Skie for your inspiration

zach

Code:
Declare Function DisplayChoice(szLocale$) As String
                               
Sub Main
Dim szLocation$
Dim iDone%
Dim DroplistBox as string
Dim Sys As Object, Sess As Object
Set Sys = CreateObject("Extra.System")
Dim SessionNames() As String
SessionCount = Sys.Sessions.Count
For SessionCnt = 0 To Sys.Sessions.Count
ReDim Preserve SessionNames(SessionCnt)
SessionNames(Sessioncnt) = Sys.Sessions.Item(SessionCnt).Name
Next

        Begin Dialog dlgHouseSample 0, 1, 175, 93, "Please Select a Session to Run Macro"
           ButtonGroup .ButtonPressed
           
           OkButton  100, 15, 50, 14
           CancelButton  100, 35, 50, 14
           PushButton   100, 55, 50, 14, "&Reset", .btnReset
           
           Text  12, 5, 62, 9, "Available Sessions"
           DropComboBox 10, 15,65,55, SessionNames(), .dcbLocation
        
        End Dialog

    iDone = FALSE

    While (iDone = FALSE)    
        Dim dMain as dlgHouseSample

        nRet = Dialog(dMain)
        
        Select Case nRet
            Case -1                       ' -1 is returned if the user chose OK
                iDone = TRUE
                szLocation = dMain.dcbLocation
                
        If SzLocation = "" Then
        MsgBox "You Didn't Select a Session. Please start over"
        Exit Sub
        End If
      
	Set Sess = Sys.ActiveSession
	For i=1 to Sys.Sessions.Count
        If SzLocation = Sys.Sessions.Item(i) Then
		Set Sess=Sys.Sessions.Item(i)
		MsgBox "Activating session " + Sess.Name + "."
		Sess.Activate
        Exit For
        End If
	Next
                
            Case 0                        ' 0 is returned if the user chose Cancel
                iDone = TRUE
            msgbox "Please select a Session"    
            
            Case 1                        ' 1 is returned if the user chose Reset
                dMain.dcbLocation = ""
               
            Case Else
                msgbox "Some undefined button pressed " + str(dMain.ButtonPressed)
                
        End Select
    Wend

End Sub

'--------------------------------------------------------------------------------
Function DisplayChoice(szLocale$) As String

szResult = szLocale

DisplayChoice = szResult
    

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top