//-------------------------------------------------------------------//
//-------------------------------------------------------------------//
//-------------------------------------------------------------------//
//
// V32xDemo.prg
// Demonstrats Various Servers Vouch32 ActiveX Exposes
//
// Copyright (C) 2006, Pritpal Bedi <pritpal@vouchcac.com>
// All Rights Reserved.
//
//-------------------------------------------------------------------//
//-------------------------------------------------------------------//
//-------------------------------------------------------------------//

#define RGB( r,g,b ) ( r + ( g*256 ) + ( b*256*256 ) )

#define CLR_BLACK RGB( 0, 0, 0 )
#define CLR_WHITE RGB( 255,255,255 )
#define CLR_DARKRED RGB( 128, 0, 0 )
#define CLR_DARKBLUE RGB( 0, 0,128 )
#define CLR_DARKGREEN RGB( 0,128, 0 )
#define CLR_DARKMAGENTA RGB( 128, 0,128 )
#define CLR_BROWN RGB( 128,128, 0 )
#define CLR_DARKGRAY RGB( 128,128,128 )
#define CLR_LIGHTGRAY RGB( 225,225,225 )
#define CLR_CYAN RGB( 0,128,128 )
#define CLR_BLUE RGB( 0, 0,255 )
#define CLR_RED RGB( 255, 0, 0 )
#define CLR_GRAY RGB( 192,192,192 )
#define CLR_GREEN RGB( 0,255, 0 )
#define CLR_PINK RGB( 255, 0,128 )
#define CLR_MAGENTA RGB( 255, 0,255 )
#define CLR_YELLOW RGB( 255,255, 0 )
#define CLR_LIGHTCYAN RGB( 0,255,255 )
#define CLR_LIGHTYELLOW RGB( 255,255,185 )

//-------------------------------------------------------------------//

#define TA_LEFT 0
#define TA_RIGHT 1
#define TA_CENTER 2

#define FT_TIMES 'Times New Roman'
#define FT_ARIEL 'Ariel'
#define FT_SYSTEM 'System'

#define COL_DETAIL 3
#define ROW_DETAIL 25
#define ROW_LAST 55

#define OR_DEFAULT 0
#define OR_PORTRAIT 1
#define OR_LANDSCAPE 2

//-------------------------------------------------------------------//

#define V32_3OF9 1
#define V32_128B 2
#define V32_CODE39 3
#define V32_EAN13 4
#define V32_EAN13B 5
#define V32_I2OF5 6

//-------------------------------------------------------------------//

#define TS_NORMAL 0
#define TS_BOLD 1
#define TS_ITALICS 2
#define TS_UNDERLINE 4
#define TS_STRIKEOUT 8

//-------------------------------------------------------------------//

#define PS_SOLID 0
#define PS_DASH 1
#define PS_DOT 2
#define PS_DASHDOT 3
#define PS_DASHDOTDOT 4
#define PS_NULL 5

//-------------------------------------------------------------------//

#ifdef __WVT__
REQUEST Wvt_SetCodePage
REQUEST Wvt_Util
REQUEST Wvt_Core
#endif

//-------------------------------------------------------------------//
#ifdef __XHARBOUR__
#pragma BEGINDUMP

#include <windows.h>
#include "hbapi.h"

HB_FUNC_STATIC( DLLREGISTERSERVER )
{
ShellExecute( NULL, "OPEN", "REGSVR32.EXE", hb_parc( 1 ), NULL, SW_SHOWNORMAL );
}

HB_FUNC_STATIC( SLEEP )
{
Sleep( hb_parni( 1 ) );
}

#pragma ENDDUMP
#endif
//-------------------------------------------------------------------//

Procedure Main()
Local aMenu, nChoice
Local a_:={}


SetColor( 'n/w,w/n,w/n,w/n,b/w' )
CLS

aMenu := {}
aadd( a_, { 'Print Server' , {|| V32xPrintObject() } } )
aadd( a_, { 'Graphic Server' , {|| V32xGraphicObject() } } )
aadd( a_, { 'Sms Server' , {|| V32xSmsObject() } } )
aadd( a_, { 'Tapi Server' , {|| V32xTapiObject() } } )
aadd( a_, { 'Serial Communication' , {|| V32xCommObject() } } )
aadd( a_, { 'Serial Communication II', {|| V32xCommObject1() } } )
aadd( a_, { 'Pop Server' , {|| V32xPopObject() } } )
aadd( a_, { 'SMTP Server' , {|| V32xSmtpObject() } } )
aadd( a_, { 'Ftp Server' , {|| V32xFtpObject() } } )

