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

Attachmate in C#

Status
Not open for further replies.

jstus

Programmer
Joined
Dec 3, 2014
Messages
3
Location
US
Hi,

Here is my code in VB.NET
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim mySystem As New EXTRA.ExtraSystem
        Dim mySessions As EXTRA.ExtraSessions = mySystem.Sessions
        Dim mySession As EXTRA.ExtraSession = mySessions.Open("C:\test.edp")
        MessageBox.Show(mySession.Screen.GetString(4, 27, 31))
End Sub

it works perfectly, it opens test.edp and reads some values from the screen.

Now I want to convert it ot C#
Code:
        private void button1_Click(object sender, EventArgs e)
        {
            EXTRA.ExtraSystem mySystem =(EXTRA.ExtraSystem) new EXTRA.ExtraSystem();
            EXTRA.ExtraSessions mySessions = (EXTRA.ExtraSessions)mySystem.Sessions;
            EXTRA.ExtraSession mySession = (EXTRA.ExtraSession)mySessions.Open("C:\\test.edp");
            MessageBox.Show(mySession.Screen.GetString(4, 27, 31));
        }

this will produce the following error:
'object' does not contain a definition for 'GetString' and no extension method 'GetString' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)

is it possible to implement it in C#?

please advice.
 
Don't know C. Do you need to declare screen as an Extra object?
 
still not working
Code:
        private void button1_Click(object sender, EventArgs e)
        {
            EXTRA.ExtraSystem mySystem =(EXTRA.ExtraSystem) new EXTRA.ExtraSystem();
            EXTRA.ExtraSessions mySessions = (EXTRA.ExtraSessions)mySystem.Sessions;
            EXTRA.ExtraSession mySession = (EXTRA.ExtraSession)mySessions.Open("C:\\ISI Apps\\LU\\Sashi\\AOM.edp");
            EXTRA.ExtraScreen myScreen = (EXTRA.ExtraScreen)mySession.Screen;
            MessageBox.Show(myScreen.GetString(4, 27, 31));
        }

will generate No overload for method 'GetString' takes '3' arguments
 
Do you have a reference to the Attachmate Object Library.
 
yes, i've added Interop.EXTRA reference and it works to some extend
for instance the following code will open attachmate window
Code:
        private void button1_Click(object sender, EventArgs e)
        {
            EXTRA.ExtraSystem mySystem =(EXTRA.ExtraSystem) new EXTRA.ExtraSystem();
            EXTRA.ExtraSessions mySessions = (EXTRA.ExtraSessions)mySystem.Sessions;
            EXTRA.ExtraSession mySession = (EXTRA.ExtraSession)mySessions.Open("C:\\test.edp");
            EXTRA.ExtraScreen myScreen = (EXTRA.ExtraScreen)mySession.Screen;
            mySession.WindowState = 0;
            mySession.Visible = 1;
            //MessageBox.Show(myScreen.GetString(4, 27, 31));
        }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top