Esempio n. 1
0
void CCaliData::GetReserveTime(int row, CString& strVal)
{
	const int itemNum = m_CaliItems.size();
	if (row<0 || row>itemNum-1) return;
	while (row!=-1)
	{
		if (m_CaliItems[row].szReserveTime!=_T(""))
		{
			strVal = m_CaliItems[row].szReserveTime;
			if (!IsDigital(strVal))
				Write_Error("保留时间非数字字符串");
			break;
		}
		else
			row--;
	}
}
Esempio n. 2
0
/*************************************************
Function: SearchWord
Description: 搜索输入单词在链表中的位置
Calls: InitReadinS(), InitSearchS(),PushReadinS(),PushSearchS(),FindLocat(),DisplayToChoose(),
Called By:    SearchMoulde()
Table Accessed: // 被访问的表(此项仅对于牵扯到数据库操作的程序)
Table Updated: // 被修改的表(此项仅对于牵扯到数据库操作的程序)
Input:存有26个字母表头信息的数组
Output: // 对输出参数的说明。
Return: 查找的结果的地址
Others: 5.29	对输入大写字母的情况做了修改
*************************************************/
WorData *SearchWord(WorData *alphabet[])            
{
	char input='\0';
	
	WorData *head=NULL,*current=NULL,*result=NULL;  //lack *
	WorData *Findout[10];
	ReadinStack *readins=NULL;
	SearchStack *searchs=NULL;
	
	readins=InitReadinS();       //初始化
	searchs=InitSearchS();      
	while(1)
	{
		while (1)
		{
			system("cls");
			printf("\n\n\n\n\n\n\n\n\n\n");     //打印出十个空行准备显示十个单词以供选择
			printf("Input:");
			
			input = getch();   //getche() -> getch(),第一个字母可能是大写不能转换成小写
			if (IsAlphabet(input) == YES)    //5.28 add   如果
			{
				putchar(input);
			}
			
			if (input == '`')
			{
				return NULL;
			}
			else if (IsAlphabet(input) == NO)  
			{
				break;     //IsAlphabet()判断是否为字母,是返回1
			}
			else
			{
				head = alphabet[ToLower(input) - 'a'];         //tolower() 将input字符转换成小写字母,-'a'得到input字符在alphabet数组中的位置   5.28
				current = head;
			}
			
			while (1)                
			{
				if (IsAlphabet(input) == YES) //如果input是字母
				{
					PushReadinS(readins,input);
					PushSearchS(searchs,current);
					current=FindLocat(readins,current);
					FindToChoose(current,Findout);
					DisplayToChoose(Findout,readins->readin);
					if (current != NULL)  //如果没找到
					{
						input=ToLower(getch());
						if (IsAlphabet(input) == YES)    //5.28 add   
						{
							putchar(input);
						}
						continue;
					}
				}
				else if (IsDigital(input) == YES) //是否为数字,是返回1
				{
					result=Findout[input-'0'];
					return result;
				}
				else if (input == '=') //输入 = ,表退格键
				{
					PopReadinS(readins);
					if (EmptyReadinS(readins) == YES) break;      //5.28 add,如果不修改,输入a = b,将出错
					current=PopSearchS(searchs);        //返回上次所指位置
					current=FindLocat(readins,current);
					FindToChoose(current,Findout);
					DisplayToChoose(Findout,readins->readin);
					//BACKSPACE;     //将之前输入的一个字符擦掉
				}
				else if (input == '@') //输入 -  ,清空整行
				{
					CleanReadinS(readins);
					CleanSearchS(searchs);
					break;       //重新输入
				}
				else if (input == '`')   //Esc键下面的那个键
				{
					return NULL;
				}
				//else BACKSPACE;     //其他情况,将该输入从屏幕上删除,已经有以下语句,该句可以去掉
				
				input = ToLower(getch());
				if (IsAlphabet(input) == YES)    //5.28 add   如果
				{
					putchar(input);
				}
			}//end of while (1)
		}//end of the frist while(1)
	}
}
Esempio n. 3
0
bool CCaliData::SynEditedCell(int col, int row, LPCTSTR szVal)
{
	if (szVal == _T("")) { 
		//::AfxMessageBox(_T("组份名不允许为空"));
		return false;
	}

	if (col == 5){
		CString cStr_tmp;
		cStr_tmp.Format(_T("%s"), szVal);
		if (!IsDigital(cStr_tmp))
			return false;
	}

	const int itemNum = m_CaliItems.size();
	if (row<0 || row>itemNum-1)
	{
		return false;
	}

	if (col==3)
	{
		if (m_CaliItems[row].szComponentName != _T("")) {
			m_CaliItems[row].szComponentName = szVal;
		}
		else{
			//::AfxMessageBox(_T("不允许在此单元格修改数据"));
			return false;
		}
	}
	else if (col==5)
	{
		CString szTmp;
		szTmp.Format(_T("%s"), szVal);
		//double dContents = _tstof(szTmp);
		//
		//if (dContents < 0.1f)
		//{
		//	szTmp.Format(_T("%e"), dContents);
		//}
		//else
		//{
		//	ConvertDecimalDigits(szTmp, 3); // 强制保留小数位后3位
		//}
		m_CaliItems[row].szContents = szTmp;

	    // 重新计算[响应因子]
		double dCont       = _tstof(m_CaliItems[row].szContents);
		double dPeakArea   = _tstof(m_CaliItems[row].szPeakArea);
		double dPeakHeight = _tstof(m_CaliItems[row].szPeakHeight);
		CString szFactor;
		if (m_tableType == _T("峰面积"))
		{
			double dResFactor = dCont / dPeakArea;
			m_CaliItems[row].szResFactor.Format(_T("%.4e"), dResFactor);

			//if (dResFactor == 0.0000f)
			//{
			//	m_CaliItems[row].szResFactor = _T("0.0000");
			//}
			//else
			//{
			//	szFactor.Format(_T("%.4e"), dResFactor);
			//	if (dResFactor >= 1.000000f)
			//		EraseZeroPlus(szFactor);
			//	else
			//		EraseZeroMinus(szFactor);
			//	m_CaliItems[row].szResFactor		= szFactor;	// 响应因子
			//}

		}
		else if (m_tableType == _T("峰高"))
		{
			double dResFactor = dCont / dPeakHeight;
			m_CaliItems[row].szResFactor.Format(_T("%.4e"), dResFactor);

			//if (dResFactor == 0.0000f)
			//{
			//	m_CaliItems[row].szResFactor = _T("0.0000");
			//}
			//else
			//{
			//	szFactor.Format(_T("%.4e"), dResFactor);
			//	if (dResFactor >= 1.000000f)
			//		EraseZeroPlus(szFactor);
			//	else
			//		EraseZeroMinus(szFactor);
			//	m_CaliItems[row].szResFactor		= szFactor;	// 响应因子
			//}
		}
		else
		{
			//::AfxMessageBox(_T("究竟是峰面积还是峰高?2"));
			return false;
		}
	}
	else
	{
		//::AfxMessageBox(_T("行数出错!")); // 理论上不会运行到这里
		return false;
	}

	return true;
}
Esempio n. 4
0
BOOL Editor_OnKeyPress(EDITOR *editor, DWORD KeyCode)
{
	int len;
	WCHAR input, wcspoint[4] = { '.', 0 };

	//TRACE("Editor_OnKeyPress, Key: '%c', 0x%02x\n", (char)KeyCode, KeyCode);

	if (editor->vcobject.ime_letter_enable)
	{
	#ifdef KEY_IME
		if (KEY_IME == KeyCode)
		{
			editor_reset_ime_roll(editor);

			if (editor->vcobject.ime_letter_enable && editor->vcobject.ime_digital_enable)
			{
				if (++editor->ime_mode > ITP_LETTER_LOW)
					editor->ime_mode = ITP_DIGITAL;
			}
			else if (editor->vcobject.ime_letter_enable)
			{
				editor->ime_mode = (ITP_LETTER_UP == editor->ime_mode) ? ITP_LETTER_LOW : ITP_LETTER_UP;
			}
			goto process_key;
		}
	#endif
	}

	if (editor->keyfilter && editor->keyfilter(KeyCode))		// 按键被过滤忽略
		return FALSE;

	if (!editor->input_buffer)
		return FALSE;

	len = wstrlen(editor->input_buffer);
	if (len && (KEY_CANCEL == KeyCode))
	{
		editor->input_buffer[0] = 0;
		editor_reset_ime_roll(editor);
	}
	else if (len && (KEY_BACKSPACE == KeyCode))
	{
		editor->input_buffer[--len] = 0;
		editor_reset_ime_roll(editor);
	}
	else if ((len < editor->maxinputchar)
					&& (IsDigital(KeyCode) || ('.' == KeyCode)))
	{
		input = (WCHAR)KeyCode;

		if ('.' == KeyCode)
		{
			editor_reset_ime_roll(editor);

			if (wstrstr(editor->input_buffer, wcspoint))
				return FALSE;
		}
		else
		{
			WCHAR current_letter = len ? editor->input_buffer[len - 1] : 0;
			input = editor_key_to_letter(editor, current_letter, KeyCode);
		}

		if (input)
		{
			if (len && (editor->ime_prev_key == (BYTE)KeyCode) && (ITP_DIGITAL != editor->ime_mode))
				len--;

			editor->input_buffer[len++] = input;
			editor->input_buffer[len++] = (WCHAR)0;

			editor->ime_input_timeout = 0;
			editor->ime_prev_key = (BYTE)KeyCode;
		}
	}
	else
		return FALSE;					// 返回FALSE表示按键未处理

#ifdef KEY_IME
process_key:
#endif
	editor->cursortogglecnt = 0;		// 重置光标闪烁状态
	Editor_OnDraw(editor);

	return TRUE;						// 返回TRUE表示按键已处理
}