On comparison of string, who have a better way???
strcmp(str1,str2)
str1 > str2 return >0
str1==str2 return 0
str1 < str2 return <0
当s1<s2时,返回值<0
当s1=s2时,返回值=0
当s1>s2时,返回值>0
能不能直接比较?
How to directly compare?
str3="abc"
if(str3=="abc") { ...}
Code: Select all
import "ecere"
class Form1 : Window
{
text = "登陆";
background = activeBorder;
borderStyle = sizable;
hasMaximize = true;
hasMinimize = true;
hasClose = true;
size = { 256, 240 };
anchor = { horz = -163, vert = -111 };
Label label1 { this, text = "用户名:", position = { 64, 72 } };
Label label2 { this, text = "密码:", position = { 64, 112 } };
EditBox editBox1 { this, text = "editBox1", position = { 120, 72 }, contents = "abc" };
EditBox editBox2 { this, text = "editBox2", position = { 120, 112 }, contents = "123" };
Button button1
{
this, text = "登陆", position = { 88, 160 };
bool NotifyClicked(Button button, int x, int y, Modifiers mods)
{
if (strcmp(editBox1.contents,"")==0)
{
MessageBox{text="错误", contents="请输入用户名", type=ok}.Modal();
}
else
{
if(strcmp(editBox1.contents,"abc")==0 && strcmp(editBox2.contents,"123")==0)
{
MessageBox{text="信息", contents="你是合法用户,欢迎进入", type=okCancel}.Modal();
}
else
{
MessageBox{text="错误", contents="用户名和密码错误", type=ok}.Modal();
}
}
return true;
}
};
Button button2
{
this, text = "取消", position = { 160, 160 };
bool NotifyClicked(Button button, int x, int y, Modifiers mods)
{
Destroy(0);
return true;
}
};
bool OnCreate(void)
{
editBox1.contents="";
editBox2.contents="";
return true;
}
}
Form1 form1 {};