function long get_que_choice !labels !constants %include "$jbcmsgdef" %from %library "sys$library:basic$starlet.tlb" %include "$quidef" %from %library "sys$library:basic$starlet.tlb" %include "$smgdef" %from %library "sys$library:basic$starlet.tlb" %include "$smgmsg" %from %library "sys$library:basic$starlet.tlb" %include "smg$routines" %from %library "sys$library:basic$starlet.tlb" %include "$ssdef" %from %library "sys$library:basic$starlet.tlb" !types !variables declare long msg_dpid, sys_status, init_msg_window, & save_queue_name_len, window_len, & menu_dpid, start_row, start_col, & dp_attr, window_width, idx, itm, & max_len, reverse, normal, char_len, & max_menu_choice, char_num, sflag, & char_found declare word terminator_key declare string read_msg, window_title, queue_name_str, & save_queue_name, default_choice, char %include "que_struct.bas" declare string menu_item(maxqueues) !procedures !functions external long function smg$put_with_scroll, & write_display( long, long ), & set_que_context( string ), & sys$getquiw, & get_que_info, & set_que_entries, & window_message( string, long, long ), & window_input( string, string, long ) max_len = 0% char = "" default_choice = "Exit No Change" available_queues_len(0%) = len(default_choice) for idx = 1% to queue_count max_len = max(max_len, available_queues_len(idx)) next idx max_len = max_len + 2% if available_queues_len(0%) > max_len then max_len = available_queues_len(0%) + 1% end if menu_item(0%) = " " + default_choice + space$(max_len-available_queues_len(0%)) for idx = 1% to queue_count menu_item(idx) = " " + mid(available_queues(idx), 1%, & available_queues_len(idx)) + & space$(max_len - available_queues_len(idx)) next idx max_menu_choice = queue_count menu_choice = 0% reverse = smg$m_reverse normal = smg$m_normal dp_attr = smg$m_border window_len = min(max_menu_choice + 1%, tt_rows - 2%) window_width = max_len sys_status = smg$create_virtual_display( window_len by ref, & window_width by ref, & menu_dpid by ref, & dp_attr by ref,, ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if window_title = " Choose Queue " sys_status = smg$label_border( menu_dpid by ref, & window_title by desc,,,,, ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if start_row = (tt_rows / 2%) - ((window_len + 2%) / 2%) + 2% start_col = (tt_cols - window_width) / 2% + 1% sys_status = smg$paste_virtual_display( menu_dpid by ref, & pbid by ref, & start_row by ref, & start_col by ref, ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if sys_status = smg$put_with_scroll( menu_dpid by ref, & menu_item(menu_choice) by desc,,& reverse by ref,,, ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if for itm = 1% to max_menu_choice sys_status = smg$put_with_scroll( menu_dpid by ref, & menu_item(itm) by desc,, & normal,,, ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if next itm sys_status = smg$set_cursor_abs( menu_dpid by ref, & 1% by ref, & 1% by ref ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if sys_status = smg$read_keystroke( kbid by ref, & terminator_key by ref,,,,, ) if sys_status = smg$_eof then sys_status = ss$_normal end if if terminator_key = smg$k_trm_ctrlz or terminator_key = smg$k_trm_f10 then menu_choice = 0% terminator_key = smg$k_trm_cr end if if (sys_status = ss$_badescape) or & (sys_status = ss$_partescape) or & (sys_status = ss$_dataoverun) then sys_status = window_getmsg( sys_status ) sys_status = smg$set_cursor_abs( menu_dpid by ref, & 1% by ref, & 1% by ref ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if end if if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if while terminator_key <> smg$k_trm_cr and terminator_key <> smg$k_trm_do select terminator_key case = smg$k_trm_up, = smg$k_trm_ctrlp char = "" if menu_choice > 0% then sys_status = smg$set_cursor_abs( menu_dpid by ref, & menu_choice + 1% by ref, ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if sys_status = smg$put_with_scroll( menu_dpid by ref, & menu_item(menu_choice) by desc,, & normal,,, ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if menu_choice = menu_choice - 1% sys_status = smg$set_cursor_abs( menu_dpid by ref, & menu_choice + 1% by ref, ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if sys_status = smg$put_with_scroll( menu_dpid by ref, & menu_item(menu_choice) by desc,, & reverse,,, ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if sys_status = smg$set_cursor_abs( menu_dpid by ref, & menu_choice + 1% by ref, ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if end if case = smg$k_trm_down, = smg$k_trm_ctrln char = "" if menu_choice < max_menu_choice then sys_status = smg$set_cursor_abs( menu_dpid by ref, & menu_choice + 1% by ref, ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if sys_status = smg$put_with_scroll( menu_dpid by ref, & menu_item(menu_choice) by desc,, & normal,,, ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if menu_choice = menu_choice + 1% sys_status = smg$set_cursor_abs( menu_dpid by ref, & menu_choice + 1% by ref, ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if sys_status = smg$put_with_scroll( menu_dpid by ref, & menu_item(menu_choice) by desc,, & reverse,,, ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if sys_status = smg$set_cursor_abs( menu_dpid by ref, & menu_choice + 1% by ref, ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if end if case smg$k_trm_space to smg$k_trm_delete, & = smg$k_trm_ctrlu, = smg$k_trm_ctrlx select terminator_key case = smg$k_trm_delete char_len = len(char) if char_len > 0% then char = mid(char, 1%, char_len - 1%) end if case = smg$k_trm_space, = smg$k_trm_ctrlu, = smg$k_trm_ctrlx char = "" ! char_num = 0% case else char = char + chr$(terminator_key) end select ! char_num = asc(char) idx = 0% char_found = 0% while idx <= queue_count if (terminator_key = smg$k_trm_space) or & (terminator_key = smg$k_trm_ctrlu) or & (terminator_key = smg$k_trm_ctrlx) or & ((terminator_key = smg$k_trm_delete) and & (char = "")) then idx = menu_choice sflag = -1% else sflag = 0% end if ! if asc(mid(menu_item(idx),2%, 1%)) = char_num then if mid(edit$(menu_item(idx), 32%), 2%, len(char)) = & edit$(char, 32%) or sflag then char_found = -1% ! if menu_choice <> idx then sys_status = smg$set_cursor_abs( menu_dpid by ref, & menu_choice + 1% by ref, ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if sys_status = smg$put_with_scroll( menu_dpid by ref, & menu_item(menu_choice) by desc,, & normal,,, ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if menu_choice = idx sys_status = smg$set_cursor_abs( menu_dpid by ref, & menu_choice + 1% by ref, ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if if (char = "") or (" " + char = menu_item(menu_choice)) then sys_status = smg$put_with_scroll( menu_dpid by ref, & menu_item(menu_choice) by desc,, & reverse,,, ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if else sys_status = smg$put_chars(menu_dpid by ref, & mid(menu_item(menu_choice), & 2%, len(char)) by desc, & menu_choice + 1% by ref,& 2%,,& reverse,, ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if end if sys_status = smg$set_cursor_abs(menu_dpid by ref,& menu_choice + 1% by ref,& 1% by ref ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if ! end if idx = queue_count end if idx = idx + 1% next if not(char_found) then char_len = len(char) if char_len > 0% then char = mid(char, 1%, char_len - 1%) end if end if case = smg$k_trm_ctrlw, = smg$k_trm_ctrll sys_status = smg$repaint_screen( pbid by ref ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if sys_status = smg$set_cursor_abs( menu_dpid by ref, & menu_choice + 1% by ref,& 1% by ref ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if end select sys_status = smg$read_keystroke( kbid by ref, & terminator_key by ref,,,,, ) if sys_status = smg$_eof then sys_status = ss$_normal end if if terminator_key = smg$k_trm_ctrlz or terminator_key = smg$k_trm_f10 then sys_status = smg$put_with_scroll(menu_dpid by ref, & menu_item(menu_choice) by desc,, & normal,,, ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if menu_choice = 0% terminator_key = smg$k_trm_cr sys_status = smg$set_cursor_abs(menu_dpid by ref, & 1% by ref, & 1% by ref ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if end if if (sys_status = ss$_badescape) or & (sys_status = ss$_partescape) or & (sys_status = ss$_dataoverun) then sys_status = window_getmsg( sys_status ) sys_status = smg$set_cursor_abs( menu_dpid by ref, & menu_choice by ref, & 1% by ref ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if end if if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if if (terminator_key = smg$k_trm_cr) or (terminator_key = smg$k_trm_do) then sys_status = smg$put_with_scroll( menu_dpid by ref, & menu_item(menu_choice) by desc,, & reverse,,, ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if end if next sys_status = smg$delete_virtual_display( menu_dpid by ref ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if if menu_choice = 0% then get_que_choice = ss$_normal exit function end if queue_name = available_queues(menu_choice) queue_name_len = available_queues_len(menu_choice) queue_name_str = mid(queue_name, 1%, queue_name_len) read_msg = "Loading " + queue_name_str + & " queue job information. Please wait..." sys_status = window_message( read_msg, 0%, msg_dpid ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if sys_status = set_que_context( queue_name_str ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if sys_status = get_que_info if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if anything_selected = 0% for idx = 1% to num_jobs selected(idx) = 0% next idx sys_status = smg$delete_virtual_display( msg_dpid by ref ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if window_title = " " + edit$(mid(queue_name,1%,queue_name_len),2%+4%+32%)& + " Entries " sys_status = smg$label_border( dpid by ref, & window_title by desc,,,,, ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if display_flag = 0% sys_status = write_display( screen, datalines ) if (sys_status and 1%) = 0% then call lib$signal( sys_status by value ) end if cur_job = 1% cur_row = top_scroll cur_col = 1% get_que_choice = sys_status end function