/************************************************************************
 * Copyright (C) 1986-1999 Micro Focus International Ltd. 
 * All rights reserved.
 ************************************************************************
 *
 * Start of source module BasicCobcall.java
 *
 ************************************************************************/

import com.microfocus.cobol.*;

class BasicCobcall
{
  Integer	myOneInt;
  Long		myOneLong;
  Double	myOneDouble;
  Float		myOneFloat;
  Boolean	myOneBoolean;
  Short		myOneShort;
  Byte		myOneByte;
  Character	myOneChar;
  int		retcode;

  /*
   * Basic constructor for BasicCobcall class
   */
  public BasicCobcall(int a, long b, double c, float d,
    	 	      boolean e, short f, byte g, char h)
  {
    myOneInt    = new Integer(a);
    myOneLong   = new Long(b);
    myOneDouble = new Double(c);
    myOneFloat  = new Float(d);
    myOneBoolean= new Boolean(e);
    myOneShort  = new Short(f);
    myOneByte   = new Byte(g);
    myOneChar   = new Character(h);
    retcode=0;
  }

  /*
   * call method()
   */
  public void call()
  {

    try 
    {
	/*
	 * Package parameters for cobcall
	 */
    	Object myParms[] = { myOneInt, myOneLong, myOneDouble,
    			     myOneFloat, myOneBoolean,
    			     myOneShort, myOneByte, myOneChar
    		   	   };

	/*
	 * Execute the call
	 */
    	retcode=RuntimeSystem.cobcall("primtypes",myParms);
    }
    catch(Exception e)
    {
	/*
	 * Did the RuntimeSystem or the call cause a exception?
	 */
    	System.err.println("call: caused a exception, reason : "
			   + e.getMessage() + "\n");
    }
  }


   /*
    * Main method
    */ 
  public static void main(String[] args)
  {
    
    BasicCobcall myExample = new BasicCobcall(1, 2, 3, 4, false, (short)1,
    					     (byte)41, 'A');
    System.out.println("Basic cobcall demo\n");
    System.out.println("before call" + myExample);
    myExample.call();
    System.out.println("after call"  + myExample);
  }
 
  public String toString()
  {
    return new String( "myOneInt = "     + myOneInt     + "\n" +
    		       "myOneLong = "    + myOneLong    + "\n" +
    		       "myOneDouble = "  + myOneDouble  + "\n" +
    		       "myOneFloat = "   + myOneFloat   + "\n" +
    		       "myOneBoolean = " + myOneBoolean + "\n" +
    		       "myOneShort = "   + myOneShort   + "\n" +
    		       "myOneByte = "    + myOneByte    + "\n" +
    		       "myOneChar = "    + myOneChar    + "\n");
  }
}

