public class MyScrape extends Session3270 {

    // Constructor.
    MyScrape() throws JagacyException {
        super("myscrape", host, port, "IBM-3278-2");
    }

    // Log onto the mainframe.
    protected boolean logon() throws JagacyException {
	
        // Wait 30 seconds
        waitForChange(30000);

        writePosition(userIdRow, userIdColumn, userid);
        writePosition(passwordRow, passwordColumn, password);

        // Enter userid/password
        writeKey(Key.ENTER);

        // Wait 30 seconds
        waitForChange(30000);

        return true;
    }


    // Logoff the mainframe.
    protected void logoff() throws JagacyException {
	
        writePosition(exitRow, exitColumn, "=x");

        writeKey(Key.ENTER);

        // Wait 30 seconds
        waitForChange(30000);
    }


    private String getData() {
        return readPosition(dataRow, dataColumn, dataWidth);
    }


    public static void main(String args[]) {
	
        // Show a session window
        System.setProperty("myscrape.window", "true");
		
        // Create the screen scraper
        MyScrape s = new MyScrape();
		
        s.open();
		
        if (s.isOpen()) {
            // Print the data
            System.out.println(s.getData());
        }
		
        s.close();
		
        System.exit(0);
    }
}