sub display_dirs( long page_number, string new_dir( ) ) ! Written by Michael W. Wheeler (mww@tntech.bitnet) ! VAX Basic V3.1 ! Copyright (c) by Michael W. Wheeler, September 1987 ! This program is intended for Public Domain, and may not be sold or ! marketed in any form without the permision and written consent ! from the author Michael W. Wheeler. I retain all copyrights to ! this program, in either the original or modified forms, and no ! violation, deletion, or change of the copyright notice is ! allowed. Futhermore, I will have no liability or responsibilty ! to any user with respect to loss or damage caused directly or ! indirectly by this program. ! Labels ! none. ! Constants %include "$smgtrmptr" %from %library "sys$library:basic$starlet.tlb" declare word constant maxdirs = 2000 ! Types ! none. ! Variables declare long cur_row, cur_col, page_size, dir_count, i declare string print_string, dash_line, spaces, line1, line2 common (rd_dirs) long col_compare common (io_l) long term_table, col_len, num_cols, tt_cols, tt_rows common (io_w) word chan, max_dir, cursor_len, start_row, start_col ! Procedures ! none. ! Functions external integer function find_last by desc ( string, string ) cur_row = start_row ! Row to start displaying directories. cur_col = start_col ! Column to start displaying directories dash_line = string$(tt_cols, 45%) ! Calculate length of the dashed line based on the buffer size of the device. page_size = (tt_rows - (start_row - 1%)) * num_cols ! page size = max number of directories that will fit on display. ! Calculate index into the array to start displaying directories at. if page_number = 0% then dir_count = page_number * page_size + 1% else dir_count = page_number * page_size + 1% page_size = (page_number + 1%) * page_size end if call output( smg$k_erase_whole_display, term_table, chan ) ! Spaces = number of spaces to print to center instructions. if tt_cols <= 80% then spaces = "" else spaces = space$( (tt_cols - 80%) / 2% ) end if line1 = spaces + "Abort=^C Expand=^X Next_scrn=^V Up_level =^J Move Cursor = emacs,edt,dcl" line2 = spaces + "Help = ? Exit =^Z Prev_scrn=ESC V Down_level=^R Set Default = Return,number" call set_cursor_abs( 2%, 1%, term_table, chan ) print #2%, mid(line1, 1%, min(len(line1),tt_cols)) call set_cursor_abs( 3%, 1%, term_table, chan ) print #2%, mid(line2, 1%, min(len(line2),tt_cols)) call set_cursor_abs( 4%, 1%, term_table, chan ) print #2%, dash_line; ! Print one page of directories. while (dir_count <= max_dir) and (dir_count <= page_size) dot = find_last(".", new_dir(dir_count)) if dot = 0% then dot = instr(0%, new_dir(dir_count), "[") + 1% end if call set_cursor_abs( cur_row, cur_col, term_table, chan ) if cur_col > col_compare then cur_col = cursor_len + 1% cur_row = cur_row + 1% else cur_col = cur_col + col_len end if print_string = format$(dir_count, "####") + " [" + & mid(new_dir(dir_count), dot, len(new_dir(dir_count)) - dot + 1%) if len(print_string) <= col_len then print #2%, print_string; else print #2%, mid(print_string, 1%, col_len); end if dir_count = dir_count + 1% next subend