/*

JavaScript to C++ translator generated C++ code.

Version: 1.0.0
Date: Mon Jan  6 10:56:29 2020


*/

#include "js.h"

//
// START PROGRAM DECLARATION
//

using namespace std;

using namespace eval_function;

void * js::java_script_pointer = 0;

eval_engine * eval_function::p_eval_engine = 0;

class ADDRESSBOOKAPP ;
class ARRAY ;
class PERSON ;
class PERSON_INPUT ;
class PERSON_LOAD ;
class PERSON_OUTPUT ;
class PERSON_SAVE ;
class PROGRAM_ADD_NEW_NUMBER ;
class PROGRAM_DELETE_NUMBER ;
class PROGRAM_DISPLAY_ALL ;
class PROGRAM_EXECUTE ;
class PROGRAM_EXIT ;
class PROGRAM_FIND_NUMBER ;
class PROGRAM_LOAD ;
class PROGRAM_RUN ;
class PROGRAM_SAVE ;
class PROGRAM_SHOW_MENU ;
class START ;
class ADDRESSBOOKAPP : public Function {
public :
Var operator ( ) ( ArgArray * _args = 0 ) ; 
Function * new_instence() const { return new ADDRESSBOOKAPP(); }
} ;

class ARRAY : public Function {
public :
Var operator ( ) ( ArgArray * _args = 0 ) ; 
Function * new_instence() const { return new ARRAY(); }
} ;

class PERSON : public Function {
public :
Var operator ( ) ( ArgArray * _args = 0 ) ; 
Function * new_instence() const { return new PERSON(); }
} ;

class PERSON_INPUT : public Function {
public :
Var operator ( ) ( ArgArray * _args = 0 ) ; 
Function * new_instence() const { return new PERSON_INPUT(); }
} ;

class PERSON_LOAD : public Function {
public :
Var operator ( ) ( ArgArray * _args = 0 ) ; 
Function * new_instence() const { return new PERSON_LOAD(); }
} ;

class PERSON_OUTPUT : public Function {
public :
Var operator ( ) ( ArgArray * _args = 0 ) ; 
Function * new_instence() const { return new PERSON_OUTPUT(); }
} ;

class PERSON_SAVE : public Function {
public :
Var operator ( ) ( ArgArray * _args = 0 ) ; 
Function * new_instence() const { return new PERSON_SAVE(); }
} ;

class PROGRAM_ADD_NEW_NUMBER : public Function {
public :
Var operator ( ) ( ArgArray * _args = 0 ) ; 
Function * new_instence() const { return new PROGRAM_ADD_NEW_NUMBER(); }
} ;

class PROGRAM_DELETE_NUMBER : public Function {
public :
Var operator ( ) ( ArgArray * _args = 0 ) ; 
Function * new_instence() const { return new PROGRAM_DELETE_NUMBER(); }
} ;

class PROGRAM_DISPLAY_ALL : public Function {
public :
Var operator ( ) ( ArgArray * _args = 0 ) ; 
Function * new_instence() const { return new PROGRAM_DISPLAY_ALL(); }
} ;

class PROGRAM_EXECUTE : public Function {
public :
Var operator ( ) ( ArgArray * _args = 0 ) ; 
Function * new_instence() const { return new PROGRAM_EXECUTE(); }
} ;

class PROGRAM_EXIT : public Function {
public :
Var operator ( ) ( ArgArray * _args = 0 ) ; 
Function * new_instence() const { return new PROGRAM_EXIT(); }
} ;

class PROGRAM_FIND_NUMBER : public Function {
public :
Var operator ( ) ( ArgArray * _args = 0 ) ; 
Function * new_instence() const { return new PROGRAM_FIND_NUMBER(); }
} ;

class PROGRAM_LOAD : public Function {
public :
Var operator ( ) ( ArgArray * _args = 0 ) ; 
Function * new_instence() const { return new PROGRAM_LOAD(); }
} ;

