MACROMEDIA COLDFUSION 4.5-CFML LANGUAGE Manuale Utente Pagina 30

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 44
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 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) {
Vedere la pagina 29
1 2 ... 25 26 27 28 29 30 31 32 33 34 35 ... 43 44

Commenti su questo manuale

Nessun commento