Hi,

I wrote the piece of code that follows. I hadn't touched C in years. I'd like to fill in the "blanks" that I wall-papered over to make ths work on my own. For example:

1. What is the difference between a "double" and a "long double" in terms of the range of values/accuracy?

2. I'm using the free Borland 2006 that was passed out years ago with a hundred year license. I won't change that. I need to know how to use the label and text boxes available with Borland 2006 to display numbers, and, given my interest in engineering applications, to display numbers in scientific notation without an infinite mantissa (which results from the method I employ at the end of this program to output the result). In the following code, I declare the value I use to display the result as a "double" rather than a "long double", because I could not get the "long double" type to display using the method I used with the "double" by simply setting it equal to a IND_OUT->Caption.

3. I declare some variables that I would have, in the past, declared to be integers, as doubles, out of fear that if I multiply a double or long double by an integer C might produce an integer result and set it equal to a variable I've declared as a double. (In the past I would have thought I was nuts for doing this, but I knew more then about C than I know now.)

4. Any basic flaws in what I'm doing in terms of how to make the code neater, faster to type? (I seem to spend a lot of space declaring and initializing variables.)

5. Do I need to free up the memory space associated with variables using a specific code line for any of these variables? How?

6. How do read data from text boxes? I'm probably going to need to read some numbers from text boxes if I ever turn this into a user interactive program, rather than something in which I program the values I intend to use directly into the code associated with a push-button. The numbers need to be able to accomodate scientific notation, because I'm dealing with values given by some number x 10^-12.

7. Any other useful, programming hints.

I know this is quite a laundry list, but I haven't done the C laundry in a dozen years, and the cobwebs are thick in that corner of my mental laundry room.

Thank you! (Code Follows)

Code:
//---------------------------------------------------------------------
#include <vcl.h>
#include <math.h>
#pragma hdrstop

#include "SDIMain.h"
#include "About.h"
//---------------------------------------------------------------------
#pragma resource "*.dfm"
TSDIAppForm *SDIAppForm;
//---------------------------------------------------------------------
__fastcall TSDIAppForm::TSDIAppForm(TComponent *AOwner)
	: TForm(AOwner)
{
}
//---------------------------------------------------------------------

void __fastcall TSDIAppForm::FileNew1Execute(TObject *Sender)
{
  // Do nothing        
}
//---------------------------------------------------------------------------

void __fastcall TSDIAppForm::FileOpen1Execute(TObject *Sender)
{
  OpenDialog->Execute();        
}
//---------------------------------------------------------------------------

void __fastcall TSDIAppForm::FileSave1Execute(TObject *Sender)
{
  SaveDialog->Execute();        
}
//---------------------------------------------------------------------------


void __fastcall TSDIAppForm::FileExit1Execute(TObject *Sender)
{
  Close();        
}
//---------------------------------------------------------------------------

void __fastcall TSDIAppForm::HelpAbout1Execute(TObject *Sender)
{
  AboutBox->ShowModal();        
}
//---------------------------------------------------------------------------









void __fastcall TSDIAppForm::Button1Click(TObject *Sender)
{
long double HA=0;
long double BETAMAX = 720;
long double THETAMAX = 720;
long double TMAX = 1000;
long double NDIV = 1000;
long double r = 150E-6;
long double R = 170E-6;
long double cBETA = 2*3.1415/BETAMAX;
long double cTHETA = 2*3.1415/THETAMAX;
long double Rav = (R + r)/2;
long double Rdif = (-R-r)/2;
long double RDivVal = 0;
long double RecA =0;
long double NumRator = 0;
long double NumRatorA = 0;
long double NumRatorB = 0;
long double Px = 0;
long double Py = 0;
long double Pz = 0;
long double P = 0;
long double cD=0;
long double cb=0;
long double cTc=0;
long double cth=0;
long double x = 0;
long double y = 0;
long double z = 1E-43;
long double RDiv_T1=0;
long double RDiv_T2=0;
double L = 0;
long double test;

for (cD = 1; cD <= NDIV; cD++) {
RDiv_T1= cos(asin(cD/NDIV));
RDiv_T2 =  2/(NDIV*3.1415);
RDivVal = RDiv_T1*RDiv_T2;

for (cb=0; cb < 1; cb++) {

for (cTc = 1; cTc <= TMAX; cTc++) {

for (cth = 0; cth <= THETAMAX; cth++) {

RecA = r / TMAX * 2*3.1415 / THETAMAX * r * cTc / TMAX;

NumRatorA = -1*cos(cBETA*cb)*(( Rdif*sin(cBETA*cb)+y+r/TMAX*cTc*sin(cTHETA*cth)));

NumRatorB =  -1*sin(cBETA*cb)*(( Rdif*cos(cBETA*cb)+z+r/TMAX*cTc*cos(cTHETA*cth)));

NumRator = sqrt(powl(NumRatorA,2) + pow(NumRatorB,2));

Px=(Rdif)*cos(cBETA*cb)+x+r/TMAX*cTc*cos(cTHETA*cth);
Py=(Rdif)*sin(cBETA*cb)+y+r/TMAX*cTc*sin(cTHETA*cth);
Pz = z;
P = (sqrtl(Px*Px + Py*Py +Pz*Pz));


HA = HA + RDivVal*(((NumRator/(P*P)*RecA)));

test=0;
}

}

}
test=0;
}
HA=2*NDIV*HA;
L = 1.257E-6/(4.*3.1415)*HA*BETAMAX;

// I named the lable box I am using to output the result "IND_OUT", 
//so I could identify it more easily when writing code.

IND_OUT->Caption=L;

}
//---------------------------------------------------------------------------