aeval( a_, {|e_| aadd( aMenu, e_[ 1 ] ) } )

do while .t.
   nChoice := aChoice( 7, 25, 20, 55, aMenu, , , nChoice )
   if nChoice == 0
      exit
   endif

   eval( a_[ nChoice,2 ] )
enddo

RETURN

//-------------------------------------------------------------------//

Function CreateVouch32( oServer )
Local cServer := 'Vouch32.Vouch.1'
Local cDataPath := '\Vouch32X\ActiveX'

#ifdef __XHARBOUR__
TRY
   oServer := GetActiveObject( cServer )
   CATCH
      TRY
         oServer := CreateObject( cServer )
      CATCH
         DllRegisterServer( cDataPath + "\Vouch32x.dll" + ' /S' )

         Sleep( 10000 )

         TRY
            oServer := CreateObject( cServer )
         CATCH
            alert( ValToPrg( "ERROR! " + cServer + " not avialable. [" + Ole2TxtError()+ "]" ) )
            Return .f.
         END
      END
   END
   oServer:Vouch32SetLicenseKey( 'THIS IS DEMO STRING' )
   oServer:Vouch32SetClientConsole()
#else
   TRY
      oServer := GetActiveObject( cServer )
   CATCH
      TRY
         oServer := CreateObject( cServer )
      CATCH
         alert( ValToPrg( "ERROR! " + cServer + " not avialable. [" + Ole2TxtError()+ "]" ) )
         Return .f.
      END
   END

   // The placeholder of your license key provided to you separately when you
   // purchase the subscription. The key will be shippedseparately along with
   // Vouch32X.lic key which need to be put alongwith Vouch32x.dll.
   //
   oServer:Vouch32SetLicenseKey( 'THIS IS DEMO STRING' )

   // Supress the following line if your application is is true Windows application.
   // Note that, GTWVT and GTWVW applications are true Windows applns.
   // Vouch32SetClientConsole() tells the com object that this is console appln and
   // all dialogs be presented as modal.
   //
   oServer:Vouch32SetClientConsole()
#endif

Return .t.

//-------------------------------------------------------------------//

Static Function V32ArView( a_ )
Local n
Local array_:={}
Local cScr := SaveScreen( 0,0,maxrow(),maxcol() )

CLS

if valtype( a_ ) <> 'A'
   a_:= { a_ }
endif

if !empty( a_ )
   array_:= LodValues( a_ )
   n := 0

   do while .t.
      n := aChoice( 1,2,23,77, array_, , , n + 1 )
      if n == 0
         exit
      endif

      if valtype( a_[ n ] ) == 'A'
         V32Arview( a_[ n ] )
      endif
   enddo

endif

RestScreen( 0,0,maxrow(),maxcol(),cScr )

return nil

//-------------------------------------------------------------------//

Static Function LodValues( a_ )
Local arr_:={}
Local i, type, s

for i := 1 to len( a_ )
   type := valtype( a_[ i ] )
   s := pad( ltrim( str( i ) ), 4 )

   do case
   case type == 'A'
      aadd( arr_, s + ' A ' + 'Array of Length ' + str( len( a_[ i ] ),4 ) )
   case type == 'B'
      aadd( arr_, s + ' B ' + 'Code Block' )
   case type == 'C'
      aadd( arr_, s + ' C ' + trim( a_[ i ] ) )
   case type == 'D'
      aadd( arr_, s + ' D ' + dtoc( a_[ i ] ) )
   case type == 'L'
      aadd( arr_, s + ' L ' + if( a_[ i ], 'Yes', 'No' ) )
   case type == 'M'
      aadd( arr_, s + ' M ' + 'Memo' )
   case type == 'N'
      aadd( arr_, s + ' N ' + ltrim( str( a_[ i ] ) ) )
   case type == 'U'
      aadd( arr_, s + ' U ' + 'Undefined' )
   endcase
next

return arr_

//-------------------------------------------------------------------//
//-------------------------------------------------------------------//
//-------------------------------------------------------------------//

