home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 1
/
FishNMoreVol1.bin
/
more
/
code_examples
/
librar
/
reed.c
< prev
next >
Wrap
Text File
|
1989-02-08
|
4KB
|
158 lines
/*--------------------------------------*/
/* */
/* REED(X,X,X,X,X,X,X) */
/* */
/* Fills a character array with keyboard*/
/* input. The first two arguments are */
/* the coordinates of the cursor posi- */
/* tion. If the coordinates are both */
/* negative then the cursor positioning */
/* is ignored. The third argument is */
/* the array being passed. The fourth is*/
/* the maximum length of the array. The */
/* fifth is initial filler. The sixth */
/* is the back-arrow filler. The */
/* seventh is a flag for special */
/* editing: */
/* */
/* 0: normal input */
/* 1: numeric input */
/* 2: upper case input */
/* 3: date input */
/* 4: floating point input */
/* 5: security input */
/* */
/*--------------------------------------*/
# include "stdlib.h"
reed(x,y,w,a,b1,b2,c)
int x,y,a,b2,c;
char w[],b1;
{
int j,d,r,m,M[12],pntflag,xloc,yloc;
char X[6];
if (c==3){
M[0]=31;
M[1]=28;
M[2]=31;
M[3]=30;
M[4]=31;
M[5]=30;
M[6]=31;
M[7]=31;
M[8]=30;
M[9]=31;
M[10]=30;
M[11]=31;
}
if (c==4)
pntflag=0;
REED1: charinit(w,a,b1);
if (x>=0 && y>=0)
scr_curs(x,y);
if (c==3){
printf("%c%c/%c%c/%c%c",b2,b2,b2,b2,b2,b2);
bspace(8);
}
for (j=0;j<a+1;j++){
REED2: if (c==2 || c==5)
d=key(0,0);
else
d=key(-1,0);
if (d==3 && c==5)
system("reboot");
if (d==13){
if (c==3 && j!=a && j){
cprintf("\a");
goto REED2;
}
j=a+1;
goto REED4;
}
if (j==a && d!=8 && d!=127)
goto REED2;
if ((d==8 || d==127) && j){
if (c==3){
if (j==2 || j==4)
bspace(1);
}
barrow(b2);
j--;
if (c==4 && w[j]==46)
pntflag=0;
w[j]=b1;
goto REED2;
}
if (c==1 || c==3){
if (d<48 || d>57)
goto REED2;
}
if (c==4){
if (d==46){
if (pntflag==1)
goto REED2;
else{
pntflag=1;
goto REED3;
}
}
if (d==45){
if (j)
goto REED2;
else
goto REED3;
}
if (d<48 || d>57)
goto REED2;
}
if (d<32 || d>127)
goto REED2;
REED3: if (c!=5){
scr_loc(&xloc,&yloc);
out(d,1);
scr_curs(xloc,yloc+1);
}
w[j]=d;
if (c==3){
if (j==1 || j==3)
fspace(1);
}
REED4: ;
}
if (c==3){
if (w[0]==b1)
goto REED5;
r=(w[4]-48)*10+w[5]-48;
m=(w[0]-48)*10+w[1]-48;
d=(w[2]-48)*10+w[3]-48;
if (m<1 || m>12){
cprintf("\a");
bspace(8);
goto REED1;
}
if (!efactor(r,4) && m==2 && d>29){
cprintf("\a");
bspace(8);
goto REED1;
}
if (!efactor(r,4) && m==2)
goto REED5;
if (d<1 || d>M[m-1]){
cprintf("\a");
bspace(8);
goto REED1;
}
REED5: for (j=0;j<2;j++)
X[j]=w[j+4];
for (j=2;j<6;j++)
X[j]=w[j-2];
for (j=0;j<6;j++)
w[j]=X[j];
}
return(0);
}