class PROGRAM_RUN : public Function {
public :
Var operator ( ) ( ArgArray * _args = 0 ) ; 
Function * new_instence() const { return new PROGRAM_RUN(); }
} ;

class PROGRAM_SAVE : public Function {
public :
Var operator ( ) ( ArgArray * _args = 0 ) ; 
Function * new_instence() const { return new PROGRAM_SAVE(); }
} ;

class PROGRAM_SHOW_MENU : public Function {
public :
Var operator ( ) ( ArgArray * _args = 0 ) ; 
Function * new_instence() const { return new PROGRAM_SHOW_MENU(); }
} ;

class START : public Function {
public :
Var operator ( ) ( ArgArray * _args = 0 ) ; 
Function * new_instence() const { return new START(); }
} ;

ADDRESSBOOKAPP AddressBookApp ;
ARRAY Array ;
PERSON Person ;
PERSON_INPUT person_input ;
PERSON_LOAD person_load ;
PERSON_OUTPUT person_output ;
PERSON_SAVE person_save ;
PROGRAM_ADD_NEW_NUMBER program_add_new_number ;
PROGRAM_DELETE_NUMBER program_delete_number ;
PROGRAM_DISPLAY_ALL program_display_all ;
PROGRAM_EXECUTE program_execute ;
PROGRAM_EXIT program_exit ;
PROGRAM_FIND_NUMBER program_find_number ;
PROGRAM_LOAD program_load ;
PROGRAM_RUN program_run ;
PROGRAM_SAVE program_save ;
PROGRAM_SHOW_MENU program_show_menu ;
START start ;
Var __AddressBookApp ( ArgArray * _args = 0 ) ;
Var __Array ( ArgArray * _args = 0 ) ;
Var __Person ( ArgArray * _args = 0 ) ;
Var __person_input ( ArgArray * _args = 0 ) ;
Var __person_load ( ArgArray * _args = 0 ) ;
Var __person_output ( ArgArray * _args = 0 ) ;
Var __person_save ( ArgArray * _args = 0 ) ;
Var __program_add_new_number ( ArgArray * _args = 0 ) ;
Var __program_delete_number ( ArgArray * _args = 0 ) ;
Var __program_display_all ( ArgArray * _args = 0 ) ;
Var __program_execute ( ArgArray * _args = 0 ) ;
Var __program_exit ( ArgArray * _args = 0 ) ;
Var __program_find_number ( ArgArray * _args = 0 ) ;
Var __program_load ( ArgArray * _args = 0 ) ;
Var __program_run ( ArgArray * _args = 0 ) ;
Var __program_save ( ArgArray * _args = 0 ) ;
Var __program_show_menu ( ArgArray * _args = 0 ) ;

Var * __AddressBookApp_new ( ArgArray * _args = 0 ) ;
Var * __Array_new ( ArgArray * _args = 0 ) ;
Var * __Person_new ( ArgArray * _args = 0 ) ;
Var * __person_input_new ( ArgArray * _args = 0 ) ;
Var * __person_load_new ( ArgArray * _args = 0 ) ;
Var * __person_output_new ( ArgArray * _args = 0 ) ;
Var * __person_save_new ( ArgArray * _args = 0 ) ;
Var * __program_add_new_number_new ( ArgArray * _args = 0 ) ;
Var * __program_delete_number_new ( ArgArray * _args = 0 ) ;
Var * __program_display_all_new ( ArgArray * _args = 0 ) ;
Var * __program_execute_new ( ArgArray * _args = 0 ) ;
Var * __program_exit_new ( ArgArray * _args = 0 ) ;
Var * __program_find_number_new ( ArgArray * _args = 0 ) ;
Var * __program_load_new ( ArgArray * _args = 0 ) ;
Var * __program_run_new ( ArgArray * _args = 0 ) ;
Var * __program_save_new ( ArgArray * _args = 0 ) ;
Var * __program_show_menu_new ( ArgArray * _args = 0 ) ;

Var __AddressBookApp ( ArgArray * _args ) {
return AddressBookApp ( _args ) ;
}