#define DATA_BOTTOMLINE 1
#define DATA_COND_1 2
#define DATA_COND_2 3
#define DATA_COND_3 4
#define DATA_COND_4 5
#define DATA_DOCTITLE 6
#define DATA_LOGO 7
#define DATA_COMPANY 8
#define DATA_ADD1 9
#define DATA_ADD2 10
#define DATA_CITY 11
#define DATA_PHONE 12
#define DATA_EMAIL 13
#define DATA_MOTO 14

#define DATA_VRBLS 14

//-------------------------------------------------------------------//

Static Function V32xPrintObject()
Local lContinue, cCust, cCAdd1, cCAdd2, cCCity, nI, nN, nRow
Local cPOrder, cPODate, cInvoice, cInvDate, cDocTitle
Local nSamePage , cAmount, nAmount, nJ, nK, nCopies, lPreview
Local nOrient, nPage, nPrintDlg, oP, cPathFiles, nZoom
Local trn_ := {}
Local hdr_ := {}
Local oServer

if !( CreateVouch32( @oServer ) )
   Return nil
endif

cPathFiles := oServer:Vouch32ServerPath()
cPathFiles += '\Resource'
oP := oServer:Vouch32PrintServer()

hdr_:= array( DATA_VRBLS )

hdr_[ DATA_BOTTOMLINE ] := ' This document is generated through Vouch32 ActiveX '
hdr_[ DATA_COND_1 ] := '1. Library can be evaluated for three months.'
hdr_[ DATA_COND_2 ] := '2. Amount is payable by international draft.'
hdr_[ DATA_COND_3 ] := '3. Assured upgradations for first years assured.'
hdr_[ DATA_COND_4 ] := '* Errors & Ommissions Entertained!'
hdr_[ DATA_DOCTITLE ] := 'Invoice # 00000001'
hdr_[ DATA_LOGO ] := cPathFiles +'\abs6.bmp'
hdr_[ DATA_COMPANY ] := 'Vouch32 Inc.'
hdr_[ DATA_ADD1 ] := '60 New Professor Colony, Adj Sunil Park, Ludhiana'
hdr_[ DATA_PHONE ] := '+919814030917'
hdr_[ DATA_EMAIL ] := 'vouch32x@vouch32.com'
hdr_[ DATA_MOTO ] := 'you can bank upon'

// Invoice info
//
cPOrder := 'PO-9087T'
cPODate := date()-10
cInvoice := 'INV00210'
cInvDate := date()
cAmount := 'US$ Twenty Five Thousands Only'
nAmount := 25000.00

// Customer Info
//
cCust := 'Vardhman Knit'
cCadd1 := '1527/6, Sunder Nagar Enclave GM'
cCAdd2 := 'Jalandhar ByPass Phase IV'
cCCity := 'Ludhiana 141001 India'

trn_:={}
aadd( trn_, { cPathFiles + '\Vouch32.bmp' , 'BMP - 3OF9' , 'ITEM 123' , V32_3OF9 , 15000.00 } )
aadd( trn_, { cPathFiles + '\Legal.gif' , 'GIF - 128B' , 'COLGATE' , V32_128B , 5000.00 } )
aadd( trn_, { cPathFiles + '\Vouch32x.ico', 'ICO - EAN13' , 'ITEM 123' , V32_EAN13 , 200.00 } )
aadd( trn_, { cPathFiles + '\Abs6.jpg' , 'JPG - 30F9' , 'ITEM 123' , V32_3OF9 , 1.00 } )
aadd( trn_, { cPathFiles + '\Quit.ico' , 'ICO - EAN13B', 'ITEM 123' , V32_EAN13B, 2520.00 } )
aadd( trn_, { cPathFiles + '\Abs3.bmp' , 'BMP - I2OF5' , '12379021' , V32_I2OF5 ,1055000.00 } )
aadd( trn_, { cPathFiles + '\Abs2.bmp' , 'BMP - 3OF9' , 'COLGATE' , V32_128B , 50.00 } )
aadd( trn_, { cPathFiles + '\Abs8.bmp' , 'BMP - 3OF9' , 'ITEM 123' , V32_3OF9 , 1000.00 } )
aadd( trn_, { cPathFiles + '\Vouch32.jpg' , 'JPG - 3OF9' , 'COLGATE' , V32_128B , 22000.00 } )


