#include /* module help9 */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include union REGS inregs,outregs; fpos_t pointer=0L; unsigned int cload(unsigned char *, unsigned int); /* prototype */ /*****************************************************************************/ help(void) /* help text */ { char *list1[]= { "ACTS - LOGGING ACTIVITY", "AUTO - AUTO-TEST STATUS", "BARS - BAR GRAPHS", "BASE - DATABASE NAMES", "DATA - DATABASE IN HEX", "FAIL - DETAILED FAILURES", "FALT - DETAILED FAULTS", "FLOW - FLOW DIAGRAM", "HELP - PROGRAM PROTOCOL", "HIST - FREEZE-FRAME SEQUENCE", "INTL - INTERLOCK DIAGRAM", "LOGS - READ A LOG", "MAIN - CONTROL PANEL", "MAPS - POSITION STORAGE GRID", "MATH - PROCESSED METERING", "MISC - USER-DEFINED FLAGS, ETC", "SCOP - OSCILLOSCOPE", "SIMU - SIMULATOR", "TABL - PRE-SET RF VALUES", "TITL - TITLE PAGE & REV LEVEL", "USER - USER-DEFINED SCREEN", "AMOF - AMPLITUDE MOD OFF", "AM - AMPLITUDE MOD ON", "PMOF - PHASE MOD OFF", "PM - PHASE MOD ON", "+-/* - CALCULATOR OPERATORS", 0 }; char *list2[]= { "COFF (F1) - COOLING STOP", "COOL - COOLING START", "FLOF (F3) - FILAMENT STOP", "FILS (F4) - FILAMENT START", "FLDN - FILAMENT LOWER", "FLUP - FILAMENT RAISE", "MOF (F5) - MAGNET STOP", "MAGS (F6) - MAGNET START", "MDN - MAGNET LOWER", "MUP - MAGNET RAISE", "HVOF (F9) - HV STOP", "HVON (F10) - HV START", "HVDN - LOWER HV", "HVUP - RAISE HV", "RCV (F11) - RECEIVE", "XMT (F12) - TRANSMIT", "ANT - ANTENNA", "WAST - WASTER", "COMB - COMBINER", "DL - KLY LOAD", "DROF (F7) - DRIVE OFF", "DRON (F8) - DRIVE ON", "DRDN - DRIVE LOWER", "DRUP - DRIVE RAISE", "DBDN - DRIVE BAL LOWER", "DBUP - DRIVE BAL RAISE", "GNDN - GAIN LOWER", "GNUP - GAIN RAISE", "OFDN - OFFSET LOWER", "OFUP - OFFSET RAISE", "PBDN - PHASE BAL LOWER", "PBUP - PHASE BAL RAISE", "RSET - RESET INDICATORS", "RTST - RESET TEST RESULTS", "STBY (F2) - STANDBY", 0 }; char *list3[]= { "alt-R - REVERSE VIDEO", "alt-P - PRINT SCREEN", "ctrl-H - TOGGLE HISTOGRAPH", "ctrl-R - REFRESH SCREEN", "BAL - COMBINER BALANCE", "BEAM - HV ADJUST", "CMND - DEFINE SPARE COMMANDS", "CODE - OVER-RIDE CIPHER", "COM - COM PORT TEST", "DATE - CHANGE CALENDAR", "DFLT - INSTALL DEFAULT VALUES", "DRIV - RF DRIVE ADJUST", "DUMP - TRANSMIT DATABASE", "EXIT - LOGOUT REMOTE TERMINAL", "FIND - SEARCH FOR STRING", "FUNC - FUNCTION KEYS", "HONK - TEST SONALERT", "ID - DEFINE SECURITY IDs", "LIMT - METER BOUNDARIES", "MUTE - SONALERT DISABLE", "PAL - COLOR PALETTE", "PASS - SET PASSWORD", "POWR - POWER OUTPUT ADJUST", "QUIT - QUIT PROGRAM", "REP - REPEAT LAST COMMAND", "SCAL - METER SCALING FACTORS", "SPAR - DEFINE SPARE DIGITAL IN", "STAT - DUMP ONE STATUS BYTE", "STLG - STORE A LOG", "STOR - STORE RF VALUES", "TEST - AUTO-TEST", "TIME - CHANGE REAL-TIME CLOCK", "TRND - TREND ANALYSIS", "LONG - LONG RANGE MODE", "SHRT - SHORT RANGE MODE", 0 }; char *list4[]= { /* (RS) */ "M1OF - MAGNET 1 OFF", /* (RS) */ "MAG1 - MAGNET 1 ON", /* (RS) */ "M1DN - MAGNET 1 LOWER", /* (RS) */ "M1UP - MAGNET 1 RAISE", /* (RS) */ "M2OF - MAGNET 2 OFF", /* (RS) */ "MAG2 - MAGNET 2 ON", /* (RS) */ "M2DN - MAGNET 2 LOWER", /* (RS) */ "M2UP - MAGNET 2 RAISE", /* (RS) */ "PACT - PRINT LOG ACTIVITY", /* (RS) */ 0 /* (RS) */ }; /* (RS) */ int i,k,x,y,m=0,mold=0,n=0,nold=0,len1,len2,len3,len4; clear(); /* clear entire screen */ font(3); texcolor(PALEBLUE); len1=list(0,479,13,list1); /* screen commands */ texcolor(YELLOW); len2=list(220,479,13,list2); /* control commands */ len4=list(0,141,13,list4); /* control commands (RS) */ texcolor(LIGHTGREEN); len3=list(440,479,13,list3); /* software commands */ clkey(); rect(BLACK,0,15,200,0); message(WHITE,"USE CURSOR KEYS OR CLICK LEFT TO SELECT"); onmouse(); while(!kbhit()) { odapc(); switch(click()) /* mouse button */ { case 1: /* left click */ x=outregs.x.cx; y=479-outregs.x.dx; if(x<220) m=0; if(x>=220&&x<440) m=1; if(x>=440) m=2; n=(479-y)/13; if((m==0)&&(n>=26)) /* (RS) */ { /* (RS) */ m=3; /* (RS) */ n=n-26; /* (RS) */ } /* (RS) */ goto exec; case 3: /* both click */ k=ESC; goto abort; } } k=caps(); if(k>128) cursor: switch(k) { case LEFT: --m; if((m==0)&&(n>26)) /* (RS) */ { /* (RS) */ m=3; /* (RS) */ n=n-26; /* (RS) */ } /* (RS) */ if(m==2) /* (RS) */ n=n+26; /* (RS) */ if(m==-1) m=2; /* wrap */ break; case RIGHT: ++m; if((m==3)&&(n<26)) /* (RS) */ m=0; /* (RS) */ if(m==3) /* (RS) */ n=n-26; /* (RS) */ if(m==4) /* (RS) */ { /* (RS) */ m=1; /* wrap */ n=n+26; /* (RS) */ } /* (RS) */ break; case UP: --n; if(n==-1&&m==0) { /* (RS) */ m=3; /* (RS) */ n=len4-1; /* wrap */ } /* (RS) */ if(n==-1&&m==1) n=len2-1; if(n==-1&&m==2) n=len3-1; if(n==-1&&m==3) /* (RS) */ { /* (RS) */ m=0; /* (RS) */ n=len1-1; /* (RS) */ } /* (RS) */ break; case DOWN: ++n; if(n==len1&&m==0) { /* (RS) */ n=0; /* wrap */ m=3; /* (RS) */ } /* (RS) */ if(n==len2&&m==1) n=0; if(n==len3&&m==2) n=0; if(n==len4&&m==3) /* (RS) */ { /* (RS) */ n=0; /* (RS) */ m=0; /* (RS) */ } /* (RS) */ break; case HOME: n=0; break; case END: if(!m) n=len1-1; if(m==1) n=len2-1; if(m==2) n=len3-1; if(m==3) /* (RS) */ n=len4-1; /* (RS) */ break; default: /* user defined */ keyboard[0]=k; goto abort; } else { keyboard[0]=k; prompt(keyboard); goto abort; } exec: if(m==0&&n>=len1-1) n=len1-1; if(m==1&&n>=len2-1) n=len2-1; if(m==2&&n>=len3-1) n=len3-1; if(m==3&&n>=len4-1) n=len4-1; if(mold==3) /* (RS) */ y=141-13*nold; /* (RS) */ else y=479-13*nold; /* (RS) */ offmouse(); switch(mold) { case 0: /* screen */ x=0; rect(BLACK,x,y,x+210,y-10); text(PALEBLUE,x,y,list1[nold]); break; case 1: /* control */ x=220; rect(BLACK,x,y,x+180,y-10); text(YELLOW,x,y,list2[nold]); break; case 2: /* software */ x=440; rect(BLACK,x,y,x+190,y-10); text(LIGHTGREEN,x,y,list3[nold]); break; case 3: /* control (RS) */ x=0; /* (RS) */ rect(BLACK,x,y,x+210,y-10); /* (RS) */ text(YELLOW,x,y,list4[nold]); /* (RS) */ break; /* (RS) */ } if(m==3) /* (RS) */ y=141-13*n; /* (RS) */ else y=479-13*n; /* (RS) */ switch(m) { case 0: /* screen */ x=0; rect(BLUE,x,y,x+210,y-10); text(WHITE,x,y,list1[n]); break; case 1: /* control */ x=220; rect(BLUE,x,y,x+180,y-10); text(WHITE,x,y,list2[n]); break; case 2: /* software */ x=440; rect(BLUE,x,y,x+190,y-10); text(WHITE,x,y,list3[n]); break; case 3: /* control (RS) */ x=0; /* (RS) */ rect(BLUE,x,y,x+210,y-10); /* (RS) */ text(WHITE,x,y,list4[n]); /* (RS) */ break; /* (RS) */ } nold=n; mold=m; MESSAGE(WHITE,"Enter OR DOUBLE-CLICK LEFT TO EXECUTE, '?' OR CLICK RIGHT TO EXPLAIN"); onmouse(); while(!kbhit()) { odapc(); switch(click()) /* mouse button */ { case 1: /* left click */ x=outregs.x.cx; y=479-outregs.x.dx; if(x<220) m=0; if(x>=220&&x<440) m=1; if(x>=440) m=2; n=(479-y)/13; if((m==0)&&(n>=26)) /* (RS) */ { /* (RS) */ m=3; /* (RS) */ n=n-26; /* (RS) */ } /* (RS) */ goto exec; case 2: /* right button */ k='?'; goto exec2; case 3: /* both click */ k=ESC; goto abort; case 4: /* double left click */ k=CR; goto exec2; } } k=caps(); if(k>128) goto cursor; if(k==ESC) goto abort; if(k==CR) goto exec2; /* (RS) */ if(k=='?') goto exec2; /* (RS) */ keyboard[0]=k; prompt(keyboard); goto abort; exec2: offmouse(); switch(m) { case 0: /* screen */ strncpy(keyboard,list1[n],5); break; case 1: /* control */ strncpy(keyboard,list2[n],5); break; case 2: /* software */ strncpy(keyboard,list3[n],5); break; case 3: /* control (RS) */ strncpy(keyboard,list4[n],5); /* (RS) */ break; /* (RS) */ } for(i=0;keyboard[i]!=SP;i++); /* find end of command */ keyboard[i]=k; keyboard[i+1]=CR; abort: oldscrn=0; /* forces refresh */ time(&keystart); } /*****************************************************************************/ helptext(void) /* detailed help text */ { char string[10]; int i,j,l,k,fail,maxi,index; unsigned int nread; long offset; if(!(stream=fopen("help.723","r"))) { warn("can't open HELP.723"); clkey(); goto abort; } if(counter[74]) strcpy(string,sysbuf); else strcpy(string,keyboard); for(i=0;string[i]!='?';i++); string[i]=0; /* remove ? mark */ if(string[0]!='M') /* (RS) */ { for(j=0;j0x2F)&&(string[j]<0x3A)) /* remove arguments */ string[j]=0; } for(i=0;cmdlist[i];i++); maxi=i-1; /* last command */ for(index=0;index<=maxi;index++) /* find index */ if(!(fail=strcmp(string,cmdlist[index]))) break; if(fail) { brief("CAN'T LOCATE THIS FUNCTION IN LIST"); clkey(); goto abort; } strcpy(keyboard,string); strcat(keyboard,"?"); loop: nread=cload(utemp,30000); /* get about 30000 help chars */ for(i=0;i<(int)nread;i++) { if(utemp[i]=='|') { brief("CAN'T LOCATE THIS FUNCTION IN HELP.723"); clkey(); goto abort; } for(j=0;keyboard[j]!='?';j++) { if(keyboard[j]!=utemp[i+j]) break; /* no match */ if((j==0)&&(utemp[i+j-1]!=LF)) break; /* similar command */ } if((keyboard[j]=='?')&&(utemp[i+j]==' ')) break; /* match */ } if(keyboard[j]=='?') { for(j=i;j<(int)nread;j++) /* find end of text */ if(utemp[j]==LF&&utemp[j+1]==LF) break; if(j==(int)nread) /* incomplete definition */ { offset=i-100L-nread; fseek(stream,offset,SEEK_CUR); /* back up to title */ goto loop; } font(5); /* 80 column, fixed spacing */ clear(); l=0; newline: for(j=i;utemp[j]!=LF;j++); /* find end of line */ utemp[j]=0; /* terminate string */ text(PALEBLUE,0,479-15*l,&utemp[i]); if(utemp[j+1]!=LF) { ++l; /* increment line counter */ i=j+1; /* next character index */ goto newline; } wait: while(!kbhit()) /* wait */ { odapc(); if(k=click()) switch(k) { case 1: /* click left */ k=PDN; goto parser; case 2: /* click right */ k=PUP; goto parser; case 3: /* click both */ k=ESC; goto parser; default: goto wait; } } k=caps(); parser: if(k==PDN) /* next definition */ { if(++index>maxi) index=0; strcpy(keyboard,cmdlist[index]); string[0]='?'; string[1]=CR; string[2]=0; strcat(keyboard,string); fseek(stream,0,SEEK_SET); /* rewind */ goto loop; } if(k==PUP) /* previous definition */ { if(--index<0) index=maxi; strcpy(keyboard,cmdlist[index]); string[0]='?'; string[1]=CR; string[2]=0; strcat(keyboard,string); fseek(stream,0,SEEK_SET); /* rewind */ goto loop; } clkey(); keyboard[0]=k; prompt(keyboard); } else { fseek(stream,-10,SEEK_CUR); /* avoid breaking in mid-command */ goto loop; } abort: fclose(stream); refresh=1; } /*****************************************************************************/ search(void) /* find case-insensitive string */ { char phrase[60],string[90],nocase; int i,j,ii,jj,color,line,k,fail; unsigned int nread; long offset,oldpt; if(!(stream=fopen("help.723","r"))) /* open help file on hard drive */ { warn("can't open HELP.723"); clkey(); goto abort; } if(keyboard[4]==CR) { clkey(); goto abort; } strcpy(phrase,&keyboard[4]); /* copy search string */ clkey(); loop: nread=cload(utemp,30000); /* get 30000 help characters */ oldpt=pointer; fail=fgetpos(stream,&pointer); j=0; cont: for(i=j;i<(int)nread;i++) { if(utemp[i]=='|') goto abort; /* last char in help file */ for(j=0;phrase[j]!=CR;j++) { nocase=utemp[i+j]; if((nocase>=0x61)&&(nocase<=0x7A)) nocase-=0x20; /* convert to upper case */ if(phrase[j]!=nocase) break; /* no match */ } if(phrase[j]==CR) break; /* match */ } odapc(); if(phrase[j]!=CR) goto loop; /* try again */ for(j=i;j<(int)nread;j++) /* find end of text */ if(utemp[j]==LF&&utemp[j+1]==LF) break; if(j==(int)nread) /* incomplete definition */ goto loop; for(j=i;j>0;j--) /* find start of text */ if(utemp[j]==LF&&utemp[j-1]==LF) break; if(j==0) /* incomplete definition */ { offset=i-80L-(long)nread; fseek(stream,offset,SEEK_CUR); /* back up 80 chars */ goto loop; } i=j; /* reset index */ font(5); /* fixed spacing */ clear(); /* erase screen */ line=0; /* init line counter */ newline: color=PALEBLUE; /* normal text */ for(j=i,jj=0;utemp[j]!=LF;j++,jj++) /* test for string */ { for(ii=0;phrase[ii]!=CR;ii++) { nocase=utemp[j+ii]; if((nocase>=0x61)&&(nocase<=0x7A)) nocase-=0x20; /* convert to upper case */ if(phrase[ii]!=nocase) break; /* no match */ } if(phrase[ii]==CR) /* match */ color=YELLOW; } strncpy(string,&utemp[i],jj); string[jj]=0; /* terminate string */ text(color,0,479-15*line,string); if(utemp[j+1]!=LF) /* end of description */ { ++line; /* increment line counter */ i=j+1; /* next character index */ goto newline; } wait: while(!kbhit()) /* wait */ { odapc(); if(k=click()) switch(k) { case 1: /* click left */ k=PDN; goto parser; case 2: /* click right */ k=PUP; goto parser; case 3: /* click both */ k=ESC; goto parser; default: goto wait; } } k=caps(); parser: if(k==PDN) /* next appearance */ goto cont; if(k<128) { keyboard[0]=k; prompt(keyboard); } abort: fclose(stream); refresh=1; } /*****************************************************************************/ unsigned int cload(unsigned char *data, unsigned int n) /* read n bytes from hard drive file */ { unsigned int nread; /* hard drive byte counter */ nread=fread(data,1,n,stream); return(nread); }