// step2a.cpp : Defines the initialization routines for the DLL.
//

#include "stdafx.h"
#include "step2a.h"
#include <ldefin2d.h>

#ifdef __LIGHT_VERSION__
#include <klAPI5.h>
#else
#include <kAPI5.h>
#endif

#include <ksConstants.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//
//	Note!
//
//		If this DLL is dynamically linked against the MFC
//		DLLs, any functions exported from this DLL which
//		call into MFC must have the AFX_MANAGE_STATE macro
//		added at the very beginning of the function.
//
//		For example:
//
//		extern "C" BOOL PASCAL EXPORT ExportedFunction()
//		{
//			AFX_MANAGE_STATE(AfxGetStaticModuleState());
//			// normal function body here
//		}
//
//		It is very important that this macro appear in each
//		function, prior to any calls into MFC.  This means that
//		it must appear as the first statement within the 
//		function, even before any object variable declarations
//		as their constructors may generate calls into the MFC
//		DLL.
//
//		Please see MFC Technical Notes 33 and 58 for additional
//		details.
//

/////////////////////////////////////////////////////////////////////////////
// CStep2aApp

BEGIN_MESSAGE_MAP(CStep2aApp, CWinApp)
	//{{AFX_MSG_MAP(CStep2aApp)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CStep2aApp construction