// Preview Window Data
//
nCopies := 2
lPreview := .T.
nOrient := OR_PORTRAIT
nPrintDlg := 1
nZoom := 1.4
cDocTitle := 'Invoice #00000001'

oP:BeginDoc( 0, cDocTitle, nOrient, nCopies, lPreview, , , , nZoom, , , , , , , nPrintDlg, .t. )
oP:SetMonoPrint( .t. )
oP:Create()

nPage := 0
nN := 0
lContinue := .t.

oP:StartDoc()

do while ( lContinue )
   nPage++

   DrawHeaderFooters( oP, hdr_ )

   oP:TextOut( 16, 3, cCust )
   oP:TextOut( 17, 3, cCAdd1 )
   oP:TextOut( 18, 3, cCAdd2 )
   oP:TextOut( 19, 3, cCCity )

   oP:TextOut( 16, 59, cPOrder , , TA_RIGHT )
   oP:TextOut( 19, 59, cPODate , , TA_RIGHT )
   oP:TextOut( 16, 79, cInvoice, , TA_RIGHT )
   oP:TextOut( 19, 79, cInvDate, , TA_RIGHT )

   nRow := ROW_DETAIL
   nK := 0
   nSamePage := 0

   do while ( nSamePage == 0 )
      nN++
      oP:Bitmap( nRow , 3, nRow + 3, 15, trn_[ nN,1 ] )
      oP:TextOut( nRow, 17, trn_[ nN,2 ] )
      oP:BarCode( nRow, 30, trn_[ nN,3 ], 12, , , trn_[ nN,4 ], 0 )
      oP:TextOut( nRow, 79, trn_[ nN,5 ], , TA_RIGHT )

      nRow := ROW_DETAIL + ( ( nK + 1 ) * 4 )
      nK := nK + 1

      if ( nN + 1 ) > len( trn_ )
         lContinue := .f.
         nSamePage := 99
      endif

      if lContinue
         if nRow >= ( ROW_LAST - 4 )
            oP:TextOut( 56.5, 40, 'Over to next page ...',,TA_CENTER )
            oP:NewPage()
            nSamePage := 99
         endif
      endif
   enddo

   if nPage == 2
      DrawGrid( oP )
   endif
enddo

oP:TextOut( 56.5, 1, cAmount )
oP:TextOut( 56.5, 79, nAmount, , TA_RIGHT )

oP:EndDoc()

Return nil

//-------------------------------------------------------------------//

Static Function DrawHeaderFooters( oP, d_ )
Local aVertA := { 0x0000,0x0000,0xffff,0xffff }
Local aVertB := { 0xf000,0xffff,0x0000,0x0000 }

oP:TextOut( 11, 1, 'Invoice', , 0, 'Ariel', 1, 48, CLR_RED )

oP:Frame( 15.3, 1, 21 , 39, , , CLR_YELLOW )
oP:Line( 15.5, 1, 15.5, 39 )
oP:Frame( 15.3, 41, 21 , 80 )
oP:Line( 18 , 41, 18 , 80 )

oP:TextOut( 16, 42, 'Order:' )
oP:TextOut( 19, 42, 'Date:' )
oP:TextOut( 16, 61, 'Invoice:' )
oP:TextOut( 19, 61, 'Date:' )

oP:TextOut( 22, 1, pad( ' Description of Items',58 ),,,,,,,CLR_GRAY )
oP:TextOut( 22,61, padl( 'Amount ',19 ),,,,,,,CLR_GRAY )

oP:Frame( 24, 1, 56, 80, , , , , 2, 4 )
oP:Line( 15.3, 60, 56, 60 )

oP:Frame( 58.5, 1, 67, 80 )
oP:Line ( 58.5, 50, 67, 50 )

oP:TextOut( 59, 3, d_[ DATA_COND_1 ], , , FT_TIMES )
oP:TextOut( 61, 3, d_[ DATA_COND_2 ], , , FT_TIMES )
oP:TextOut( 63, 3, d_[ DATA_COND_3 ], , , FT_TIMES )
oP:TextOut( 65, 3, d_[ DATA_COND_4 ] )

oP:TextOut( 59, 79, 'for', , TA_RIGHT, , 2 )
oP:TextOut( 60, 79, d_[ DATA_COMPANY ], , TA_RIGHT, FT_ARIEL, , 16, CLR_DARKGREEN )
oP:TextOut( 65, 79, 'Authorised Signatory', , TA_RIGHT )

