/* * * * * * G B . L I B * * * * * */ /* */ /* Copyright (c) 1989 by */ /* */ /* Geoff Buckeridge. */ /* */ /* last changed 29 JUN 89 */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * **/ void pron() /* printer on :- fprint(LST,"%s","PRINT TEST"); */ { if (!(LST=(fopen("LST:","wb")))) { fputs("cannot open LST:\n",stderr); exit(1); } } void proff() /* just switches it off again */ { fclose(LST); } void timeset(HRS,MIN,SEC) /* set up new time */ { poke(64502,HRS); poke(64503,MIN); poke(64504,SEC); time(); } void time() /* loads global HRS MIN & SEC with time */ { HRS=peek(64502); MIN=peek(64503); SEC=peek(64504); } void date2() /* produces English version of date */ { int MSB,LSB; /* e.g. Wednesday 28th June 1989 */ date(); switch (MONTH) { case 1: strcpy(MON_NAME,"January"); break; case 2: strcpy(MON_NAME,"February"); break; case 3: strcpy(MON_NAME,"March"); break; case 4: strcpy(MON_NAME,"April"); break; case 5: strcpy(MON_NAME,"May"); break; case 6: strcpy(MON_NAME,"June"); break; case 7: strcpy(MON_NAME,"July"); break; case 8: strcpy(MON_NAME,"August"); break; case 9: strcpy(MON_NAME,"September"); break; case 10:strcpy(MON_NAME,"October"); break; case 11:strcpy(MON_NAME,"November"); break; case 12:strcpy(MON_NAME,"December"); break; } switch (DAY_NO) { case 0: strcpy(DAY_NAME,"Saturday"); break; case 1: strcpy(DAY_NAME,"Sunday"); break; case 2: strcpy(DAY_NAME,"Monday"); break; case 3: strcpy(DAY_NAME,"Tuesday"); break; case 4: strcpy(DAY_NAME,"Wednesday"); break; case 5: strcpy(DAY_NAME,"Thursday"); break; case 6: strcpy(DAY_NAME,"Friday"); break; } MSB=DAYS/10; LSB=DAYS%10; strcpy(TAG,"th"); if (LSB==1) strcpy(TAG,"st"); if (LSB==2) strcpy(TAG,"nd"); if (LSB==3) strcpy(TAG,"rd"); if (DAYS>10 && DAYS<14) strcpy(TAG,"th"); } void date() /* extracts the date in a useable form from memory */ { int DATEL, DATEH, LEAP; static int MONLEN[12]={31,28,31,30,31,30,31,31,30,31,30,31}; /* obvious */ DATEL=peek(64500); DATEH=peek(64501); DAYS=(DATEH*256)+DATEL; /* total number of days since 1st Jan 1978 */ DAY_NO=DAYS%7; /* which day of the week */ YEAR=((DAYS/1461)*4)+78; /* 1461 = No of days in 4 yrs */ DAYS=DAYS%1461; /* No of days left */ YEAR_LEN=365; /* leap year if equal to 366 */ LEAP=0; /* leap year if equal to 2 */ while (DAYS > YEAR_LEN) /* fine tune date */ { DAYS=DAYS-YEAR_LEN; ++YEAR; ++LEAP; if (LEAP==2) YEAR_LEN=366; /* leap year */ else YEAR_LEN=365; /* or not */ if (LEAP==4) LEAP=0; /* after 4 start again */ } MONTH=0; if (YEAR_LEN==366) MONLEN[1]=29; /* alter FEB for leap year */ while (DAYS > MONLEN[MONTH]) /* subtract a month at a time */ DAYS=DAYS-MONLEN[MONTH++]; /* from the remaining days */ ++MONTH; /* get it right */ strcpy (MON_NAME,"no-name"); /* these variables used in date2() */ strcpy (DAY_NAME,MON_NAME); strcpy (TAG,"**"); } void cls() /* clears screen and homes cursor */ { home(); printf("\33E"); } void home() /* puts cursor in top LH corner of the screen */ { printf("\33H"); } void clrln() /* clears from cursor to end of line */ { printf("\15\33K"); } void posn(x,y) /* posn(3,10); moves cursor to line 3, column 10 */ int x,y; { printf("\33Y%c%c",x+0x20,y+0x20); } int tab(t) /* tab(3); will move cursor to the 3rd tab position */ int t; { int i; for(i=0;i 20 it is not changed. */ { int i,l; if ((l=strlen(line)) > ln_len) return(FALSE); for(i=l;i ln_len) return(FALSE); d=ln_len-l; for(i=l-1;i>=0;i--) *(line+i+d)=*(line+i); for(i=0;i ln_len) return(FALSE); d=(ln_len-l)/2; e=(ln_len-l)%2; for(i=l-1;i>=0;i--) *(line+i+d)=*(line+i); for(i=0;i