Screen Native Access Sample Code 2

Sample 1

Creates an instance of ScreenNativeAccessEx, sets properties, sets a field, and sends an ENTER key.

public class Example01 {
      public static void main( String argc[]) {
        INativeAccessEx nab = new ScreenNativeAccessEx();
        nab.setTimeout( 3000 );
        nab.setSettleTime( 750 );
        nab.setPreserveContext( INativeAccessEx.PRESERVE_ALWAYS );
        nab.setCommand( INativeAccessConstants.REFRESH_NULL);
        try {
          nab.executeSync();
          nab.setFieldInputText( 8, "mydata");
          nab.setCommand( INativeAccessConstants.TRANSMIT);
          nab.executeSync();
          System.out.println(nab.getFieldText(0));
          nab.clearContext();
        } catch ( Exception e) e.printStackTrace(); }
      }
    }
Sample 2

Creates a standard connector, loads a task file, calls the Native Access task, prints out the data, and closes the connection.


    public class Example02 {
      public static void main( String argc[] ) {
        ScreenConnectorAccessImpl sca = new ScreenConnectorAccessImpl();
        sca.open( "mytasks.xml");
        sca.execute( "NativeScreenAccess",
          "<ScreenInputs><Command>stuff</Command></ScreenInputs>");
        System.out.println( sca.getData() );
        sca.close();
      }
    }
Sample 3

Transfers context between ITask beans and Native Access


    public void testTBT() {
      try {
        logon.setPreserveContext(ITask.PRESERVE_ALWAYS);
        logon.setUserID("myID");
        logon.setPassword("myPassword");
        logon.executeSync();
        nax.transferContext(m_logon);
        nax.setPreserveContext(ITask.PRESERVE_ALWAYS);
        nax.setCommand( INativeAccessConstants.REFRESH_NULL);
        nax.executeSync();
        if ( "CMSReady".equals( nax.getScreenName() ) {
          nax.setFieldInputText(0, "irmatest");
          nax.setCommand( INativeAccessEx.CMD_TRANSMIT );
          nax.executeSync();
          m_nax.setFieldInputText(0, "1");
          nax.executeSync(); // do a TRANSMIT
        }
        fieldAttr.transferContext(m_nax);
        fieldAttr.setPreserveContext(ITask.PRESERVE_ALWAYS);
        fieldAttr.executeSync();
        String title = m_fieldAttr.getTitle();
        fieldAttr.clearContext();
      }
      catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
      }
    }
Related Topics
Bullet Using Tasks in Your Applications, Overview
Bullet Using Screen Native Access, Overview
  Attachmate