oP:Picture( 2 , 70, 5, 80, d_[ DATA_LOGO ] )

oP:TextOut( 5 , 80, d_[ DATA_COMPANY ], , 1, 'Ariel', 0, 24, CLR_DARKGREEN )
oP:TextOut( 7.5, 80, d_[ DATA_MOTO ] , , 1, 'Times New Roman', 2, 10 )
oP:TextOut( 2 , 1, d_[ DATA_MOTO ] , , 1, 'Times New Roman', 0, 12, , , 90 )

oP:TextOut( 10, 80, d_[ DATA_ADD1 ] , , TA_RIGHT, FT_ARIEL )
oP:TextOut( 11.5, 80, d_[ DATA_PHONE ] , , TA_RIGHT, FT_ARIEL )
oP:TextOut( 13, 80, d_[ DATA_EMAIL ] , , TA_RIGHT, FT_ARIEL,,,, CLR_LIGHTGRAY )

oP:Shaded( 68,1,72,80,0, aVertA, aVertB )

oP:TextOut( 69.4, 40, d_[ DATA_BOTTOMLINE ], , TA_CENTER,,,, CLR_WHITE )

Return nil

//-------------------------------------------------------------------//

Static Function DrawGrid( oP )
Local aData, aAttr, aHdg, aLns, aRowClr, bBlock, aColors, cFont

aData := {}
aadd( aData,{ 'Brij Bhushan' , 215.12, date() , 'Yes', 'Handsome' })
aadd( aData,{ 'Karan Johar Tana' , 22210900.00, date()-1, 'No' , 'Excellent'})
aadd( aData,{ 'Kuljit Singh Sethi' , 10025.00, date()-2, 'Yes', 'Smiling' })
aadd( aData,{ 'Jagmohan Jit Singh' , 413210.25, date()-3, 'Yes', 'Fine' })

aAttr := {}
// Title, Width, Picture, Font, Style, Size, TextColor, BackColor, Alignment
// Text/back color can be block as a string, nColorIndex, nAbsColor
//
aadd( aAttr,{ 'Name' , 20, ,,,,, , 0 } )
aadd( aAttr,{ 'Salary', 12, '@Z 999999999.99',,,, 'if( v < 21000, 3, 1 )', , 1 } )
aadd( aAttr,{ 'Since' , 8 } )
aadd( aAttr,{ 'Did' , 3, ,,,,, , 2 } )
aadd( aAttr,{ 'Look' , 10, ,,,,, , 1 } )

cFont := 'Times New Roman'


// Attribitutes for Headings over the Grid
//
aHdg := { .t., 2, cFont, TS_BOLD+TS_ITALICS, 16, CLR_DARKBLUE, , , 0.5 }



// Attributes for the Lines of the Grid
// Outline/vertical/Horizontal
//
aLns := { { 10, CLR_DARKGREEN }, { 1, ,PS_DOT }, { 1, CLR_RED, PS_NULL } }



// Cell Colors, if a block is provided, index in this array is looked for.
//
aColors := { CLR_BLACK, /* transparent */, CLR_YELLOW }



// Colors for the indivisual rows repeated alternatively.
// You can provide as many rows as you wish, nil will be treated as background
//
aRowClr := { /* as background */, CLR_LIGHTYELLOW, CLR_LIGHTGRAY, CLR_LIGHTCYAN }



// Draw the Grid
//
oP:Grid( 43, 3, 11, 75, aData, aAttr, aHdg, aLns, aColors, aRowClr )


Return nil

//-------------------------------------------------------------------//

Function V32xSmsObject()
Local cAddress := '13236847318'
Local oSMS, i, a_
Local oServer

if !( CreateVouch32( @oServer ) )
   Return nil
endif

oSMS := oServer:Vouch32SmsServer()

cAddress := '+919814030917'

oSMS:nPort := 2
oSMS:cSMSText := 'This message is via Vouch32 ActiveX !'

