home *** CD-ROM | disk | FTP | other *** search
- { CDS-DISP.PAS - Requires STD-CTV.PAS and CDS-UTIL.PAS }
-
- procedure Disp_Prompt(prmt_no: Byte);
- begin
- vid_line[MSG_LINE] := prompt_ln[3 * prmt_no + 1];
- vid_line[PROMPT_LINE] := prompt_ln[3 * prmt_no + 2];
- vid_line[CMD_LINE] := prompt_ln[3 * prmt_no + 3];
- end { Disp_Prompt };
-
- procedure Disp_Help(help_line,
- line_no,
- line_cnt : Byte;
- valid_keys : Any_Char);
-
- var xpos, ypos : Byte;
- temp_buf : Inp_Scrn;
- begin
- temp_buf := cur_scrn;
- Move(help_ln[help_line],vid_line[line_no],(160 * line_cnt));
- Disp_Prompt(HELP_PROMPT);
- xpos := WhereX; ypos := WhereY;
- if (valid_keys <> [ESC]) then
- begin
- Display_Prompt(PROMPT_LINE,'INP','Enter selection ' + ARROW);
- GoToXY(27,PROMPT_LINE);
- end
- else
- GoToXY(29,CMD_LINE);
- repeat
- Read_Kbd(inchr,inctl);
- until (inctl in valid_keys);
- cur_scrn := temp_buf;
- end; { Disp_Help }
-
- procedure Display_Prompt; { (line : Byte;
- prompt : Str_10;
- msg_str : Str_80); forward declared }
- var hold_pos : Integer;
-
- begin { Display_Prompt }
- GoTo_XY(2,line); hold_pos := cur_pos;
- vid_attr := DIM_VID;
- Write_Usr_Str((prompt + ': ')); vid_attr := BRIGHT_VID;
- Write_Usr_Str(msg_str);
- GoToXY(2 + cur_pos - hold_pos,line);
- end; { Display_Prompt }
-
- procedure Disp_Error_Msg; { (err_msg: Str_80); }
- var inchr : Char; { forward defined in STD-UTIL.PAS }
-
- begin
- Disp_Prompt(HELP_PROMPT);
- Display_Prompt(PROMPT_LINE,'ERR',err_msg);
- Beep;
- Read(Kbd,inchr); { Pause until key is pressed }
- end; { Disp_Error_Msg }
-
- procedure Disp_IO_Error; { (device_name: File_ID); }
- { forward defined in STD-UTIL.PAS }
- var IO_Msg : Str_80;
- err_str : string[3];
- valid_keys : Printable_Char;
-
- begin
- Str(io_status:3,err_str);
- IO_Msg := ' error status = ' + err_str;
- Disp_Prompt(ERROR_PROMPT);
- IO_Msg := 'Device/File ' + device_name + IO_Msg;
-
- Display_Prompt(PROMPT_LINE,'MSG',IO_Msg);
- Display_Prompt(MSG_LINE,'INP',
- 'Press CMD: key to enter selection. (A/I) ==> ');
- inchr := Valid_Key(['A','I']);
- if (inchr = 'A') then
- err_flag := TRUE
- else
- io_status := ZERO
- end; { Disp_IO_Error }
-
- procedure Load_Inp_Scrn(scrn_id: File_ID; var screen: Scrn_Image);
-
- begin
- Assign(image_file,scrn_id);
- {$I-} Reset(image_file); {$I+} io_status := IOresult;
- if io_status = ZERO then
- begin
- Read(image_file,screen);
- Close(image_file);
- end;
- end { Load_Inp_Scrn };
-
- procedure Disp_Inp_Scrn(scrn_no: Byte);
- begin
- if (scrn_no = ZERO) then
- cur_scrn := buf_scrn
- else
- cur_scrn := vid_buf[scrn_no].buf_scrn;
- end { Disp_Inp_Scrn };
-
- procedure Verify_Exit;
- begin
- vid_line[22] := prompt_ln[3];
- Disp_Prompt(MSG_BOX_PROMPT);
- Display_Prompt(PROMPT_LINE,'INP','Do you want to END this session? (Y/N) ==> ');
- if (Valid_Key(['Y','N',ESC]) = 'Y') then
- end_session := TRUE;
- end; { Verify_Exit }
-
- procedure Verify_Cancel;
- begin
- Disp_Prompt(MSG_BOX_PROMPT);
- Display_Prompt(PROMPT_LINE,'INP','Abandon changes? (Y/N) ' + ARROW);
- if (Valid_Key(['Y','N']) = 'Y') then
- begin
- esc_flag := TRUE;
- modified := FALSE;
- end;
- end; { Verify_Cancel }
-
- procedure Load_Screen(scrn_id: File_ID; var screen_buf: Inp_Scrn);
- var screen_file : file of Inp_Scrn;
-
- begin
- Assign(screen_file,scrn_id);
- {$I-} Reset(screen_file); {$I+} io_status := IOresult;
- if io_status = ZERO then
- begin
- Read(screen_file,screen_buf);
- Close(screen_file);
- end;
- end; { Load_Screen }
-
- procedure Load_Fld_Msgs(file_name: File_ID);
- var inp_text : Text;
- msg_ptr : Integer;
- begin
- Assign(inp_text,file_name);
- Reset(inp_text); msg_ptr := 1;
- while (not Eof(inp_text)) do
- begin
- ReadLn(inp_text,fld_msg[msg_ptr]);
- msg_ptr := Succ(msg_ptr);
- end;
- Close(inp_text);
- end; { Load_Fld_Msgs }
-
- procedure Load_Menu_Selections(menu_id: File_ID);
- var menu_file : Text;
- txt_row, txt_col : Str_2;
- sel_cnt, int_val : Integer;
- dummy : Char;
-
- begin
- Assign(menu_file,menu_id);
- {$I-}
- Reset(menu_file); io_status := IOresult;
- if (io_status = ZERO) then
- begin
- ReadLn(menu_file,sel_cnt); io_status := IOresult;
- end;
- {$I+}
- FillChar(menu_dat,SizeOf(menu_dat),ZERO);
- if (io_status = ZERO) then
- for i := 1 to sel_cnt do
- with menu_dat[i] do
- begin
- Read(menu_file,txt_row,dummy);
- Read(menu_file,txt_col,dummy);
- ReadLn(menu_file,menu_txt);
- Val(txt_col,int_val,io_status); xloc := int_val;
- Val(txt_row,int_val,io_status); yloc := int_val;
- end;
- if (io_status = ZERO) then
- Close(menu_file)
- else
- Disp_IO_Error(menu_id);
- end; { Load_Menu_Selections }
-
- procedure Display_Menu_Selection(pntr: Integer; select: Boolean);
- begin
- with menu_dat[pntr] do
- begin
- GoTo_XY(xloc,yloc); vid_attr := REVERSE_VID;
- Write_Usr_Str(Copy(menu_txt,1,3)); vid_attr := BRIGHT_VID;
- if select then vid_attr := REVERSE_VID;
- Write_Usr_Str(Copy(menu_txt,4,40)); Write(Usr,SPACE);
- vid_attr := BRIGHT_VID;
- end;
- end; { Display_Menu_Selection }
-
- procedure Disp_Menu(select_file : File_ID;
- menu_header : Str_40);
- begin
- cur_scrn := menu_buf;
- Disp_Prompt(MENU_PROMPT); Rev_Video;
- GoTo_XY(9,2); Write_Usr_Str(SPACE + sys_date + SPACE);
- GoTo_XY(54 - (Length(menu_header) div 2),2);
- Write_Usr_Str(menu_header); Norm_Video;
- Load_Menu_Selections(select_file);
- i := 1;
- while (menu_dat[i].menu_txt <> NULL_STR) do
- with menu_dat[i] do
- begin
- if menu_txt <> '*' then
- if (i = 1) then
- Display_Menu_Selection(i,TRUE)
- else
- Display_Menu_Selection(i,FALSE);
- i := Succ(i);
- end;
- end; { Disp_Menu }
-
- function Valid_Menu_Selection(max: Byte): Integer;
- const key_set : Any_Char = ['0'..'9',BS,ESC,PREV_FLD,NEXT_FLD,
- ALT_PREV,ALT_NEXT,ENTER,#94..#103];
-
- var selection,
- pointer : Integer;
- xpos, ypos : Byte;
-
- procedure Init_Inp_Fld;
- begin
- GoToXY(xpos,ypos); Write(FILL_CHAR,FILL_CHAR);
- GoToXY(xpos,ypos); selection := ZERO; i := ZERO;
- end; { Init_Inp_Fld }
-
- begin { Valid_Menu_Selection }
- xpos := WhereX; ypos := WhereY;
- inchr := NULL_CHR; pointer := 1;
- Init_Inp_Fld; submenu := FALSE;
- while (i < 3) and (inchr <> ENTER) do
- begin
- inchr := Valid_Key(key_set);
- if (inchr in ['0'..'9']) then
- begin
- if (i = 0) then
- selection := selection + Ord(inchr) - 48
- else
- selection := selection * 10 + Ord(inchr) - 48;
- if (selection > max) then
- begin
- Beep;
- Init_Inp_Fld;
- end
- else
- begin
- Write(inchr);
- i := Succ(i);
- end;
- end
- else
- case inchr of
- ENTER : if (selection = ZERO) then
- selection := pointer;
- BS : if (i > ZERO) then
- begin
- i := Pred(i);
- Write(BS,SPACE,BS);
- selection := selection div 10;
- end
- else
- Beep;
- ESC : begin
- esc_flag := TRUE;
- inchr := ENTER;
- selection := ZERO;
- end;
- ALT_PREV,
- PREV_FLD : begin
- Display_Menu_Selection(pointer,FALSE);
- if (pointer > 1) then
- pointer := Pred(pointer)
- else
- pointer := max;
- Display_Menu_Selection(pointer,TRUE);
- Init_Inp_Fld;
- end;
- ALT_NEXT,
- NEXT_FLD : begin
- Display_Menu_Selection(pointer,FALSE);
- pointer := (pointer mod max) + 1;
- Display_Menu_Selection(pointer,TRUE);
- Init_Inp_Fld;
- end;
- #94..#103 : begin
- selection := Ord(inchr) - 93;
- submenu := TRUE;
- inchr := ENTER;
- end;
- end; {case}
- end; {while}
- Valid_Menu_Selection := selection;
- end; { Valid_Menu_Selection }