Var __Array ( ArgArray * _args ) {
return Array ( _args ) ;
}

Var __Person ( ArgArray * _args ) {
return Person ( _args ) ;
}

Var __person_input ( ArgArray * _args ) {
return person_input ( _args ) ;
}

Var __person_load ( ArgArray * _args ) {
return person_load ( _args ) ;
}

Var __person_output ( ArgArray * _args ) {
return person_output ( _args ) ;
}

Var __person_save ( ArgArray * _args ) {
return person_save ( _args ) ;
}

Var __program_add_new_number ( ArgArray * _args ) {
return program_add_new_number ( _args ) ;
}

Var __program_delete_number ( ArgArray * _args ) {
return program_delete_number ( _args ) ;
}

Var __program_display_all ( ArgArray * _args ) {
return program_display_all ( _args ) ;
}

Var __program_execute ( ArgArray * _args ) {
return program_execute ( _args ) ;
}

Var __program_exit ( ArgArray * _args ) {
return program_exit ( _args ) ;
}

Var __program_find_number ( ArgArray * _args ) {
return program_find_number ( _args ) ;
}

Var __program_load ( ArgArray * _args ) {
return program_load ( _args ) ;
}

Var __program_run ( ArgArray * _args ) {
return program_run ( _args ) ;
}

Var __program_save ( ArgArray * _args ) {
return program_save ( _args ) ;
}

Var __program_show_menu ( ArgArray * _args ) {
return program_show_menu ( _args ) ;
}

Var * __AddressBookApp_new ( ArgArray * _args ) {
Var temp = __AddressBookApp ( _args ) ;
temp.type_code = Var::OBJECT_VALUE ;
temp.type_string = "AddressBookApp" ;
Var * ret = new Var ( temp ) ;
ret->type_code = Var::OBJECT_VALUE ;
ret->type_string = "AddressBookApp" ;
ret -> set_this ( ) ;
return ret ;
}

Var * __Array_new ( ArgArray * _args ) {
Var temp = __Array ( _args ) ;
temp.type_code = Var::OBJECT_VALUE ;
temp.type_string = "Array" ;
Var * ret = new Var ( temp ) ;
ret->type_code = Var::OBJECT_VALUE ;
ret->type_string = "Array" ;
ret -> set_this ( ) ;
return ret ;
}

Var * __Person_new ( ArgArray * _args ) {
Var temp = __Person ( _args ) ;
temp.type_code = Var::OBJECT_VALUE ;
temp.type_string = "Person" ;
Var * ret = new Var ( temp ) ;
ret->type_code = Var::OBJECT_VALUE ;
ret->type_string = "Person" ;
ret -> set_this ( ) ;
return ret ;
}

Var * __person_input_new ( ArgArray * _args ) {
Var temp = __person_input ( _args ) ;
temp.type_code = Var::OBJECT_VALUE ;
temp.type_string = "person_input" ;
Var * ret = new Var ( temp ) ;
ret->type_code = Var::OBJECT_VALUE ;
ret->type_string = "person_input" ;
ret -> set_this ( ) ;
return ret ;
}

Var * __person_load_new ( ArgArray * _args ) {
Var temp = __person_load ( _args ) ;
temp.type_code = Var::OBJECT_VALUE ;
temp.type_string = "person_load" ;
Var * ret = new Var ( temp ) ;
ret->type_code = Var::OBJECT_VALUE ;
ret->type_string = "person_load" ;
ret -> set_this ( ) ;
return ret ;
}

Var * __person_output_new ( ArgArray * _args ) {
Var temp = __person_output ( _args ) ;
temp.type_code = Var::OBJECT_VALUE ;
temp.type_string = "person_output" ;
Var * ret = new Var ( temp ) ;
ret->type_code = Var::OBJECT_VALUE ;
ret->type_string = "person_output" ;
ret -> set_this ( ) ;
return ret ;
}