oSMS:Create()
if oSMS:lInitialized
   /*
   if oSms:SMSSend( cAddress )
   alert( 'SMS is sent !' )
   //? oSMS:SMSSend( cAddress, 'This is second message !' )
   //alert( oSMS:cErrorString )
   else
   alert( oSMS:cErrorString )
   endif
   */

   //? oSMS:SMSDelete( 5 )

   a_:= oSMS:SMSReceive()
   V32Arview( oSMS:aReads )

   oSMS:Destroy()
else
   alert( oSMS:cErrorString )
endif

Return nil

//-------------------------------------------------------------------//

Function V32xGraphicObject()
Local oGraph, oServer

if !( CreateVouch32( @oServer ) )
   Return nil
endif

oGraph := oServer:Vouch32GraphicsServer()

oGraph:Create()

oGraph:Destroy()

Return nil

//-------------------------------------------------------------------//

Function V32xTapiObject()
Local oTapi, oServer

if !( CreateVouch32( @oServer ) )
   Return nil
endif

oTapi := oServer:Vouch32TapiServer()

oTapi:cDevice := 'IPCONF LINE'

oTapi:Create()
if oTapi:lCreated
   V32Arview( oTapi:aDevices )

   if oTapi:Initialize()
      V32Arview( oTapi:Dial( '2067' ) )
      V32Arview( oTapi:aParam )
   endif
endif

// This is not to be issued therwise nothing will happen
//
//oTapi:Destroy()

Return nil

//----------------------------------------------------------------------//

Function V32xCommObject()
Local n, oCom, oServer
Local a_:={}

if !( CreateVouch32( @oServer ) )
   Return nil
endif

oCom := oServer:Vouch32CommServer()
oCom:ReadIntervalTimeout := 16

if oCom:Com_Open( 2,300,300 )
   if oCom:Com_Init( 2, 9600, 'E' )
      oCom:Com_Hard( 2, .f. )
      oCom:Com_Soft( 2, .f. )
      aadd( a_, oCom:aDcb )

      oCom:Com_Hard( 2, .t. )
      oCom:Com_Soft( 2, .t. )
      aadd( a_, oCom:aDcb )

      aadd( a_, oCom:Com_Timeouts( 2 ) )
      aadd( a_, oCom:Com_Properties( 2 ) )
      aadd( a_, oCom:Com_Error( 2 ) )
      aadd( a_, oCom:Com_GetMask( 2 ) )
      aadd( a_, oCom:Com_Send( 2,'ATZ' ) )
      INKEY( 2 )
      aadd( a_, n := oCom:Com_Count( 2 ) )
      aadd( a_, oCom:Com_Read( 2,n ) )
      aadd( a_, oCom:Com_ReadString( 2 ) )
      aadd( a_, oCom:Com_Stat( 2 ) )

      aadd( a_, oCom:Com_DefaultConfig( 'COM2' ) )
      aadd( a_, oCom:Com_Dialog( 'COM2' ) )

      oCom:Com_Close( 2 )

      V32Arview( a_ )
   else
      oCom:Com_Close()
      alert( oCom:cErrorString )
   endif
else
   alert( oCom:cErrorString )
endif

Return nil

//-------------------------------------------------------------------//

Function V32xCommObject1()
Local n, oCom, oServer
Local a_:={}

if !( CreateVouch32( @oServer ) )
   Return nil
endif

oCom := oServer:Vouch32CommServer()
oCom:ncPort := 2
oCom:cParity := 'E'
oCom:nInBuffer := 300
oCom:nOutBuffer := 300
oCom:ReadIntervalTimeout := 16

oCom:Create()
if oCom:lInitialized
   oCom:ComHard( .f. )
   oCom:ComSoft( .f. )
   aadd( a_, oCom:aDcb )

   oCom:ComHard( .t. )
   oCom:ComSoft( .t. )
   aadd( a_, oCom:aDcb )

   aadd( a_, oCom:ComTimeouts() )
   aadd( a_, oCom:ComProperties() )
   aadd( a_, oCom:ComError() )
   aadd( a_, oCom:ComGetMask() )
   aadd( a_, oCom:ComSend( 'ATZ' ) )
   INKEY( 2 )
   aadd( a_, n := oCom:ComCount() )
   aadd( a_, oCom:ComRead( n ) )
   aadd( a_, oCom:ComReadString() )
   aadd( a_, oCom:ComStat() )

   aadd( a_, oCom:ComDefaultConfig( 'COM2' ) )
   aadd( a_, oCom:ComDialog( 'COM2' ) )

   oCom:Destroy()

   V32Arview( a_ )
