while ((IsLetterOrNumber(Gl_ch))=0) or
((IsLetterOrNumber(Gl_ch))=1) do
begin
Inputword:=Inputword+Gl_ch;
showmessage(Gl_ch+' + '+inputword);
str_Input:=GetStringTail(str_Input);
Gl_ch:=ReadChar(str_Input);
end;---------------------------------------
说明:
function IsLetterOrNumber(ch:Char):integer;
begin
if ((ch>='a') and (ch<='z')) or ((ch>='A') and (ch<='Z')) then Result:=0 //字母
else if (ch>='0') and (ch<='9') then Result:=1//数字
else if (ch=' ') then Result:=3//空格
else Result:=2; //其他
end;
function GetStringTail(Str:String):string;
var
str_temp:string;
int_Strlength:integer;
begin
int_strlength:=length(Trim(str));
str_temp:=copy(str,2,int_strlength);
result:=str_temp;
end;function ReadChar(str:String):char;
begin
if Length(str)>0 then Result:=str[1]
end;
((IsLetterOrNumber(Gl_ch))=1) do
begin
Inputword:=Inputword+Gl_ch;
showmessage(Gl_ch+' + '+inputword);
str_Input:=GetStringTail(str_Input);
Gl_ch:=ReadChar(str_Input);
end;---------------------------------------
说明:
function IsLetterOrNumber(ch:Char):integer;
begin
if ((ch>='a') and (ch<='z')) or ((ch>='A') and (ch<='Z')) then Result:=0 //字母
else if (ch>='0') and (ch<='9') then Result:=1//数字
else if (ch=' ') then Result:=3//空格
else Result:=2; //其他
end;
function GetStringTail(Str:String):string;
var
str_temp:string;
int_Strlength:integer;
begin
int_strlength:=length(Trim(str));
str_temp:=copy(str,2,int_strlength);
result:=str_temp;
end;function ReadChar(str:String):char;
begin
if Length(str)>0 then Result:=str[1]
end;
解决方案 »
- 打印问题
- 急:怎样只显视查询到的记录
- dbgrid中复制当前项的上一行记录
- quickrep和query结合的报表不能显示出记录(入门级)
- 我需要触发DBGrid的单元格得到、失去焦点的事件,怎么做?
- 请问那位大哥有邮件发送带验证的代码,给小弟一份,谢谢!
- 有什么好的图形分析控件
- 求delphi7中的treeview控件的遍历算法。
- 请问Win98中用Delphi如何与UNIX的Informix的数据库连起来?(十万火急)
- 抢分题目,我的数据库的字段名太多了,请问TDBCtrlGrid能否让它的每个panel有滚动条?
- 关于对程序的使用进行时间限制的问题
- 初学自定义预览窗口--有关《深入QuickRep》一文
执行Gl_ch:=ReadChar(str_Input)后, Gl_ch总是为"H"。这样,在进行while判断时,自然总是不能跳出。那么为什么Gl_ch到最后总是为H呢?
不明白啊!
要怎么解决呢?
Gl_ch:=ReadChar(str_Input)
showmessage(Gl_ch);
到最后显示的总是H
Gl_ch:=ReadChar(str_Input);
你的STR——INPUT不变,当然GL——CH也不变了;
function GetStringTail(Str:String):string;
var
str_temp:string;
int_Strlength:integer;
begin
int_strlength:=length(Trim(str));
str_temp:=copy(str,2,int_strlength); //就在这里!减少了第一个字符!
result:=str_temp;
end;
修改为:
Result:='';
if Length(str)>0 then Result:=str[1];
现在才发现一个问题!
为什么现在在CSDN上我找不到提问的地方了?
---->str_temp := RightStr(str, int_strlength-1)
Result:=''不行吧,类型不匹配
begin
if Length(str)>0 then
Result:=str[1]
else
Result := #0
end;
把分给了westfly(西翔)吧,其实跟踪一下就会发现
length为0
Gl_ch值为str最后一个,没法改变
你的ReadChar调用也有问题
begin
j:=IsLetterOrNumber(str_Input[i])
if (j=0) or (j=1) then
BEGIN
Gl_ch:=ReadChar(str_Input); Inputword:=Inputword+Gl_ch;
END
ELSE
BREAK;
end;
效率高多了
while ((IsLetterOrNumber(Gl_ch))=0) or
((IsLetterOrNumber(Gl_ch))=1) do
begin
Inputword:=Inputword+Gl_ch;
showmessage(Gl_ch+' + '+inputword);
str_Input:=GetStringTail(str_Input);
Gl_ch:=ReadChar(str_Input);
end;
修改为:
Result:=Char(0);
if Length(str)>0 then Result:=str[1];