Var * __person_save_new ( ArgArray * _args ) {
Var temp = __person_save ( _args ) ;
temp.type_code = Var::OBJECT_VALUE ;
temp.type_string = "person_save" ;
Var * ret = new Var ( temp ) ;
ret->type_code = Var::OBJECT_VALUE ;
ret->type_string = "person_save" ;
ret -> set_this ( ) ;
return ret ;
}

Var * __program_add_new_number_new ( ArgArray * _args ) {
Var temp = __program_add_new_number ( _args ) ;
temp.type_code = Var::OBJECT_VALUE ;
temp.type_string = "program_add_new_number" ;
Var * ret = new Var ( temp ) ;
ret->type_code = Var::OBJECT_VALUE ;
ret->type_string = "program_add_new_number" ;
ret -> set_this ( ) ;
return ret ;
}

Var * __program_delete_number_new ( ArgArray * _args ) {
Var temp = __program_delete_number ( _args ) ;
temp.type_code = Var::OBJECT_VALUE ;
temp.type_string = "program_delete_number" ;
Var * ret = new Var ( temp ) ;
ret->type_code = Var::OBJECT_VALUE ;
ret->type_string = "program_delete_number" ;
ret -> set_this ( ) ;
return ret ;
}

Var * __program_display_all_new ( ArgArray * _args ) {
Var temp = __program_display_all ( _args ) ;
temp.type_code = Var::OBJECT_VALUE ;
temp.type_string = "program_display_all" ;
Var * ret = new Var ( temp ) ;
ret->type_code = Var::OBJECT_VALUE ;
ret->type_string = "program_display_all" ;
ret -> set_this ( ) ;
return ret ;
}

Var * __program_execute_new ( ArgArray * _args ) {
Var temp = __program_execute ( _args ) ;
temp.type_code = Var::OBJECT_VALUE ;
temp.type_string = "program_execute" ;
Var * ret = new Var ( temp ) ;
ret->type_code = Var::OBJECT_VALUE ;
ret->type_string = "program_execute" ;
ret -> set_this ( ) ;
return ret ;
}

Var * __program_exit_new ( ArgArray * _args ) {
Var temp = __program_exit ( _args ) ;
temp.type_code = Var::OBJECT_VALUE ;
temp.type_string = "program_exit" ;
Var * ret = new Var ( temp ) ;
ret->type_code = Var::OBJECT_VALUE ;
ret->type_string = "program_exit" ;
ret -> set_this ( ) ;
return ret ;
}

Var * __program_find_number_new ( ArgArray * _args ) {
Var temp = __program_find_number ( _args ) ;
temp.type_code = Var::OBJECT_VALUE ;
temp.type_string = "program_find_number" ;
Var * ret = new Var ( temp ) ;
ret->type_code = Var::OBJECT_VALUE ;
ret->type_string = "program_find_number" ;
ret -> set_this ( ) ;
return ret ;
}

Var * __program_load_new ( ArgArray * _args ) {
Var temp = __program_load ( _args ) ;
temp.type_code = Var::OBJECT_VALUE ;
temp.type_string = "program_load" ;
Var * ret = new Var ( temp ) ;
ret->type_code = Var::OBJECT_VALUE ;
ret->type_string = "program_load" ;
ret -> set_this ( ) ;
return ret ;
}

Var * __program_run_new ( ArgArray * _args ) {
Var temp = __program_run ( _args ) ;
temp.type_code = Var::OBJECT_VALUE ;
temp.type_string = "program_run" ;
Var * ret = new Var ( temp ) ;
ret->type_code = Var::OBJECT_VALUE ;
ret->type_string = "program_run" ;
ret -> set_this ( ) ;
return ret ;
}

Var * __program_save_new ( ArgArray * _args ) {
Var temp = __program_save ( _args ) ;
temp.type_code = Var::OBJECT_VALUE ;
temp.type_string = "program_save" ;
Var * ret = new Var ( temp ) ;
ret->type_code = Var::OBJECT_VALUE ;
ret->type_string = "program_save" ;
ret -> set_this ( ) ;
return ret ;
}

