;dBRIEF Assist - v3.10
;Copyright (c) 1991 - Global Technologies Corporation
;ALL RIGHTS RESERVED
#include "dbrief.h"
(macro assi
	(
		(if (== (inq_assignment "_implode_object_window" 1) "")
			(
				(= temp_str "")
				(message "Stand by...")
				(_pick_menu (search_path (inq_environment dbr_mnu_path) "assist.mnu") "Assist Menu" 47 (_menu_lines 25) 75 1)
				(if (&& (!= temp_str "NULL")(inq_macro (substr temp_str 1 (- (index temp_str " ")1))))
					(execute_macro temp_str)
				)
			)
		;else
			(_display_popup_message "Assist menu unavailable during object edit!" "" 1)
		)
	)
)
(macro dbhe
	(
		(if (== (inq_assignment "_implode_object_window" 1) "")
			(
				(int				screen_lines
				)
				(= temp_str "")
				(while (!= temp_str "NULL")
					(
						(message "Stand by...")
						(_pick_menu (search_path (inq_environment dbr_mnu_path) "dbrief.mnu") "dBRIEF Help" 47 (_menu_lines 19) 75 1 "")
						(if (!= temp_str "NULL")
							(_display_dbhelp temp_str)
						)
					)
				)
			)
		;else
			(_display_popup_message "dBRIEF help unavailable during object edit!" "" 1)
		)
	)
)
(macro _display_dbhelp
	(
		(int		hlp_current_buffer
					hlp_temp_buffer
					hlp_start_block
					hlp_next_block
		)
		(string	topic
		)
		(= hlp_current_buffer (inq_buffer))
		(if (= hlp_temp_buffer (create_buffer "dBRIEF Help" (search_path  (inq_environment dbr_mnu_path) "dbrief.hlp") 1))
			(
				(set_buffer hlp_temp_buffer)
				(get_parm 0 topic)
				(top_of_buffer)
				(if (search_fwd (+ (+ "\xc" topic) "\xc"))
					(
						(keyboard_push)
						(beginning_of_line)
						(down)
						(inq_position hlp_start_block NULL)
						(search_fwd "\xc*\xc")
						(inq_position hlp_next_block NULL)
						(move_abs hlp_start_block 1)
						(if (>= (version) 310)
							(execute_macro "db_hide 0 _pick_action")
						)
						(if (> (- hlp_next_block hlp_start_block) 18)
							(create_window 2 21 76 2 "<PgUp/Dn> <N)ext/P)rev topic>, <Esc> to exit")
						;else
							(create_window 2 21 76 2 "<N)ext/P)rev topic>, <Esc> to exit")
						)
						(if (>= (version) 310)
							(execute_macro "db_show 0")
						)
						(attach_buffer hlp_temp_buffer)
						(assign_to_key "<Keypad-minus>" "_exit")
						(assign_to_key "<P>" "_prev_topic")
						(assign_to_key "<N>" "_next_topic")
						(assign_to_key "<p>" "_prev_topic")
						(assign_to_key "<n>" "_next_topic")
						(assign_to_key "<Esc>" "exit")
						(assign_to_key "<PgUp>" "_prev_topic")
						(assign_to_key "<PgDn>" "_next_topic")
						(refresh)
						(process)
						(keyboard_pop)
						(delete_window)
						(search_back (+ (+ "\xc" topic) "\xc"))
						(beginning_of_line)
					)
				;else
					(_display_popup_message "No help available for %s." (upper topic) 1)
				)
				(delete_buffer hlp_temp_buffer)
			)
		;else
			(_display_popup_message "Help file DBRIEF.HLP not found." "" 1)
		)
		(set_buffer hlp_current_buffer)
		(attach_buffer hlp_current_buffer)
	)
)
(macro _next_topic
	(
		(if (search_fwd "\xc\*\xc")
			(
				(beginning_of_line)
				(down)
			)
		)
	)
)
(macro _prev_topic
	(
		(int				hlp_line
		)
		(search_back "\xc\*\xc")
		(inq_position hlp_line NULL)
		(if (!= hlp_line 19)
			(up)
		)
		(search_back "\xc\*\xc")
		(beginning_of_line)
		(down)
	)
)
(macro inte
	(
		(int				int_current_buffer
							int_temp_buffer
							int_lines
		)
		(string			int_file_name
		)
		(inq_names int_file_name NULL NULL)
		(if (inq_modified)
			(write_buffer)
		)
		(= int_current_buffer (inq_buffer))
		(= int_temp_buffer (create_buffer "Interface" (search_path  (inq_environment dbr_mnu_path) "interfac.cfg") 1))
		(set_buffer int_temp_buffer)
		(end_of_buffer)
		(inq_position int_lines NULL)
		(set_buffer int_current_buffer)
		(delete_buffer int_temp_buffer)
		(_pick_menu (search_path (inq_environment dbr_mnu_path) "interfac.cfg") "Interface" 30 (_menu_lines (+ int_lines 2)) 62 04)
		(if (== (upper temp_str) "DBR_DIALECT")
			(= temp_str (_get_dialect_info dbr_dialect 4))
		)
		(if (index (upper temp_str) "BUFFER")
			(
				(= temp_str (substr temp_str 1 (- (index (upper temp_str) "BUFFER") 1)))
				(+= temp_str (+ " " int_file_name))
			)
		)
		(drop_bookmark 1 "y")
		(top_of_buffer)
		(if (search_fwd (+ (_comment_character 3) " MAIN =") 0 0)
			(
				(beginning_of_line)
				(= int_file_name (ltrim (trim (read))))
				(= int_file_name (trim (substr int_file_name (+ (index int_file_name "=") 1))))
				(+= temp_str (+ " " int_file_name))
			)
		)
		(goto_bookmark 1)
		(if (!= temp_str "NULL")
			(dos temp_str)
		)
		(= temp_str "NULL")
	)
)
(macro _execute_option_one
	(
		(int				int_current_buffer
							int_temp_buffer
		)
		(string			int_command_line
							int_file_name
		)
		(inq_names int_file_name NULL NULL)
		(if (inq_modified)
			(write_buffer)
		)
		(= int_current_buffer (inq_buffer))
		(= int_temp_buffer (create_buffer "Interface" (search_path  (inq_environment dbr_mnu_path) "interfac.cfg") 1))
		(set_buffer int_temp_buffer)
		(move_abs 1 36)
		(= int_command_line (ltrim (trim (read 29))))
		(set_buffer int_current_buffer)
		(delete_buffer int_temp_buffer)
		(if (== (upper int_command_line) "DBR_DIALECT")
			(= int_command_line (_get_dialect_info dbr_dialect 4))
		)
		(if (index (upper int_command_line) "BUFFER")
			(
				(= int_command_line (substr int_command_line 1 (- (index (upper int_command_line) "BUFFER") 1)))
				(+= int_command_line (+ " " int_file_name))
			)
		)
		(drop_bookmark 1 "y")
		(top_of_buffer)
		(if (search_fwd (+ (_comment_character 3) " MAIN =") 0 0)
			(
				(beginning_of_line)
				(= int_file_name (ltrim (trim (read))))
				(= int_file_name (trim (substr int_file_name (+ (index int_file_name "=") 1))))
				(+= int_command_line (+ " " int_file_name))
			)
		)
		(goto_bookmark 1)
		(if (strlen int_command_line)
			(dos int_command_line)
		)
	)
)
