<commit_before><?php
/* This file is part of the XP framework's EASC API
 *
 * $Id$ 
 */
  require('lang.base.php');
  xp::sapi('cli');
  ini_set('include_path', ini_get('include_path').PATH_SEPARATOR.'../php/');
  uses('Remote', 'util.cmd.ParamString');

  // {{{ main
  $p= &new ParamString();
  if (!$p->exists(1)) {
    Console::writeLine(<<<__
EASC calculator demo application

Usage
-----
$ php calculator.php <hostname> [-p <port> ] [-j <jndi_name> ]
  
  * hostname is the host name (or IP) that your JBoss + XP-MBean server 
    is running on. The calculator bean (from the easc/beans directory) 
    is expected to be deployed.

  * port is the port the XP-MBean is listening on. It defaults to 6448.
  
  * jndi_name is the name of the bean in JNDI. It defaults to 
    "xp/demo/Calculator"
__
    );
    exit(1);
  }
  
  try(); {
    $remote= &Remote::forName('xp://'.$p->value(1).':'.$p->value('port', 'p', 6448).'/');
    $remote && $home= &$remote->lookup($p->value('jndi', 'j', 'xp/demo/Calculator'));
    $home && $calculator= &$home->create();
  } if (catch('Exception', $e)) {
    $e->printStackTrace();
    exit(-1);
  }
  
  // The add() method
  Console::writeLine('1.0 + 1.0 = ', xp::stringOf($calculator->add(1.0, 1.0)));
  Console::writeLine('1 + 1 = ', xp::stringOf($calculator->add(1, 1)));
  Console::writeLine('(2 + 3i) + (3 + 4i) = ', xp::stringOf($calculator->add(new Complex(2, 3), new Complex(3, 4))));

  // The subtract() method
  Console::writeLine('1.0 - 1.3 = ', xp::stringOf($calculator->subtract(1.0, 1.3)));
  Console::writeLine('1 - 12 = ', xp::stringOf($calculator->subtract(1, 12)));

  // The multiply() method
  Console::writeLine('2.0 * 1.5 = ', xp::stringOf($calculator->multiply(2.0, 1.5)));
  Console::writeLine('2 * 6 = ', xp::stringOf($calculator->multiply(2, 6)));
  // }}}
?>
<commit_msg>- Force "." in include path<commit_after><?php
/* This file is part of the XP framework's EASC API
 *
 * $Id$ 
 */
  require('lang.base.php');
  xp::sapi('cli');
  ini_set('include_path', ini_get('include_path').PATH_SEPARATOR.'../php/'.PATH_SEPARATOR.'.');
  uses('Remote', 'util.cmd.ParamString');

  // {{{ main
  $p= &new ParamString();
  if (!$p->exists(1)) {
    Console::writeLine(<<<__
EASC calculator demo application

Usage
-----
$ php calculator.php <hostname> [-p <port> ] [-j <jndi_name> ]
  
  * hostname is the host name (or IP) that your JBoss + XP-MBean server 
    is running on. The calculator bean (from the easc/beans directory) 
    is expected to be deployed.

  * port is the port the XP-MBean is listening on. It defaults to 6448.
  
  * jndi_name is the name of the bean in JNDI. It defaults to 
    "xp/demo/Calculator"
__
    );
    exit(1);
  }
  
  try(); {
    $remote= &Remote::forName('xp://'.$p->value(1).':'.$p->value('port', 'p', 6448).'/');
    $remote && $home= &$remote->lookup($p->value('jndi', 'j', 'xp/demo/Calculator'));
    $home && $calculator= &$home->create();
  } if (catch('Exception', $e)) {
    $e->printStackTrace();
    exit(-1);
  }
  
  // The add() method
  Console::writeLine('1.0 + 1.0 = ', xp::stringOf($calculator->add(1.0, 1.0)));
  Console::writeLine('1 + 1 = ', xp::stringOf($calculator->add(1, 1)));
  Console::writeLine('(2 + 3i) + (3 + 4i) = ', xp::stringOf($calculator->add(new Complex(2, 3), new Complex(3, 4))));

  // The subtract() method
  Console::writeLine('1.0 - 1.3 = ', xp::stringOf($calculator->subtract(1.0, 1.3)));
  Console::writeLine('1 - 12 = ', xp::stringOf($calculator->subtract(1, 12)));

  // The multiply() method
  Console::writeLine('2.0 * 1.5 = ', xp::stringOf($calculator->multiply(2.0, 1.5)));
  Console::writeLine('2 * 6 = ', xp::stringOf($calculator->multiply(2, 6)));
  // }}}
?>

{'fraction_non_alphanumeric': 0.22452272116160257, 'fraction_numerical': 0.031191180424845387, 'mean_word_length': 3.5756457564575648, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4930084', 'n_tokens_mistral': 1480, 'n_tokens_neox': 1374, 'n_words': 308}