Var * __program_show_menu_new ( ArgArray * _args ) {
Var temp = __program_show_menu ( _args ) ;
temp.type_code = Var::OBJECT_VALUE ;
temp.type_string = "program_show_menu" ;
Var * ret = new Var ( temp ) ;
ret->type_code = Var::OBJECT_VALUE ;
ret->type_string = "program_show_menu" ;
ret -> set_this ( ) ;
return ret ;
}


Var id_count ;
Var person_array ;
Var FILE_NAME ;
Var did_save ;
Var running ;
Var prog ;

Var ADDRESSBOOKAPP :: operator ( ) ( ArgArray * _args ) 
{
if(the_this == 0) the_this = new Var();
parent = the_this;

the_this  -> get_member() [ "load" ]  = program_load ;
the_this  -> get_member() [ "save" ]  = program_save ;
the_this  -> get_member() [ "run" ]  = program_run ;
the_this  -> get_member() [ "show_menu" ]  = program_show_menu ;
the_this  -> get_member() [ "add_new_number" ]  = program_add_new_number ;
the_this  -> get_member() [ "delete_number" ]  = program_delete_number ;
the_this  -> get_member() [ "find_number" ]  = program_find_number ;
the_this  -> get_member() [ "display_all" ]  = program_display_all ;
the_this  -> get_member() [ "execute" ]  = program_execute ;
the_this  -> get_member() [ "exit" ]  = program_exit ;

return *the_this;
}

Var ARRAY :: operator ( ) ( ArgArray * _args ) 
{
if(the_this == 0) the_this = new Var();
parent = the_this;


return *the_this;
}

Var PERSON :: operator ( ) ( ArgArray * _args ) 
{
if(the_this == 0) the_this = new Var();
parent = the_this;
Var & name = ( * ( * _args ) [ 0 ] ) ;
Var & phone_number = ( * ( * _args ) [ 1 ] ) ;

the_this  -> get_member() [ "id" ]  = id_count ;
id_count ++ ;
the_this  -> get_member() [ "name" ]  = name ;
the_this  -> get_member() [ "phone_number" ]  = phone_number ;
the_this  -> get_member() [ "output" ]  = person_output ;
the_this  -> get_member() [ "input" ]  = person_input ;
the_this  -> get_member() [ "load" ]  = person_load ;
the_this  -> get_member() [ "save" ]  = person_save ;

return *the_this;
}

Var PERSON_INPUT :: operator ( ) ( ArgArray * _args ) 
{
if(the_this == 0) the_this = new Var();
parent = the_this;

the_this  -> get_member() [ "name" ]  = input (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( "please enter the new person name: " )  ) ) . get ( ) ) ;
the_this  -> get_member() [ "phone_number" ]  = input (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( "please enter the new person phone number: " )  ) ) . get ( ) ) ;

return *the_this;
}

Var PERSON_LOAD :: operator ( ) ( ArgArray * _args ) 
{
if(the_this == 0) the_this = new Var();
parent = the_this;


return *the_this;
}

Var PERSON_OUTPUT :: operator ( ) ( ArgArray * _args ) 
{
if(the_this == 0) the_this = new Var();
parent = the_this;

print (  auto_ptr < ArgArray > ( new ArgArray (  new Var (  Var ( "name: " )  + the_this  -> get_member() [ "name" ]  +  Var ( "\tphone number: " )  + the_this  -> get_member() [ "phone_number" ]  )  ) ) . get ( )           ) ;

return *the_this;
}

Var PERSON_SAVE :: operator ( ) ( ArgArray * _args ) 
{
if(the_this == 0) the_this = new Var();
parent = the_this;


return *the_this;
}

Var PROGRAM_ADD_NEW_NUMBER :: operator ( ) ( ArgArray * _args ) 
{
if(the_this == 0) the_this = new Var();
parent = the_this;

Var name = input (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( "please enter the name: " )  ) ) . get ( ) ) ;

p_eval_engine->register_var("name", INT_VAR, name.get_pointer_value());
Var phone_number = input (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( "please enter the phone number: " )  ) ) . get ( ) ) ;

