|

|
|
|
/* LoanCalc.rex this program computes loan payment values this program communicates with TopHat.EXE via the registry a tab delimited request is received from registry value: HKLM\Software\Kilowatt Software\R4\LoanCalc[Request] a tab delimited response is returned in registry value: HKLM\Software\Kilowatt Software\R4\LoanCalc[Response] */ tab = d2c( 9 ) /* get TopHat request */ request = value( 'HKLM\Software\Kilowatt Software\R4\LoanCalc[Request]', , 'Registry' ) /* parse tab delimited request fields */ parse var request downPayment (tab) principal (tab) pctRate (tab) periodType (tab) nperiods /* compute loan payment values */ workingPrincipal = principal - downPayment interest = ( pctRate / 100 ) / 12 /* convert annual interest rate to monthly rate */ if translate( left( periodType, 1 ) ) = 'Y' then nperiods = nperiods * 12 /* #payments in a year */ x = ( 1 + interest ) ** nperiods monthly = ( workingPrincipal * x * interest ) / ( x - 1 ) monthlyPayment = trunc( monthly, 2 ) total = monthly * nperiods totalPayment = trunc( total, 2 ) totalInterest = trunc( total - principal, 2 ) totalExpense = trunc( total + downPayment, 2 ) /* prepare tab delimited TopHat response */ response = monthlyPayment || tab || totalPayment || tab || totalInterest || tab || totalExpense 'set R4REGISTRYWRITE=Y' /* enable registry writing */ call value 'HKLM\Software\Kilowatt Software\R4\LoanCalc[Response]', response, 'Registry' |
|
/* LoanCalc.rex /* GetContact.rex this program obtains contact information via TopHat this program communicates with TopHat.EXE via the registry a tab delimited input value is acquired from registry value: HKLM\Software\Kilowatt Software\R4\Contact[Request] */ tab = d2c( 9 ) /* invoke TopHat with input file: Contact.TopHat */ trace off /* ignore error code when cancel is pressed */ 'TopHat Contact.TopHat' if rc <> 0 then /* cancel button was pressed */ exit 1 /* get TopHat input field values */ input = value( "HKLM\Software\Kilowatt Software\R4\Contact[Request]", , "Registry" ) /* parse tab delimited input field values */ parse var input , name (tab) , address1 (tab) , address2 (tab) , city (tab) , state (tab) , mailCode (tab) , phone (tab) , email (tab) , emailAlt (tab) , dateOfContact (tab) say 'Contact information:' say left( 'Name', 20 ) name say left( 'Address1', 20 ) address1 say left( 'Address2', 20 ) copies( address2, address2 <> '-' ) say left( 'City', 20 ) city say left( 'State', 20 ) state say left( 'Zip/Mail code', 20 ) mailCode say left( 'Phone', 20 ) phone say left( 'E-mail', 20 ) email say left( 'Alternate e-mail', 20 ) emailAlt say left( 'Date of contact', 20 ) dateOfContact exit 0 |
|
Contact information: Name John Doe Address1 11 Oak Street Address2 City Pleasantville State ZW Zip/Mail code 55555 Phone 999-555-1212 E-mail jdoe@bitbucket.com Alternate e-mail johndoe@elsewhere.com Date of contact 23 May 2001 |