CStep2aApp::CStep2aApp()
{
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CStep2aApp object

CStep2aApp theApp;

//-------------------------------------------------------------------------------
//
// ---
unsigned int WINAPI LIBRARYID(){
	return IDS_LIBID;
}

KompasObject kompas( NULL );

void PointIndefiniteArray();
void TextIndefiniteArray();
void StrIndefiniteArray();
void AttrIndefiniteArray();
void PolyLineArray();
void RectArray();

//-------------------------------------------------------------------------------
//
// ---
void GetKompas() {
	if ( !kompas.m_lpDispatch ) {
		CString filename;
		if( ::GetModuleFileName(NULL, filename.GetBuffer(255), 255) ) {
			filename.ReleaseBuffer( 255 );
			CString libname;

      #ifdef __LIGHT_VERSION__
        libname.LoadString( IDS_STRING5 );  //klAPI5.dll
      #else
        libname.LoadString( IDS_STRING4 );  //kAPI5.dll
      #endif

			filename.Replace( filename.Right(filename.GetLength() - (filename.ReverseFind('\\') + 1)), 
												libname );

			HINSTANCE hAppAuto = LoadLibrary( filename ); //  kAPI5.dll
			if(  hAppAuto ) {
				typedef LPDISPATCH ( WINAPI *FCreateKompasObject )(); 
				FCreateKompasObject pCreateKompasObject = 
					(FCreateKompasObject)GetProcAddress( hAppAuto, "CreateKompasObject" );	
				if ( pCreateKompasObject ) 
					kompas = pCreateKompasObject();
				FreeLibrary( hAppAuto );
			}
		}
	}
}

//-------------------------------------------------------------------------------
//
// ---
void WINAPI LIBRARYENTRY( unsigned int comm ) {
	//      .exe ,     
	//   dll   define
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	GetKompas();
	if ( kompas.m_lpDispatch ) {
		switch ( comm ) {
		case 1  : ::StrIndefiniteArray();     break; //  
		case 2  : ::PointIndefiniteArray();   break; //   
		case 3  : ::TextIndefiniteArray();    break; //    ""
		case 4  : ::AttrIndefiniteArray();    break; //    
		case 5  : ::PolyLineArray();          break; //  
		case 6  : ::RectArray();              break; //   
		}
	}
}

//--------------------------------------------------------------------------
//          ,
//       ,    
//    ,   
//  (  ,  ,   . .)
//--------------------------------------------------------------------------
void TextIndefiniteArray() {
  char buf[128];
  ksTextLineParam par ( kompas.GetParamStruct(ko_TextLineParam) );
  ksTextItemParam par1( kompas.GetParamStruct(ko_TextItemParam) );
  //    
  ksDynamicArray  p   ( kompas.GetDynamicArray(TEXT_LINE_ARR)      );
  if ( par.m_lpDispatch && par1.m_lpDispatch && p.m_lpDispatch ) {
	  par.Init();
	  par1.Init();
	  //    
	  ksDynamicArray p1( par.GetTextItemArr() );
	  if ( p1.m_lpDispatch ) {
		  ksTextItemFont font( par1.GetItemFont() );
		  if ( font.m_lpDispatch ) {
				//    
				font.SetHeight( 10 );   //  
				font.SetKsu( 1 );       //  
				font.SetColor( 1000 );  // 
				font.SetBitVector( 1 ); //   (, , ,   (, ,   ))
				par1.SetS( CString("1  1 ") );
				//  1-     
				p1.ksAddArrayItem( -1, par1 );

				font.SetHeight( 20 );   //  
				font.SetKsu( 2 );       //  
				font.SetColor( 2000 );  // 
				font.SetBitVector( 2 ); //   (, , ,   (, ,   ))
				par1.SetS( CString("2  1 ") );
				//  2-     
				p1.ksAddArrayItem( -1, par1 );
				par.SetStyle( 1 );

				// 1-          
				//   
				p.ksAddArrayItem( -1, par );

				//   ,     
				//  
				p1.ksClearArray();

			  //    
				font.SetHeight( 30 );   //  
				font.SetKsu( 3 );       //  
				font.SetColor( 3000 );  // 
				font.SetBitVector( 3 ); //   (, , ,   (, ,   ))
				par1.SetS( CString("1  2 ") );
				//  1-     
				p1.ksAddArrayItem( -1, par1 );

				font.SetHeight( 40 );   //  
				font.SetKsu( 4 );       //  
				font.SetColor( 4000 );  // 
				font.SetBitVector( 4 ); //   (, , ,   (, ,   ))
				par1.SetS( CString("2  2 ") );
				//  2-     
				p1.ksAddArrayItem( -1, par1 );

				par.SetStyle( 2 );

				// 2-          
				//   		 }
				p.ksAddArrayItem( -1, par );

				kompas.ksMessageBoxResult();

				int n = p.ksGetArrayCount();
				::sprintf( buf, " n = %d ", n );
				kompas.ksMessage( buf );
				//    
				for ( int i = 0; i < n; i++ ) {  //    
					p.ksGetArrayItem( i, par );
					::sprintf( buf, "i = %d: style = %d,", i, par.GetStyle() );
					kompas.ksMessage( buf );

					int n1 = p1.ksGetArrayCount();
					for ( int j = 0; j < n1; j++ ) {  //     
						p1.ksGetArrayItem( j, par1 );
						::sprintf( buf, "j = %d:  h = %5.1f, s = %s", j, font.GetHeight(), par1.GetS() );
						kompas.ksMessage( buf );
					}
				}

				kompas.ksMessageBoxResult(); //     

				//      
				p.ksGetArrayItem( 0, par );
				font.SetHeight( 50 );   //  
				font.SetKsu( 1 );       //  
				font.SetColor( 1000 );  // 
				font.SetBitVector( 1 ); //   (, , ,   (, ,   ))
				par1.SetS( CString("2 . 1 .") );
				p1.ksSetArrayItem( 1, par1 );
				par.SetStyle( 3 );
				p.ksSetArrayItem( 0, par );

				//      
				p.ksGetArrayItem( 1, par );
				font.SetHeight( 60 );   //  
				font.SetKsu( 1 );       //  
				font.SetColor( 1000 );  // 
				font.SetBitVector( 1 ); //   (, , ,   (, ,   ))
				par1.SetS( CString("1 . 2 .") );
				p1.ksSetArrayItem( 0, par1 );
				par.SetStyle( 4 );
				p.ksSetArrayItem( 1, par );

				n = p.ksGetArrayCount();
				//    
				for ( i = 0; i < n; i++ ) {  //    
					p.ksGetArrayItem( i, par );
					::sprintf( buf, "i = %d: style = %d,", i, par.GetStyle() );
					kompas.ksMessage( buf );

					int n1 = p1.ksGetArrayCount();
					for ( int j = 0; j < n1; j++ ) {  //     
						p1.ksGetArrayItem( j, par1 );
						::sprintf( buf, "j = %d:  h = %5.1f, s = %s", j, font.GetHeight(), par1.GetS() );
						kompas.ksMessage( buf );
					}
				}

				kompas.ksMessageBoxResult(); //     

				p1.ksDeleteArray();
				p.ksDeleteArray();
			}
		}
	}	
}


//--------------------------------------------------------------------------
//          MathPointParam
//--------------------------------------------------------------------------
void PointIndefiniteArray() {
	char buf[128];
	ksMathPointParam par( kompas.GetParamStruct(ko_MathPointParam) );
  //  
	ksDynamicArray p    ( kompas.GetDynamicArray(POINT_ARR) );
	if ( p.m_lpDispatch && par.m_lpDispatch ) {
	  //  
		par.Init();
		par.SetX( 10 );
		par.SetY( 10 );
		p.ksAddArrayItem( -1, par );
		par.SetX( 20 );
		par.SetY( 20 );
		p.ksAddArrayItem( -1, par );
		par.SetX( 30 );
		par.SetY( 30 );
		p.ksAddArrayItem( -1, par );

		kompas.ksMessageBoxResult();

	  //  
		int n = p.ksGetArrayCount();
		::sprintf( buf, " n = %d ", n );
		kompas.ksMessage( buf );

		for ( int i = 0; i < n; i++ ) {
		  p.ksGetArrayItem( i, par );
			::sprintf( buf, "i = %d:  x = %5.1f, y = %5.1f", i, par.GetX(), par.GetY() );
			kompas.ksMessage( buf );
		}

		//   1- 
		par.SetX( 50 );
		par.SetY( 50 );
		p.ksSetArrayItem( 1, par );

	  //   0- 
		par.SetX( 60 );
		par.SetY( 60 );
		p.ksSetArrayItem( 0, par );

	  //  
		n = p.ksGetArrayCount();
		for ( i = 0; i < n; i++ ) {
		  p.ksGetArrayItem( i, par );
			::sprintf( buf, "i = %d:  x = %5.1f, y = %5.1f", i, par.GetX(), par.GetY() );
			kompas.ksMessage( buf );
		}

		kompas.ksMessageBoxResult();

		p.ksDeleteArray();
	}
}

//--------------------------------------------------------------------------
//      
//--------------------------------------------------------------------------
void StrIndefiniteArray() {
  char buf[128];
  //  
	ksChar255      charS( kompas.GetParamStruct(ko_Char255) );
	ksDynamicArray p    ( kompas.GetDynamicArray(CHAR_STR_ARR) );
	if ( p.m_lpDispatch && charS.m_lpDispatch ) {
		charS.Init();
	  //  
		charS.SetStr( CString("12345") );
		p.ksAddArrayItem( -1, charS );
		charS.SetStr( CString("67890") );
		p.ksAddArrayItem( -1, charS );
		charS.SetStr( CString("qwerty") );
		p.ksAddArrayItem( -1, charS );

		kompas.ksMessageBoxResult();

	  //  
		int n = p.ksGetArrayCount();
		::sprintf( buf, " n = %d ", n );
		kompas.ksMessage( buf );

		for ( int i = 0; i < n; i++ ) {
		  p.ksGetArrayItem( i, charS );
			kompas.ksMessage( charS.GetStr() );
		}

		//     1
		p.ksExcludeArrayItem( 1 );
		n = p.ksGetArrayCount();

	  //  
		for ( i = 0; i < n; i++ ) {
		  p.ksGetArrayItem( i, charS );
			kompas.ksMessage( charS.GetStr() );
		}

		kompas.ksMessageBoxResult();

		p.ksDeleteArray();
	}
}

//-------------------------------------------------------------------------------
// 
// ---
static void ShowColumns( ksDynamicArray& pCol, bool fl ) {
  ksColumnInfoParam par( kompas.GetParamStruct(ko_ColumnInfoParam) );
	if ( par.m_lpDispatch ) {
		par.Init();
	  
		char buf[128];
	  char s[10];
	  if ( fl )
		  ::strcpy( s, "" );
		else
			s[0]='\0';

		int n = pCol.ksGetArrayCount();

	  for ( int i = 0; i < n; i++ ) {
		  if ( !pCol.ksGetArrayItem(i, par) )
			  kompas.ksMessageBoxResult();  //     
			else {
			  //    
			  ::sprintf( buf, "%s i=%d header=%s type=%d def=%s flagEnum=%d", s, i, par.GetHeader(),
						       par.GetType(), par.GetDef(), par.GetFlagEnum() );
				kompas.ksMessage( buf );
				if( par.GetType() == RECORD_ATTR_TYPE )  { // 
					ksDynamicArray pCol( par.GetColumns() );
					if ( pCol.m_lpDispatch ) {
						::ShowColumns( pCol, true );
						pCol.ksDeleteArray();
					}
				}
				else {
					if ( par.GetFlagEnum() ) { //   
						ksDynamicArray fEnum( par.GetFieldEnum() );
						if ( fEnum.m_lpDispatch ) {
			        int n1 = fEnum.ksGetArrayCount();
						  kompas.ksMessage( " " );
							ksChar255 charS( kompas.GetParamStruct(ko_Char255) );
							for ( int i1 = 0; i1 < n1; i1++ ) 
			          if ( !fEnum.ksGetArrayItem( i1, charS) )
						      kompas.ksMessageBoxResult();  //     
			          else 
						      kompas.ksMessage( charS.GetStr() );
						}
					}
				}
			}
		}
	}
}

//--------------------------------------------------------------------------
//         ,
//       
//---------------------------------------------------------------------------
void AttrIndefiniteArray(){
/*
    3 
     int    ( 100, 200, 300 )
   -   
 struct {
   double ;//   123456789
   long   ;//   1000000
   char   ;//   10
 }
       "text"
*/
	ksColumnInfoParam parCol1  ( kompas.GetParamStruct(ko_ColumnInfoParam) );
	ksColumnInfoParam parCol2  ( kompas.GetParamStruct(ko_ColumnInfoParam) );
	ksColumnInfoParam parCol3  ( kompas.GetParamStruct(ko_ColumnInfoParam) );
	ksColumnInfoParam parStruct( kompas.GetParamStruct(ko_ColumnInfoParam) );
	ksDynamicArray    pCol     ( kompas.GetDynamicArray(ATTR_COLUMN_ARR)      );
	ksChar255         charS    ( kompas.GetParamStruct(ko_Char255)         );
	if ( parCol1.m_lpDispatch && parCol2.m_lpDispatch && parCol3.m_lpDispatch
				&& parStruct.m_lpDispatch && charS.m_lpDispatch && pCol.m_lpDispatch ) {
	  //  
		parCol1.Init();
		parCol1.SetHeader( CString("int") );  // o- 
		parCol1.SetType( INT_ATTR_TYPE );     //     - .
		parCol1.SetKey( 0 );                  //  ,        
		parCol1.SetDef( CString("100") );     //   
		parCol1.SetFlagEnum( true );          //   ,          

		ksDynamicArray pEnum( kompas.GetDynamicArray(CHAR_STR_ARR) );
		if ( pEnum.m_lpDispatch ) {
			//      
			charS.Init();
			charS.SetStr( CString("100") );
			pEnum.ksAddArrayItem( -1, charS );
			charS.SetStr( CString("200") );
			pEnum.ksAddArrayItem( -1, charS );
			charS.SetStr( CString("300") );
			pEnum.ksAddArrayItem( -1, charS );

			parCol1.SetFieldEnum( pEnum );      //     ()
		}

		pCol.ksAddArrayItem( -1, parCol1 );

		//  
		parCol2.Init();
		parCol2.SetHeader( CString("struct") );  // o- 
		parCol2.SetType( RECORD_ATTR_TYPE );     //     - .
		parCol2.SetKey( 0 );                     //  ,        
		parCol2.SetDef( CString("\0") );         //   
		parCol2.SetFlagEnum( false );            //   ,          
		
		ksDynamicArray pStruct( kompas.GetDynamicArray(ATTR_COLUMN_ARR) );
		if ( pStruct.m_lpDispatch ) {
		  //     
			//    
			parStruct.Init();
			parStruct.SetHeader( CString("double") );  // o- 
			parStruct.SetType( DOUBLE_ATTR_TYPE );     //     - .
			parStruct.SetDef( CString("123456789") );  //   
			pStruct.ksAddArrayItem( -1, parStruct );

		  //   
			parStruct.Init();
			parStruct.SetHeader( CString("long ") );  // o- 
			parStruct.SetType( LINT_ATTR_TYPE );      //     - .
			parStruct.SetDef( CString("1000000") );   //   
			pStruct.ksAddArrayItem( -1, parStruct );

		  //   
			parStruct.Init();
			parStruct.SetHeader( CString("char") );   // o- 
			parStruct.SetType( CHAR_ATTR_TYPE );      //     - .
			parStruct.SetDef( CString("10") );        //   
			pStruct.ksAddArrayItem( -1, parStruct );

			parCol2.SetColumns( pStruct );         //        
		}

		pCol.ksAddArrayItem( -1, parCol2 );

		//   
		parCol3.Init();
		parCol3.SetHeader( CString("string") );  // o- 
		parCol3.SetType( STRING_ATTR_TYPE );     //     - .
		parCol3.SetKey( 0 );                     //  ,        
		parCol3.SetDef( CString("text") );       //   

		pCol.ksAddArrayItem( -1, parCol3 );

	  kompas.ksMessageBoxResult();  //     

		//   
		::ShowColumns( pCol, false ); //  

	  kompas.ksMessageBoxResult();  //     

	  //     2->1 1->3 3->2
		pCol.ksSetArrayItem( 0, parCol2 );
		pCol.ksSetArrayItem( 2, parCol1 );
		pCol.ksSetArrayItem( 1, parCol3 );

		//   
		::ShowColumns( pCol, false ); //  

	  kompas.ksMessageBoxResult();  //     
	
		pStruct.ksDeleteArray();
		pEnum.ksDeleteArray();
		pCol.ksDeleteArray();
	}
}

//-------------------------------------------------------------------------------
//       
//-------------------------------------------------------------------------------
void PolyLineArray() {
	char buf[128];
	ksMathPointParam par( kompas.GetParamStruct(ko_MathPointParam) );
	//  
	ksDynamicArray arrPoint( kompas.GetDynamicArray(POINT_ARR) );
	//  
	ksDynamicArray arrPoly( kompas.GetDynamicArray(POLYLINE_ARR) );
	if ( par.m_lpDispatch && arrPoint.m_lpDispatch &&arrPoly.m_lpDispatch ) {
		//  
		par.SetX( 10 );
		par.SetY( 10 );
		arrPoint.ksAddArrayItem( -1, par );
		par.SetX( 100 );
		par.SetY( 100 );
		arrPoint.ksAddArrayItem( -1, par );
		par.SetX( 1000 );
		par.SetY( 1000 );
		arrPoint.ksAddArrayItem( -1, par );
		//     
		arrPoly.ksAddArrayItem( -1, arrPoint );
		kompas.ksMessageBoxResult();

		//  
		arrPoint.ksClearArray();
		par.SetX( 20 );
		par.SetY( 20 );
		arrPoint.ksAddArrayItem( -1, par );
		par.SetX( 200 );
		par.SetY( 200 );
		arrPoint.ksAddArrayItem( -1, par );
		par.SetX( 2000 );
		par.SetY( 2000 );
		arrPoint.ksAddArrayItem( -1, par );
		//     
		arrPoly.ksAddArrayItem( -1, arrPoint );
		kompas.ksMessageBoxResult();

		//  
		arrPoint.ksClearArray();
		par.SetX( 30 );
		par.SetY( 30 );
		arrPoint.ksAddArrayItem( -1, par );
		par.SetX( 300 );
		par.SetY( 300 );
		arrPoint.ksAddArrayItem( -1, par );
		par.SetX( 3000 );
		par.SetY( 3000 );
		arrPoint.ksAddArrayItem( -1, par );
		//     
		arrPoly.ksAddArrayItem( -1, arrPoint );
		kompas.ksMessageBoxResult();

		int count = arrPoly.ksGetArrayCount();
		::sprintf( buf, "n=%d", count );
		kompas.ksMessage( buf );

		arrPoly.ksGetArrayItem( 1, arrPoint );
		// 2-   
		count = arrPoint.ksGetArrayCount();
		for ( int i = 0; i < count; i++ ) {
			arrPoint.ksGetArrayItem( i, par );
			::sprintf( buf, "i=%d, x=%g, y=%g", i, par.GetX(), par.GetY() );
			kompas.ksMessage( buf );
		}

		//  2 -    2- 
		par.SetX( 50 );
		par.SetY( 50 );
		arrPoint.ksSetArrayItem( 1, par );
		par.SetX( 500 );
		par.SetY( 500 );
		arrPoint.ksSetArrayItem( 0, par );
		arrPoly.ksSetArrayItem( 1, arrPoint );

		count = arrPoly.ksGetArrayCount();
		for ( i = 0; i < count; i++ ) {
			arrPoly.ksGetArrayItem( i, arrPoint );
			int n = arrPoint.ksGetArrayCount();
			for ( int j = 0; j < n; j++ ) {
				arrPoint.ksGetArrayItem( j, par );
				::sprintf( buf, "i=%d, j=%d, x=%g, y=%g", i, j, par.GetX(), par.GetY() );
				kompas.ksMessage( buf );
			}
		}
		kompas.ksMessageBoxResult();
		arrPoint.ksDeleteArray();
		arrPoly.ksDeleteArray();
	}
}

//--------------------------------------------------------------------------------
//     -( RectParam)
//--------------------------------------------------------------------------------
void RectArray() {
	ksRectParam par( kompas.GetParamStruct(ko_RectParam) ); //  
	ksDynamicArray arr( kompas.GetDynamicArray(RECT_ARR) );    //  
	ksMathPointParam pBot( kompas.GetParamStruct(ko_MathPointParam) );
	ksMathPointParam pTop( kompas.GetParamStruct(ko_MathPointParam) );
	if ( arr.m_lpDispatch && par.m_lpDispatch && pBot.m_lpDispatch && pTop.m_lpDispatch ) {
		// 
		pTop.SetX( 10 );
		pTop.SetY( 10 );
		par.SetpTop( pTop );
		pBot.SetX( 20 );
		pBot.SetY( -10 );
		par.SetpBot( pBot );
		arr.ksAddArrayItem( -1, par );

		pTop.SetX( 20 );
		pTop.SetY( 50 );
		par.SetpTop( pTop );
		pBot.SetX( 50 );
		pBot.SetY( 10 );
		par.SetpBot( pBot );
		arr.ksAddArrayItem( -1, par );

		pTop.SetX( 20 );
		pTop.SetY( 150 );
		par.SetpTop( pTop );
		pBot.SetX( 50 );
		pBot.SetY( 110 );
		par.SetpBot( pBot );
		arr.ksAddArrayItem( -1, par );
		kompas.ksMessageBoxResult();

		// 
		int n = arr.ksGetArrayCount();

		char buf[255];
		::sprintf( buf, "n=%d", n );
		kompas.ksMessage( buf );

		for ( int i = 0; i < n; i++ ) {
			arr.ksGetArrayItem( i, par );
			pBot = par.GetpBot();
			pTop = par.GetpTop();
			::sprintf( buf, "i=%d, x1=%5.1f, y1=%5.1f,\n     x2=%5.1f, y2=%5.1f, ", i, 
								 pTop.GetX(), pTop.GetY(), pBot.GetX(), pBot.GetY() );
			kompas.ksMessage( buf );
		}

		// 
		pTop.SetX( -20 );
		pTop.SetY( -50 );
		par.SetpTop( pTop );
		pBot.SetX( 20 );
		pBot.SetY( -10 );
		par.SetpBot( pBot );
		arr.ksSetArrayItem( 1, par );

		pTop.SetX( 0 );
		pTop.SetY( 0 );
		par.SetpTop( pTop );
		pBot.SetX( 10 );
		pBot.SetY( -20 );
		par.SetpBot( pBot );
		arr.ksSetArrayItem( 0, par );

		pTop.SetX( 5 );
		pTop.SetY( 5 );
		par.SetpTop( pTop );
		pBot.SetX( 25 );
		pBot.SetY( 0 );
		par.SetpBot( pBot );
		arr.ksAddArrayItem( -1, par );

		// 
		n = arr.ksGetArrayCount();
		for ( i = 0; i < n; i++ ) {
			arr.ksGetArrayItem( i, par );
			pBot = par.GetpBot();
			pTop = par.GetpTop();
			::sprintf( buf, "i=%d, x1=%5.1f, y1=%5.1f,\n     x2=%5.1f, y2=%5.1f, ", i, 
								 pTop.GetX(), pTop.GetY(), pBot.GetX(), pBot.GetY() );
			kompas.ksMessage( buf );
		}
		kompas.ksMessageBoxResult();

		// 
		arr.ksDeleteArray();
	}
}