p_eval_engine->register_var("phone_number", INT_VAR, phone_number.get_pointer_value());
person_array [ person_array  . pointer -> get_member() [ "length" ]  ] =  __Person_new  (  auto_ptr < ArgArray > ( to_param ( 2 ,  new Var ( name ) , new Var ( phone_number )  ) ) . get ( )   ) ;

return *the_this;
}

Var PROGRAM_DELETE_NUMBER :: operator ( ) ( ArgArray * _args ) 
{
if(the_this == 0) the_this = new Var();
parent = the_this;

Var phone_number = input (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( "please enter the phone number to delete: " )  ) ) . get ( ) ) ;

p_eval_engine->register_var("phone_number", INT_VAR, phone_number.get_pointer_value());
Var temp =  __Array_new  ( ) ;

p_eval_engine->register_var("temp", INT_VAR, temp.get_pointer_value());
for ( Var i = Var ( 0 )  ;
i < person_array  . pointer -> get_member() [ "length" ]  ;
i ++ ) { 
p_eval_engine->register_var("i", INT_VAR, i.get_pointer_value());
 if ( phone_number != person_array [ i ]  . pointer -> get_member() [ "phone_number" ]  ) {
temp [ temp  . pointer -> get_member() [ "length" ]  ] = person_array [ i ] ;
}
}
person_array = temp ;

return *the_this;
}

Var PROGRAM_DISPLAY_ALL :: operator ( ) ( ArgArray * _args ) 
{
if(the_this == 0) the_this = new Var();
parent = the_this;

for ( Var i = Var ( 0 )  ;
i < person_array  . pointer -> get_member() [ "length" ]  ;
i ++ ) { 
p_eval_engine->register_var("i", INT_VAR, i.get_pointer_value());
 person_array [ i ]  . pointer -> get_member() [ "output" ]  ( ) ;
}
input (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( "[press enter to continue]\n" )  ) ) . get ( ) ) ;

return *the_this;
}

Var PROGRAM_EXECUTE :: operator ( ) ( ArgArray * _args ) 
{
if(the_this == 0) the_this = new Var();
parent = the_this;
Var & choice = ( * ( * _args ) [ 0 ] ) ;

switch ( choice ) {
case 1:

the_this  -> get_member() [ "add_new_number" ]  ( ) ;
break ;
case 2:

the_this  -> get_member() [ "delete_number" ]  ( ) ;
break ;
case 3:

the_this  -> get_member() [ "find_number" ]  ( ) ;
break ;
case 4:

the_this  -> get_member() [ "display_all" ]  ( ) ;
break ;
case 5:

the_this  -> get_member() [ "exit" ]  ( ) ;
break ;
}

return *the_this;
}

Var PROGRAM_EXIT :: operator ( ) ( ArgArray * _args ) 
{
if(the_this == 0) the_this = new Var();
parent = the_this;

Var choice = Var ( "no" )  ;

p_eval_engine->register_var("choice", INT_VAR, choice.get_pointer_value());
do {
choice = input (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( "quit program? [yes/no]: " )  ) ) . get ( ) ) ;
if ( choice == Var ( "yes" )  ) {
running = false ;
}
}
while ( choice != Var ( "no" )  && choice != Var ( "yes" )  ) ;

return *the_this;
}

Var PROGRAM_FIND_NUMBER :: operator ( ) ( ArgArray * _args ) 
{
if(the_this == 0) the_this = new Var();
parent = the_this;

Var name = input (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( "please enter the name: " )  ) ) . get ( ) ) ;

p_eval_engine->register_var("name", INT_VAR, name.get_pointer_value());
for ( Var i = Var ( 0 )  ;
i < person_array  . pointer -> get_member() [ "length" ]  ;
i ++ ) { 
p_eval_engine->register_var("i", INT_VAR, i.get_pointer_value());
 if ( person_array [ i ]  . pointer -> get_member() [ "name" ]  == name ) {
person_array [ i ]  . pointer -> get_member() [ "output" ]  ( ) ;
Var choice = input (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( "[press enter continue]\n" )  ) ) . get ( ) ) ;

