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!

Session Terminates

Status
Not open for further replies.

vzachin

Technical User
Feb 10, 2006
305
US
Hi,

If the Attachmate session terminates for whatever reason, I get the following error message:

Microsoft Visual Basic
Run-time error '462':
The remote server machine does not exist or is unavailable

Is there any way of coding the macro so that when the session terminates, the macro will save the file and then exit the macro?

I tried something like:

If Sess0.Screen Is Nothing Then
Exit Sub
End If

but of course that doesn't work.

thanks
zach
 
You could use the On Error statement to have your program do something when it encounters an error.
 
hi Skie,

Thanks for your reply. I'm not having too much luck with the On Error statement. I tried running my code,disconnecting the attachmate session manually but I'm still getting the run-time error '462'.
Am I writing the statement incorrectly?

Code:
Sub NoConn ()

On Error GoTo NoConn
'here i have my coding to get data from Attachmate
'when i disconnect the session, i still get a runtime error

NoConn:
MsgBox "connection lost"
Exit Sub
End Sub


thanks again
zach
 
This code always displays the MsgBox "Error" for me. I would guess your problem is the sub and the label have the same name.
Code:
Sub Main
    Dim Sys As Object, Sess As Object
    On Error Goto This
    Set Sys = CreateObject("Extra.System")
    Set Sess = Sys.ActiveSession
    Sys.Quit
    Sess.Screen.PutString "Junk",1,1
    MsgBox "No Error"
This:
    If Err Then MsgBox "Error"
End Sub
 
hi Skie,

That is so cool. Works like a charm!

thanks
zach
 
I have a rather extensive dialog box I'm working on that has a number of textboxes, droplistboxes, and checkboxes.

For one of my textboxes, I want to refresh the Dialog Box so that several droplistboxes become visible or invisible based on the input in the textbox. This works fine, but only if the user selects another droplistbox or checks a checkbox (Case 2 in FileDlgFunction). Is there a way that I can use a button to cause the dialog to refresh but keep the data I've already updated? If I click the button now, it just closes out of the dialog.

In my code, I want ".RefreshButton" to have it check for:
Code:
If DlgText(86) = "1" then DlgVisible 80, 1 : DlgVisible 81, 0 : DlgVisible 82, 0 : DlgVisible 83, 0 : DlgVisible 84, 0

I've removed a lot of the code for purposes of brevity the Identifier$ numbers will be off but I've noted what they refer to.

Code:
Declare Function FileDlgFunction(identifier$, action, suppvalue)

Function FileDlgFunction(identifier$, action, suppvalue)

    Select Case action
        Case 1                                      'dialog started
        Case 2                                      'user changed control or clicked a button
            If DlgControlID(identifier$) = 96 then  'this is where the button is clicked, but it doesn't function correctly
                If DlgText(86) = "1" then DlgVisible 80, 1 : DlgVisible 81, 0 : DlgVisible 82, 0 : DlgVisible 83, 0 : DlgVisible 84, 0 
            End If
    End Select
End Function

Sub Main()

Dim button as integer
Dim identifier$
Dim action as Integer
Dim suppvalue as Integer
Dim months         'List

months="  "+Chr$(9)+"Jan"+Chr$(9)+"Feb"+Chr$(9)+"Mar"+Chr$(9)+"Apr"+Chr$(9)+"May"+Chr$(9)+"Jun"+Chr$(9)+"Jul"+Chr$(9)+"Aug"+Chr$(9)+"Sep"+Chr$(9)+"Oct"+Chr$(9)+"Nov"+Chr$(9)+"Dec"

Begin Dialog dlgPick 50, 50, 430, 270, "Pick List", .FileDlgFunction
    ButtonGroup .ButtonGroup1
    Text 10, 175, 70, 10, "Info changes", .Text35
    DropListBox 70, 173, 33, 120, months, .DropListBox12  'These are 80-84
    DropListBox 105, 173, 33, 120, months, .DropListBox13
    DropListBox 140, 173, 33, 120, months, .DropListBox14
    DropListBox 175, 173, 33, 120, months, .DropListBox15
    DropListBox 210, 173, 33, 120, months, .DropListBox16    
    Text 10, 160, 70, 10, "# per year", .Text36
    Textbox 70, 158, 18, 12, .text#PerYear      'This is 86

    Button 245, 174, 11, 10, "*", .RefreshButton    'This is 96
    OKButton 270, 243, 50, 12
    CancelButton 325, 243, 50, 12
End Dialog

Dim mydialog as dlgPick

nRet = Dialog(mydialog)

select case nRet
    case -1    
        'Click OK and it performs certain actions based on the selections made
    case 0
        exit sub

end select    

End Sub

Any help will be greatly appreciated!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top