home *** CD-ROM | disk | FTP | other *** search
- // HELP_CHN.PKG
- // March 13, 1992
- // LS
- //
- // Help Object (Global) - Chaining Version
-
- #CHKSUB 1 1 // Verify the UI subsystem.
-
- use UI
- use Helpmsgs // Global Messages for Global Help Object
-
- /Help_Cant_Open_Img
- ╔══════════════════════════════════════════╗
- ║ The help data files could not be loaded. ║
- ║ The help system is unavailable. ║
- ║ ║
- ║ ____ ║
- ╚══════════════════════════════════════════╝
- /*
-
- #COMMAND DEFINE_SYMBOL R "FOR" R
- #IFDEF !1
- #ELSE
- #REPLACE !1 !3
- #ENDIF
- #ENDCOMMAND
-
- DEFINE_SYMBOL HELP_CHAIN_PROGRAM FOR 'help'
-
- DEFINE_SYMBOL HELP_ARG_CONTEXT_HELP FOR 'C'
- DEFINE_SYMBOL HELP_ARG_HELP_FOR_HELP FOR 'H'
- DEFINE_SYMBOL HELP_ARG_HELP_INDEX FOR 'I'
- DEFINE_SYMBOL HELP_ARG_KEYS_HELP FOR 'K'
-
- DEFINE_SYMBOL HELP_FOR_HELP_NAME FOR 'HELP FOR HELP' //special values of
- DEFINE_SYMBOL HELP_KEYS_NAME FOR 'KEYS HELP' // HELP_NAME
- DEFINE_SYMBOL HELP_NAME_LENGTH FOR 40
- DEFINE_SYMBOL HELP_GRP_FILENAME FOR 'helpgrp' // default filenames
- DEFINE_SYMBOL HELP_SBJ_FILENAME FOR 'helpsbj'
- DEFINE_SYMBOL HELP_XRF_FILENAME FOR 'helpxrf'
- DEFINE_SYMBOL HELP_CTX_FILENAME FOR 'helpctx'
- DEFINE_SYMBOL HELP_FILENAME_PREFIX FOR 'help'// default filename prefix
-
- class Help_Chain is an ARRAY
- procedure Construct_Object
- forward send Construct_Object
-
- property string Chain_Program_Name Public HELP_CHAIN_PROGRAM
- property string Context_Filename Public HELP_CTX_FILENAME
- property string Filename_Prefix Private HELP_FILENAME_PREFIX
- property string Group_Filename Public HELP_GRP_FILENAME
- property string Link_Filename Public HELP_XRF_FILENAME
- property integer Remain_Open_State Public 0
- property string Subject_Filename Public HELP_SBJ_FILENAME
-
- object Cant_Open is a Button Help_Cant_Open_Img
- set Block_Mouse_State to True
- set Location to 11 18 Absolute
- set Popup_State to True
- set Scope_State to True
-
- item_list
- on_item "<OK>" send Ok
- end_item_list
-
- on_key kHelp send None Private
- on_key kExit_Application send None Private
- end_object
- end_procedure
-
- procedure Set Filename_Prefix string Prefix
- local integer Old_Pre_Len
- local string Old_Name
-
- length (!$.Filename_Prefix( Current_Object )) to Old_Pre_Len
- set Help_Chain.Filename_Prefix to Prefix
-
- get Group_Filename to Old_Name
- set Group_Filename to ;
- (Prefix + mid( Old_Name, length( Old_Name ) - Old_Pre_Len, Old_Pre_Len + 1 ))
-
- get Subject_Filename to Old_Name
- set Subject_Filename to ;
- (Prefix + mid( Old_Name, length( Old_Name ) - Old_Pre_Len, Old_Pre_Len + 1 ))
-
- get Link_Filename to Old_Name
- set Link_Filename to ;
- (Prefix + mid( Old_Name, length( Old_Name ) - Old_Pre_Len, Old_Pre_Len + 1 ))
-
- get Context_Filename to Old_Name
- set Context_Filename to ;
- (Prefix + mid( Old_Name, length( Old_Name ) - Old_Pre_Len, Old_Pre_Len + 1 ))
- end_procedure
-
- function Filename_Prefix returns string
- function_return (!$.Filename_Prefix( Current_Object ))
- end_function
-
- procedure Open_Help integer Local_Open
- local integer Rem_Opn Old_Error_ID
-
- get Remain_Open_State to Rem_Opn
- if Num_Arguments LE 0 set Remain_Open_State to True
-
- indicate Err False
- move Error_Object_ID to Old_Error_ID
- move Current_Object to Error_Object_ID
-
- open (Group_Filename( Current_Object )) as Grp // language
- [not Err] open (Subject_Filename( Current_Object )) as Sbj // dependent file
- [not Err] open (Link_Filename( Current_Object )) as Xrf // names are in
- [not Err] open (Context_Filename( Current_Object )) as Ctx // properties
-
- [Err] begin
- close Grp
- close Sbj
- close Xrf
- close Ctx
- end
-
- move Old_Error_Id to Error_Object_ID
-
- [not Err] if Rem_Opn send Store_Records
- end_procedure
-
- procedure Error_Report integer Error_Info string Err_Text
- local integer Ret_Val
- ui_accept (Cant_Open( Current_Object )) to Ret_Val
- end_procedure
-
- procedure Close_Help integer Local_Close
- if (Num_Arguments Min 1) NE (Remain_Open_State( Current_Object )) begin
- close Grp
- close Sbj
- close Xrf
- close Ctx
- end
- end_procedure
-
- // chain to the chn_help program; note the use of export_only to force the use
- // of help files opened in this class; chn_help prog's opens will do nothing
-
- procedure Chain_Help string Chn_Arg
- if Chn_Arg NE HELP_ARG_CONTEXT_HELP begin
- send Open_Help True
- [err] procedure_return
- end
-
- chain wait (Chain_Program_Name(Current_Object) + " " + Chn_Arg) ;
- Export_Only
- send Refresh_Screen to Desktop // in case screen was corrupted
- if Chn_Arg NE HELP_ARG_CONTEXT_HELP send Close_Help True
- if (Remain_Open_State( Current_Object )) send Restore_Records
- end_procedure
-
- procedure View_Context_Help integer Obj
- local integer Ret_Val
-
- send Open_Help True
- [err] procedure_return
- get Context_Help Obj to Ret_Val
- if Ret_Val ;
- send Chain_Help (HELP_ARG_CONTEXT_HELP + " " + String( Ret_Val ))
- else send Chain_Help HELP_ARG_HELP_INDEX
- send Close_Help True
- end_procedure
-
- // return Ctx.Recnum for passed Help Name; 0 if none found
-
- function Find_Help string Hlp_Name returns integer
- clear Ctx
- get Application_Name of Desktop to Ctx.App_Name
- get Module_Name of Desktop to Ctx.Mod_Name
- trim (Uppercase( Hlp_Name )) to Ctx.Hlp_Name
- find EQ Ctx.Hlp_Name
- [Found] relate Ctx
- function_return Ctx.Recnum
- end_function
-
- // return Ctx.Recnum of appropriate Ctx record for the focus object
-
- function Context_Help integer Obj_Num returns integer
- local string App_Name Mod_Name
- local integer Obj Ret_Val
-
- move Obj_Num to Obj
-
- repeat
- if (Find_Help( Current_Object, Right( Help_Name( Obj ), ;
- HELP_NAME_LENGTH ) )) function_return Ctx.Recnum
-
- if Obj EQ Desktop function_return 0
-
- get Parent of Obj to Obj
- loop
- end_function
-
- procedure View_Help_For_Help
- send Chain_Help to Help_Object HELP_ARG_HELP_FOR_HELP
- end_procedure
-
- procedure View_Keys_Help
- send Chain_Help to Help_Object HELP_ARG_KEYS_HELP
- end_procedure
-
- procedure View_Help_Index
- send Chain_Help to Help_Object HELP_ARG_HELP_INDEX
- end_procedure
-
- procedure Store_Records
- set Array_Value item 0 to Grp.Recnum
- set Array_Value item 1 to Sbj.Recnum
- set Array_Value item 2 to Xrf.Recnum
- set Array_Value item 3 to Ctx.Recnum
- end_procedure
-
- procedure Restore_Records
- clear Grp Sbj Xrf Ctx
- get Array_Value item 0 to Grp.Recnum
- get Array_Value item 1 to Sbj.Recnum
- get Array_Value item 2 to Xrf.Recnum
- get Array_Value item 3 to Ctx.Recnum
- find EQ Grp.Recnum
- find EQ Sbj.Recnum
- find EQ Xrf.Recnum
- find EQ Ctx.Recnum
- end_procedure
-
- procedure Request_Help integer Msg_ID integer Arg
- local integer Was_Err
-
- move 0 to Was_Err
- [err] move 1 to Was_Err
- indicate Err False
-
- if NUM_ARGUMENTS GT 1 send Msg_ID Arg
- else send Msg_ID
-
- indicate Err as Was_Err NE 0
- end_procedure
- end_class
-
- object Help_Object is a Help_Chain
- end_object
-