p_eval_engine->register_var("choice", INT_VAR, choice.get_pointer_value());
break ;
}
}

return *the_this;
}

Var PROGRAM_LOAD :: operator ( ) ( ArgArray * _args ) 
{
if(the_this == 0) the_this = new Var();
parent = the_this;

Var file = read_file (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( FILE_NAME )  ) ) . get ( ) ) ;

p_eval_engine->register_var("file", INT_VAR, file.get_pointer_value());
person_array =  __Array_new  ( ) ;
Var sep = Var ( "\n" )  ;

p_eval_engine->register_var("sep", INT_VAR, sep.get_pointer_value());
Var array = split (  auto_ptr < ArgArray > ( to_param ( 2 ,  new Var ( file ) , new Var ( sep )  ) ) . get ( )   ) ;

p_eval_engine->register_var("array", INT_VAR, array.get_pointer_value());
for ( Var i = Var ( 0 )  ;
i < array  . pointer -> get_member() [ "length" ]  ;
i += Var ( 2 )  ) { 
p_eval_engine->register_var("i", INT_VAR, i.get_pointer_value());
 person_array [ person_array  . pointer -> get_member() [ "length" ]  ] =  __Person_new  (  auto_ptr < ArgArray > ( to_param ( 2 ,  new Var ( array [ i ] ) , new Var ( array [ i +  Var ( 1 )  ] )  ) ) . get ( )           ) ;
}

return *the_this;
}

Var PROGRAM_RUN :: operator ( ) ( ArgArray * _args ) 
{
if(the_this == 0) the_this = new Var();
parent = the_this;

print (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( "JavaScript Address Book 1.0" )  ) ) . get ( ) ) ;
print (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( "(C) Copyright 2019. All rights reserved." )  ) ) . get ( ) ) ;
print (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( "This software is the intellectual property of Matthew William Coan." )  ) ) . get ( ) ) ;
print (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( "Author: Matthew W. Coan mcoan@slack.net http://slack.net/~mcoan/" )  ) ) . get ( ) ) ;
print (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( "" )  ) ) . get ( ) ) ;
the_this  -> get_member() [ "load" ]  ( ) ;
while ( running ) {
the_this  -> get_member() [ "show_menu" ]  ( ) ;
Var choice = input (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( "choice> " )  ) ) . get ( ) ) ;

p_eval_engine->register_var("choice", INT_VAR, choice.get_pointer_value());
choice = parseInt (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( choice )  ) ) . get ( ) ) ;
the_this  -> get_member() [ "execute" ]  (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( choice )  ) ) . get ( ) ) ;
}
the_this  -> get_member() [ "save" ]  ( ) ;

return *the_this;
}

Var PROGRAM_SAVE :: operator ( ) ( ArgArray * _args ) 
{
if(the_this == 0) the_this = new Var();
parent = the_this;

Var file = Var ( "" )  ;

p_eval_engine->register_var("file", INT_VAR, file.get_pointer_value());
for ( Var i = Var ( 0 )  ;
i < person_array  . pointer -> get_member() [ "length" ]  ;
i ++ ) { 
p_eval_engine->register_var("i", INT_VAR, i.get_pointer_value());
 file += person_array [ i ]  . pointer -> get_member() [ "name" ]  + Var ( "\n" )  ;
file += person_array [ i ]  . pointer -> get_member() [ "phone_number" ]  + Var ( "\n" )  ;
}
write_file (  auto_ptr < ArgArray > ( to_param ( 2 ,  new Var ( FILE_NAME ) , new Var ( file )  ) ) . get ( )   ) ;

return *the_this;
}

Var PROGRAM_SHOW_MENU :: operator ( ) ( ArgArray * _args ) 
{
if(the_this == 0) the_this = new Var();
parent = the_this;

print (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( "main menu:" )  ) ) . get ( ) ) ;
print (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( "1: add new number" )  ) ) . get ( ) ) ;
print (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( "2: delete number" )  ) ) . get ( ) ) ;
print (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( "3: find number" )  ) ) . get ( ) ) ;
print (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( "4: display all" )  ) ) . get ( ) ) ;
print (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( "5: exit" )  ) ) . get ( ) ) ;

