- 注册时间
- 2006-6-1
- 最后登录
- 1970-1-1
|
发表于 2006-12-12 22:53:18
|
显示全部楼层
比如说在写:
if(a=>b)
这样的语句时(当然是写错了),YAN大哥的编译器能把它通过,并且是if(a>=b)的效果。
下面的JAY大哥的示例程序在本人的TC1KS上编译时通过,但运行时自动关机了。
#define FONT_SMA 0
#define FONT_LAR 1
#define EDIT_INS 0
#define EDIT_OVR 1
#define KEY_LEFT 23
#define KEY_RIGHT 22
#define KEY_UP 20
#define KEY_DOWN 21
#define KEY_ENTER 13
#define KEY_SHIFT 18
#define KEY_CAPS 26
#define KEY_ESC 27
#define KEY_HELP 25
#define KEY_SPC 32
#define KEY_F1 28
#define KEY_F2 29
#define KEY_F3 30
#define KEY_F4 31
//文字缓存
char textBuf[100];
//保存地址,长度,显示坐标,字体
char Input(long textAdd,char length,char textX,char textY,char font){
char strPt;//字串指针、长度
char curX,curY,curL;//光标坐标、长度
int word;//获得的单个字符的ASCII或GB码
char editMode;
strPt=0;
word=0;
editMode=EDIT_INS;
if(font==FONT_SMA){//判断字体
curL=6;
curY=textY+11;
}
else{
curL=8;
curY=textY+15;
}
while(1){
Refresh();
TextOut(textX,textY,textAdd,0x40+0x80*font);//显示当前字串
curX=textX+strPt*curL;
if(editMode==EDIT_INS){//绘制光标
if(*(textAdd+strPt)>=0xa1){Line(curX,curY,curX+curL*2-1,curY,2);}
else{Line(curX,curY,curX+curL-1,curY,2);}
}else{
if(*(textAdd+strPt)>=0xa1){Box(curX,curY-curL*2,curX+curL*2-1,curY,1,2);}else
{Box(curX,curY-curL*2,curX+curL-1,curY,1,2);}
}
word=GetWord(3);
if(word==KEY_ENTER||word==KEY_ESC){break;}
if(word==KEY_F1){//切换插入、覆盖
if(editMode==EDIT_INS){editMode=EDIT_OVR;}
else{editMode=EDIT_INS;}
continue;
}
if(word==KEY_LEFT){//左移光标
if(strPt>0){
if(*(textAdd+strPt-1)>=0xa1){strPt=strPt-2;}
else{strPt--;}
}
continue;
}
if(word==KEY_RIGHT){//右移光标
if(strPt<strlen(textAdd)){
if(*(textAdd+strPt)>=0xa1){strPt=strPt+2;}
else{strPt++;}
}
continue;
}
if(word==KEY_F2){//删除字符
if(*(textAdd+strPt)==NULL){
if(strPt>0){
if(*(textAdd+strPt-1)>=0xa1){strPt=strPt-2;}
else{strPt--;}
}
}
if(*(textAdd+strPt)>=0xa1){strcpy(textBuf,textAdd+strPt+2);}
else if(*(textAdd+strPt)!=0){strcpy(textBuf,textAdd+strPt+1);}
strcpy(textAdd+strPt,textBuf);
continue;
}
//加入字符
if(!isgraph(word&0xff) && (word>>8==0)){continue;}//合法字符
if(editMode==EDIT_INS||*(textAdd+strPt)==NULL){//插入模式,或是光标在最后为新加的字符腾出空间
if(word>>8!=0&&strlen(textAdd)>=length-1){continue;}//判断长度是否超过规定长度
if(word>>8==0&&strlen(textAdd)>=length){continue;}
strcpy(textBuf,textAdd+strPt);
if(word>>8!=0){strcpy(textAdd+strPt+2,textBuf);}
else{strcpy(textAdd+strPt+1,textBuf);}
}
if(word>>8!=0){//汉字
if(*(textAdd+strPt)<0xA1&&editMode==EDIT_OVR){//覆盖英文或数字
if(strlen(textAdd)>=length)continue;
strcpy(textBuf,textAdd+strPt);
strcpy(textAdd+strPt+1,textBuf);
}
*(textAdd+strPt)=word&0xff;
*(textAdd+strPt+1)=word>>8;
strPt=strPt+2;
}else{//英文或数字
if(strlen(textAdd)>=length&&*(textAdd+strPt)==NULL)continue;
if(*(textAdd+strPt)>=0xA1&&editMode==EDIT_OVR){//覆盖汉字
strcpy(textBuf,textAdd+strPt+1);
strcpy(textAdd+strPt,textBuf);
}
*(textAdd+strPt)=word&0xff;
strPt++;
}
}
if(word==KEY_ESC)return 0;
return!0;
}
void main(){
char text[20];
memset(text,0,20);
Input(text,18,10,10,1);
}
希望gameghost能继续更新这个编译器,把它做得更好,本人很支持你啊!! |
|