newntui/commonresources/src/filterwizard.cpp
//----------------------------------------------------------------------------------------
// This function asks all controls to form the token, exept From and To members.
// Returns TRUE and fills"token" members if the token was made successfully or
// FALSE if error was detected in the user input. Sets m_ErrorType member to
// indicate the error type.
//----------------------------------------------------------------------------------------
This function asks all controls to form the token, exept From and To members.
Returns TRUE and fills"token" members if the token was made successfully or
FALSE if error was detected in the user input. Sets m_ErrorType member to
indicate the error type.
This function asks all controls to form the token exept From and To members . Returns TRUE and fills " token " members if the token was made successfully or FALSE if error was detected in the user input . Sets m_ErrorType member to indicate the error type .
BOOL CFilterWizard::MakeToken(CToken& token) {
register i;
int     selectedAttribute;
int     attributeReference;
int     selectedCommand;
int     commandReference;
CString argument;
BOOL    isDigit;
    selectedAttribute=m_AttributeCombo.GetCurSel();
	if(selectedAttribute==-1) {
		m_ErrorType = ERROR_NO_ATTRIBUTE;
		return FALSE;
	}
	attributeReference = m_AttributeCombo.GetItemData(selectedAttribute);
    selectedCommand=m_OperationCombo.GetCurSel();
	if(selectedCommand==-1) {
		m_ErrorType = ERROR_NO_OPERATION;
		return FALSE;
	}
	commandReference = m_OperationCombo.GetItemData(selectedCommand);
    m_ArgumentEdit.GetWindowText(argument); 
	if(argument.GetLength()==0) {
		m_ErrorType = ERROR_EMPTY_ARGUMENT;
		return FALSE;
	}
	switch(m_AttributesTable[attributeReference].Type) {
	   case INT_TYPE : for(i=0;i<argument.GetLength();i++) {
		                  switch(argument[i]) {
						     case '0' :
						     case '1' :
						     case '2' :
						     case '3' :
						     case '4' :
						     case '5' :
						     case '6' :
						     case '7' :
						     case '8' :
						     case '9' : isDigit=TRUE; break;
							 default  : isDigit=FALSE; break;
						  }
						  if(isDigit==FALSE) {
		                     m_ErrorType = ERROR_WRONG_ARGUMENT;
		                     return FALSE;
						  }
					   }
					   if(argument.GetLength()>10) {
		                  m_ErrorType = ERROR_BIG_ARGUMENT;
		                  return FALSE;
					   }
					   break;
	   case STR_TYPE :    break;
	   default :	      m_ErrorType = ERROR_UNSUPPORTED_TYPE;
	}
    token.Attribute      = m_AttributesTable[attributeReference].Option; 
    token.AttributeIndex = selectedAttribute;
	if(m_AndButton.GetCheck()==1) token.Concatination=OP_AND;
	else                          token.Concatination=OP_OR;
    token.UseLength = FALSE;
    token.Operation      = m_OperationsTable[commandReference].FormatString;
    token.OperationIndex = selectedCommand;
	if(token.Operation.Find("strn")!=-1) token.UseLength = TRUE;
	token.Argument  = argument;
	return TRUE;
}
BOOL CFilterWizard :: MakeToken ( CToken & token ) { register i ; int selectedAttribute ; int attributeReference ; int selectedCommand ; int commandReference ; CString argument ; BOOL isDigit ; selectedAttribute = m_AttributeCombo . GetCurSel ( ) ; if ( selectedAttribute == -1 ) { m_ErrorType = ERROR_NO_ATTRIBUTE ; return FALSE ; } attributeReference = m_AttributeCombo . GetItemData ( selectedAttribute ) ; selectedCommand = m_OperationCombo . GetCurSel ( ) ; if ( selectedCommand == -1 ) { m_ErrorType = ERROR_NO_OPERATION ; return FALSE ; } commandReference = m_OperationCombo . GetItemData ( selectedCommand ) ; m_ArgumentEdit . GetWindowText ( argument ) ; if ( argument . GetLength ( ) == 0 ) { m_ErrorType = ERROR_EMPTY_ARGUMENT ; return FALSE ; } switch ( m_AttributesTable [ attributeReference ] . Type ) { case INT_TYPE : for ( i = 0 ; i < argument . GetLength ( ) ; i ++ ) { switch ( argument [ i ] ) { case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : isDigit = TRUE ; break ; default : isDigit = FALSE ; break ; } if ( isDigit == FALSE ) { m_ErrorType = ERROR_WRONG_ARGUMENT ; return FALSE ; } } if ( argument . GetLength ( ) > 10 ) { m_ErrorType = ERROR_BIG_ARGUMENT ; return FALSE ; } break ; case STR_TYPE : break ; default : m_ErrorType = ERROR_UNSUPPORTED_TYPE ; } token . Attribute = m_AttributesTable [ attributeReference ] . Option ; token . AttributeIndex = selectedAttribute ; if ( m_AndButton . GetCheck ( ) == 1 ) token . Concatination = OP_AND ; else token . Concatination = OP_OR ; token . UseLength = FALSE ; token . Operation = m_OperationsTable [ commandReference ] . FormatString ; token . OperationIndex = selectedCommand ; if ( token . Operation . Find ( " " ) != -1 ) token . UseLength = TRUE ; token . Argument = argument ; return TRUE ; }
This function asks all controls to form the token, exept From and To members.
This function asks all controls to form the token exept From and To members .
// We are going to get the reference to the attributes array from the attributes // combobox. // If nothing is selected // Now we will be able to get this attribute index in the attribute array. // We are going to get the reference to the operations array from the operations // combobox. // If nothing is selected // Now we will be able to get this operation index in the operation  array. // User argument we will take from the arguments editor. // We need to check user argument. (We can't use characters different from "0".."9") // for the integer arguments, we can't use empty strings) // Testing the argiment... // If integer ... // If string ... // In future ... // Wrong type ... // Forming the token  // Access command // concatination operation // Operation format string