MACROMEDIA COLDFUSION 4.5-CFML LANGUAGE Manuel d'utilisateur Page 30

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 44
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 29
30 CHAPTER 30 Extending ColdFusion with CFX
Listing 30.5 (continued)
// Retrieve value of VARIABLE attribute
LPCSTR lpszVariable = pRequest->GetAttribute(“VARIABLE”) ;
// Make sure a VARIABLE attribute was actually passed to the tag
if ( pRequest->AttributeExists(“COLUMN”)==FALSE ) {
pRequest->ThrowException(
“Error in CFX_ComputeStandardDeviation Tag”,
“No COLUMN attribute specified.”);
}
// Retrieve value of VARIABLE attribute
LPCSTR lpszColumn = pRequest->GetAttribute(“COLUMN”) ;
// Retrieve the query specified in the tag’s QUERY attribute
CCFXQuery* pQuery = pRequest->GetQuery();
// Make sure a query was actually passed to the tag
if ( pQuery == NULL ) {
pRequest->ThrowException(
“Error in CFX_ComputeStandardDeviation Tag”,
“No QUERY provided.”);
}
// Find the index position of the column named in the COLUMN attribute
int colIndex = pQuery->GetColumns()->GetIndexForString( lpszColumn );
// If the column specified in COLUMN attribute does not exist in query
if ( colIndex == CFX_STRING_NOT_FOUND ) {
pRequest->ThrowException(
“Error in CFX_ComputeStandardDeviation Tag”,
“The COLUMN attribute does not match up to a column in the query.”);
}
/* FINISHED WITH ATTRIBUTE VALIDATION */
// Local variables
double dTotal = 0;
double dMean = 0;
double dStdDev = 0;
double dSumSq = 0;
double dVariance = 0;
int iValueCount = 0;
// Compute the total of all the numbers in the data set
for ( int Row = 1; Row <= pQuery->GetRowCount(); Row++) {
// Get the value (as a string) from the query
LPCSTR thisVal = pQuery->GetData(Row, colIndex);
// Assuming the value is not an empty string
if ( strlen(thisVal) > 0) {
Vue de la page 29
1 2 ... 25 26 27 28 29 30 31 32 33 34 35 ... 43 44

Commentaires sur ces manuels

Pas de commentaire