else
   alert( oCom:cErrorString )
endif

Return nil

//-------------------------------------------------------------------//

Function V32xPopObject()
Local oPop, oServer
Local a_:={}

if CreateVouch32( @oServer )
   oPop := oServer:Vouch32PopServerT()

   oPop:cServer := 'mail.vouchcac.com'
   oPop:cUsername := 'viveka@vouchcac.com'
   oPop:cPassword := 'viveka'

   oPop:Create()

   if oPop:lInitialized
      aadd( a_, oPop:GetMessage( 1 ) )
      aadd( a_, oPop:GetHeader( 1 ) )
      aadd( a_, oPop:List() )

      oPop:Destroy()

      V32Arview( a_ )
   else
      alert( oPop:cErrorString )
   endif
endif

Return nil

//-------------------------------------------------------------------//

Function V32xSmtpObject()
Local oSmtp, oServer

if !( CreateVouch32( @oServer ) )
   Return nil
endif

oSmtp := oServer:Vouch32SmtpServerT()

oSmtp:cServer := 'mail.vouchcac.com'
oSmtp:cUserName := 'test@vouchcac.com'
oSmtp:cPassword := 'test'
oSmtp:acTo := 'test@vouchcac.com'
oSmtp:cMessage := 'Vouch32 ActiveX is ready to be LAUNCHED !'
oSmtp:cPop3Server := 'mail.vouchcac.com'
oSmtp:lLogFile := .t.

oSmtp:Create()

if oSmtp:lInitialized
   oSmtp:SendMail()

   oSmtp:Destroy()
endif

V32Arview( oSmtp:aLogInfo )

Return nil

//-------------------------------------------------------------------//

#define CRLF Chr(13)+chr(10)

Function V32xFtpObject()
Local cPath
Local oServer
Local oFtp
Local a_:={}

if CreateVouch32( @oServer )
   cPath := oServer:Vouch32ServerPath()
   cPath := substr( cPath, 1, rat( '\',cPath )-1 )

   oFtp := oServer:Vouch32FtpServerT()

   // Windows Server
   //
   oFtp:cServer := 'www.myserver.com'
   oFtp:cUsername := 'vouch32'
   oFtp:cPassword := 'vouch'

   // Linux Server
   //
   oFtp:cServer := 'www.vouch.ws'
   oFtp:cUsername := 'test@vouch.ws'
   oFtp:cPassword := 'vouch'

   oFtp:Create()

   if oFtp:lInitialized
      aadd( a_, 'Create Directory - vouch32ActiveX :' )
      aadd( a_, oFtp:CreateDirectory( 'vouch32ActiveX' ) )
      aadd( a_, 'Upload File - vouch32ActiveX/License.txt :' )
      aadd( a_, oFtp:PutFile( cPath+'\Readme\License.txt', 'vouch32ActiveX/License.txt' ) )
      aadd( a_, 'Download File - vouch32ActiveX/License.txt :' )
      aadd( a_, oFtp:GetFile( 'vouch32ActiveX/License.txt', cPath+'\Temp\License.txt' ) )
      aadd( a_, 'Delete File - vouch32ActiveX/License.001 :' )
      aadd( a_, oFtp:DeleteFile( 'vouch32ActiveX/License.001' ) )
      aadd( a_, 'Rename File - vouch32ActiveX/License.txt -> 001 :' )
      aadd( a_, oFtp:RenameFile( 'vouch32ActiveX/License.txt', 'vouch32ActiveX/License.001' ) )
      aadd( a_, 'Get Current Directory - root :' )
      aadd( a_, oFtp:GetCurrentDirectory() )
      aadd( a_, 'Set Current Directory - vouch32ActiveX :' )
      aadd( a_, oFtp:SetCurrentDirectory( 'vouch32ActiveX' ) )
      aadd( a_, 'Get Current Directory - vouch32ActiveX :' )
      aadd( a_, oFtp:GetCurrentDirectory() )
      aadd( a_, 'Get only .001 files :' )
      aadd( a_, oFtp:GetDirectory( '*.001' ) )

      oFtp:Destroy()

      V32Arview( a_ )
   else
      alert( oFtp:cErrorString )
   endif
endif

Return nil

//-------------------------------------------------------------------//