return *the_this;
}

Var START :: operator ( ) ( ArgArray * _args ) 
{

 id_count = Var ( 100 )  ;
 person_array =  __Array_new  ( ) ;
 FILE_NAME = Var ( "person.txt" )  ;
 did_save = false ;
 running = true ;
try {
 prog =  __AddressBookApp_new  ( ) ;
prog . pointer -> get_member() [  "run" ]  ( ) ;
}
catch ( Var  ex ) {
print (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( "address book exception..." )  ) ) . get ( ) ) ;
print (  auto_ptr < ArgArray > ( new ArgArray (  new Var ( ex )  ) ) . get ( ) ) ;
}
return Var();
}

void hello() { cout << "Hello...\n" << endl; }
extern "C" {
extern int main (int argc, char ** argv);
extern void script_init (void * rt, void * cx, void * obj);
}

int main (int argc, char ** argv)
{
int ret = 0 ;
{
ArgArray args ;
StringArrayVar * argv2  = new StringArrayVar ( "argv" ) ;
eval_engine e_engine;
p_eval_engine = &e_engine;
p_eval_engine->register_fun("AddressBookApp", (void*)__AddressBookApp, 0);
p_eval_engine->register_fun("Array", (void*)__Array, 0);
p_eval_engine->register_fun("Person", (void*)__Person, 0);
p_eval_engine->register_fun("person_input", (void*)__person_input, 0);
p_eval_engine->register_fun("person_load", (void*)__person_load, 0);
p_eval_engine->register_fun("person_output", (void*)__person_output, 0);
p_eval_engine->register_fun("person_save", (void*)__person_save, 0);
p_eval_engine->register_fun("program_add_new_number", (void*)__program_add_new_number, 0);
p_eval_engine->register_fun("program_delete_number", (void*)__program_delete_number, 0);
p_eval_engine->register_fun("program_display_all", (void*)__program_display_all, 0);
p_eval_engine->register_fun("program_execute", (void*)__program_execute, 0);
p_eval_engine->register_fun("program_exit", (void*)__program_exit, 0);
p_eval_engine->register_fun("program_find_number", (void*)__program_find_number, 0);
p_eval_engine->register_fun("program_load", (void*)__program_load, 0);
p_eval_engine->register_fun("program_run", (void*)__program_run, 0);
p_eval_engine->register_fun("program_save", (void*)__program_save, 0);
p_eval_engine->register_fun("program_show_menu", (void*)__program_show_menu, 0);
p_eval_engine->register_fun("read_file", (void*)read_file, 1);
p_eval_engine->register_fun("write_file", (void*)write_file, 2);
p_eval_engine->register_fun("split", (void*)split, 2);
p_eval_engine->register_fun("parseInt", (void*)parseInt, 1);
p_eval_engine->register_fun("print", (void*)print, 1);
p_eval_engine->register_fun("print2", (void*)print2, 1);
p_eval_engine->register_fun("exit", (void*)my_exit, 1);
p_eval_engine->register_fun("input", (void*)my_input, 1);
p_eval_engine->register_fun("eval", (void*)in_eval, 1);
for ( int i = 0 ; i < argc ; i ++ ) {
argv2  -> add_string ( new Var ( argv [ i ] ) ) ;
}
args . add ( argv2 ) ;
try {
start ( auto_ptr < ArgArray > ( to_param ( args.arg_count() , argv2 ) ) . get ( ) ) ;
ret = 0;
}
catch( js_exception se ) {
cout << "message: " << se.get_message() << endl << flush;
cout << "file: " << se.get_file() << endl << flush;
cout << "line: " << se.get_line() << endl << flush;
ret = 1;
}
catch( ... ) {
cout << "unknown exception..." << endl;
ret = 1;
}
}

return ret;
}

