MODULE SCA$REPORT_PORTABLE_SYNTAX IDENT "T4.0-4" !************************************************************************* ! * ! © 2000 BY * ! COMPAQ COMPUTER CORPORATION * ! © 2000 BY * ! ELECTRONIC DATA SYSTEMS LIMITED * ! * ! THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED * ! ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH THE * ! INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR ANY OTHER * ! COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY * ! OTHER PERSON. NO TITLE TO OR OWNERSHIP OF THE SOFTWARE IS HEREBY * ! TRANSFERRED. * ! * ! THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE * ! AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY COMPAQ COMPUTER * ! CORPORATION OR EDS. * ! * ! NEITHER COMPAQ NOR EDS ASSUME ANY RESPONSIBILITY FOR THE USE OR * ! RELIABILITY OF THIS SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY * ! COMPAQ. * ! * !************************************************************************* ! !++ ! Facility: ! SCA - Source Code Analyzer ! REPORT - Report Subfacility ! ! Abstract: ! The procedures in this module are used for processing the portable report ! syntax: ! defining the valid options for each report ! filling in option values (SET REPORT command, RESET REPORT command) ! displaying option values (SHOW REPORT command) ! portable invocation of a report (REPORT command) ! Global/static variables for report option routines ! VARIABLE sca$report_options_initialized, ! TRUE if report options have been initialized ! via a call to the report's define_options ! procedure. FALSE (or undefined) otherwise. sca$report_temp_value, ! global used for "execute" assignment. sca$report_temp_result, ! global used for "execute" result status. sca$report_valid_option_array, ! array containing default values for all ! valid options. indexed by option name. sca$report_valid_options, ! string containing names of all valid options ! for the current report, separated by blanks. sca$report_valid_options_UC;! uppercase copy of valid option names procedure sca$report_cmd_report (rest_of_line) !++ ! FUNCTIONAL DESCRIPTION: ! ! This is the top-level routine for the portable REPORT command. ! It is invoked from SCA only (not directly from LSE). ! ! The format of the portable REPORT command is: ! ! REPORT [report-name] ! ! FORMAL PARAMETERS: ! ! rest_of_line - the rest of the command line entered by the user, after the ! REPORT keyword. This is the name of the report. Defaults to report ! name from SET REPORT NAME. ! ! ROUTINE VALUE: ! ! TRUE if the report is generated. FALSE if not. !-- LOCAL report_name, status; ON_ERROR [OTHERWISE]: sca$report_common_error_cleanup ("SCA$REPORT_CMD_REPORT"); ENDON_ERROR; IF GET_INFO (rest_of_line, 'TYPE') = UNSPECIFIED THEN report_name := ''; ELSE report_name := EDIT (rest_of_line, COMPRESS, TRIM, UPPER); ENDIF; IF GET_INFO (sca$report_name, 'TYPE') = UNSPECIFIED THEN sca$report_name := ''; ENDIF; ! Default to current report name, if it's been set. ! IF (report_name <> '') AND (sca$report_name <> '') THEN IF INDEX (sca$report_name, report_name) <> 1 THEN sca$report_status_message ('Report name does not match SET REPORT NAME'); RETURN FALSE; ENDIF; ENDIF; IF sca$report_name = '' THEN sca$report_name := report_name; ENDIF; ! Run the report. ! status := lse$report (sca$report_name); RETURN status; ENDPROCEDURE; procedure sca$report_cmd_reset_report (rest_of_line) !++ ! FUNCTIONAL DESCRIPTION: ! ! This is the top-level routine for the portable RESET REPORT command. ! It is invoked from SCA only (not directly from LSE). ! ! The format of the portable RESET REPORT command is: ! ! RESET REPORT option-name-expression ! ! FORMAL PARAMETERS: ! ! rest_of_line - name of option to reset. May include wildcard characters. ! ! ROUTINE VALUE: ! ! TRUE if the option is reset successfully. FALSE if not. !-- LOCAL option_name, status; ON_ERROR [OTHERWISE]: sca$report_common_error_cleanup ("SCA$REPORT_CMD_RESET_REPORT"); ENDON_ERROR; IF GET_INFO (rest_of_line, 'TYPE') = UNSPECIFIED THEN sca$report_status_message ('Option name must be specified'); RETURN FALSE; ELSE option_name := EDIT (rest_of_line, COMPRESS, TRIM, UPPER); ENDIF; ! If no options have been set, give a message and return. ! IF GET_INFO (sca$report_options_initialized, "TYPE") = UNSPECIFIED THEN sca$report_options_initialized := FALSE; ENDIF; IF NOT sca$report_options_initialized THEN sca$report_status_message('Report options have not been initialized'); RETURN FALSE; ENDIF; ! Process the option. ! status := sca$report_reset_option (option_name); RETURN status; endprocedure; procedure sca$report_cmd_set_report (rest_of_line) !++ ! FUNCTIONAL DESCRIPTION: ! ! This is the top-level routine for the portable SET REPORT command. ! It is invoked from SCA only (not directly from LSE). ! ! The format of the portable SET REPORT command is: ! ! SET REPORT option-name option-value ! ! FORMAL PARAMETERS: ! ! rest_of_line - name of option being set and its value. ! A value of "" means set the default value. ! ! ROUTINE VALUE: ! ! TRUE if the option is set successfully. FALSE if not. ! ! SIDE EFFECTS: ! ! An element of the array sca$report_options is filled in. !-- LOCAL i, option_name, option_value, status; ON_ERROR [OTHERWISE]: sca$report_common_error_cleanup ("SCA$REPORT_CMD_SET_REPORT"); ENDON_ERROR; IF GET_INFO (rest_of_line, 'TYPE') = UNSPECIFIED THEN rest_of_line := ''; ENDIF; IF rest_of_line = '' THEN sca$report_status_message ('Option name must be specified'); RETURN FALSE; ENDIF; ! Extract the option name and value from the command line. ! EDIT (rest_of_line, COMPRESS, TRIM, UPPER); i := INDEX (rest_of_line, ' '); IF i = 0 THEN option_name := rest_of_line; option_value := ''; ELSE option_name := SUBSTR (rest_of_line, 1, i-1); option_value := SUBSTR (rest_of_line, i+1); ENDIF; IF GET_INFO (sca$report_options_initialized, "TYPE") = UNSPECIFIED THEN sca$report_options_initialized := FALSE; ENDIF; if (option_name = 'NAME') OR (option_name = 'NAM') then ! Command is SET REPORT NAME - process it. ! status := sca$report_set_name (option_value); RETURN status; else ! Command is not SET REPORT NAME - see if a report name has been ! set already. ! if NOT sca$report_options_initialized then ! First SET REPORT is not NAME - error. ! sca$report_status_message('SET REPORT NAME must precede other SET REPORT commands'); RETURN FALSE; endif; endif; ! Process the option. ! status := sca$report_set_one_option (option_name, option_value); RETURN status; endprocedure; procedure sca$report_cmd_show_report (rest_of_line) !++ ! FUNCTIONAL DESCRIPTION: ! ! This is the top-level routine for the portable SHOW REPORT command. ! It is invoked from SCA only (not directly from LSE). ! ! The format of the portable SHOW REPORT command is: ! ! SHOW REPORT option-name-expression ! ! FORMAL PARAMETERS: ! ! rest_of_line - name of option to show. May include wildcard characters. ! ! ROUTINE VALUE: ! ! TRUE if the option is shown successfully. FALSE if not. !-- LOCAL option_name, status; ON_ERROR [OTHERWISE]: sca$report_common_error_cleanup ("SCA$REPORT_CMD_SHOW_REPORT"); ENDON_ERROR; IF GET_INFO (rest_of_line, 'TYPE') = UNSPECIFIED THEN sca$report_status_message ('Option name expression must be specified'); RETURN FALSE; ELSE option_name := EDIT (rest_of_line, COMPRESS, TRIM); ENDIF; ! If no options have been set, give a message and return. ! IF GET_INFO (sca$report_options_initialized, "TYPE") = UNSPECIFIED THEN sca$report_options_initialized := FALSE; ENDIF; IF NOT sca$report_options_initialized THEN sca$report_status_message('Report options have not been initialized'); RETURN FALSE; ENDIF; ! Process the option. ! status := sca$report_show_option (option_name); RETURN status; endprocedure; PROCEDURE sca$report_add_valid_option (option_name, default_value, option_proc) !++ ! FUNCTIONAL DESCRIPTION: ! ! Add an option to the list of valid options for a report. ! ! FORMAL PARAMETERS: ! ! option_name ! ! The option name, as a string. IN parameter. ! ! default_value ! ! The default value for the option. May be any type. IN parameter. ! ! option_proc ! ! The name of the procedure to be used to SET the option. "" if the ! standard procedure should be used. IN procedure. ! ! ROUTINE VALUE: ! ! TRUE if the option was stored successfully. FALSE if not. !-- LOCAL option_name_UC; ON_ERROR [OTHERWISE]: sca$report_common_error_cleanup ("SCA$REPORT_ADD_VALID_OPTION"); ENDON_ERROR; ! Initialize the list of valid option names and array of default values, if ! necessary. ! IF GET_INFO (sca$report_valid_options, 'TYPE') = UNSPECIFIED THEN sca$report_valid_options := ' '; ENDIF; IF GET_INFO (sca$report_valid_option_array, 'TYPE') = UNSPECIFIED THEN sca$report_valid_option_array := CREATE_ARRAY; ENDIF; IF GET_INFO (sca$report_valid_option_procs, 'TYPE') = UNSPECIFIED THEN sca$report_valid_option_procs := CREATE_ARRAY; ENDIF; ! Add option name if it doesn't exist yet. ! option_name_UC := CHANGE_CASE (option_name, UPPER, NOT_IN_PLACE); IF INDEX (sca$report_valid_options, option_name_UC + ' ') = 0 THEN sca$report_valid_options := sca$report_valid_options + option_name_UC + ' '; ENDIF; ! Add default value to array of default values. ! sca$report_valid_option_array{option_name_UC} := default_value; sca$report_valid_option_procs{option_name_UC} := option_proc; ! Initialize corresponding variable to default value. ! sca$report_set_one_option (option_name_UC, tpu$k_unspecified); RETURN TRUE; ENDPROCEDURE PROCEDURE sca$report_cleanup_options !++ ! FUNCTIONAL DESCRIPTION: ! ! Clean up all option information. This is done at the end of a report, and ! when a SET REPORT NAME command is entered. ! ! FORMAL PARAMETERS: ! ! None ! ! IMPLICIT OUTPUTS: ! ! sca$report_invoked_via_portable - true if invoked via portable syntax ! sca$report_options - string containing list of valid option names ! sca$report_valid_option_array - array containing defaults for valid options ! sca$report_valid_option_procs - array containing names of procedures used ! to set valid options !-- ON_ERROR [OTHERWISE]: sca$report_common_error_cleanup ("SCA$REPORT_CLEANUP_OPTIONS"); ENDON_ERROR; sca$report_name := tpu$k_unspecified; sca$report_options_initialized := FALSE; sca$report_invoked_via_portable := tpu$k_unspecified; sca$report_valid_options := tpu$k_unspecified; sca$report_valid_option_array := tpu$k_unspecified; sca$report_valid_option_procs := tpu$k_unspecified; ENDPROCEDURE PROCEDURE sca$report_construct_option_proc_name (prefix, full_routine_name) !++ ! FUNCTIONAL DESCRIPTION: ! ! This procedure constructs the name of the TPU routine that defines options ! for the current report. ! ! FORMAL PARAMETERS: ! ! prefix ! ! A string containing the prefix part of the procedure name. IN ! parameter. ! ! full_routine_name ! ! A string containing the full name of the routine. OUT parameter. ! ! IMPLICIT INPUTS: ! ! sca$report_name - full name of current report ! ! ROUTINE VALUE: ! ! FALSE if the routine was not found. ! TRUE otherwise. !-- LOCAL load_status; ON_ERROR [OTHERWISE]: sca$report_common_error_cleanup ("SCA$REPORT_CONSTRUCT_OPTION_PROC_NAME"); ENDON_ERROR; ! Look up the routine name. ! IF GET_INFO (PROCEDURES, "defined", prefix + sca$report_name) THEN full_routine_name := prefix + sca$report_name; RETURN TRUE; ELSE full_routine_name := 'sca$report_define_CLI_options'; RETURN FALSE; ENDIF; ENDPROCEDURE; PROCEDURE sca$report_convert_CLI_options !++ ! FUNCTIONAL DESCRIPTION: ! ! Convert options entered via the VMS CLI REPORT command to be compatible with ! the portable interface. ! ! FORMAL PARAMETERS: ! ! None ! ! IMPLICIT INPUTS: ! ! The TPU variables that are filled in by the CLI interface: ! sca$report_domain_query - string or '' ! sca$report_fill - 0 or 1 ! sca$report_name - string ! sca$report_options - string or ''. string is of form: (x,x,x) ! sca$report_output - string or '' ! sca$report_rest_of_line - string or '' ! sca$report_target - string surrounded by quotes or '' ! sca$report_languages - string or '' ! sca$report_help_library - string or '' !-- LOCAL save_domain_query, save_fill, save_output, save_target, save_languages, save_help_library; ON_ERROR [OTHERWISE]: sca$report_common_error_cleanup ("SCA$REPORT_CONVERT_CLI_OPTIONS"); ENDON_ERROR; ! Save all the qualifier values from the user's (CLI) report command. ! save_domain_query := sca$report_domain_query; save_fill := sca$report_fill; save_output := sca$report_output; save_target := sca$report_target; save_languages := sca$report_languages; save_help_library := sca$report_help_library; ! Add option definitions for the current report, and fill in defaults. ! sca$report_get_option_defs; ! Special processing for /TARGET value, because it is quoted (historical ! artifact, retained for compatibility). ! IF GET_INFO (save_target, 'TYPE') = UNSPECIFIED THEN save_target := tpu$k_unspecified ELSE ! Strip quotes from /TARGET value, if they're present. It should ! be safe to assume that if there are any quote marks in the value, ! they're balanced and there are exactly 2. ! IF INDEX (save_target, '"') <> 0 THEN save_target := save_target - '"'; ENDIF; IF INDEX (save_target, '"') <> 0 THEN save_target := save_target - '"'; ENDIF; ENDIF; sca$report_set_one_CLI_option ('DOMAIN_QUERY', save_domain_query); sca$report_set_one_CLI_option ('FILL', save_fill); sca$report_set_one_CLI_option ('OUTPUT', save_output); sca$report_set_one_CLI_option ('TARGET', save_target); sca$report_set_one_CLI_option ('LANGUAGES', save_languages); sca$report_set_one_CLI_option ('HELP_LIBRARY', save_help_library); ENDPROCEDURE PROCEDURE sca$report_define_CLI_options !++ ! FUNCTIONAL DESCRIPTION: ! ! Define report options for the case where no define_options routine ! is available for the current report. The options defined correspond to ! the qualifiers available for the VMS CLI REPORT command. ! ! FORMAL PARAMETERS: ! ! None ! ! SIDE EFFECTS: ! ! None !-- LOCAL temp_target; ON_ERROR [OTHERWISE]: sca$report_common_error_cleanup ("sca$report_define_CLI_options"); ENDON_ERROR; sca$report_add_valid_option ('domain_query', '', 'sca$report_process_option_domain_query'); sca$report_add_valid_option ('output', '', 'sca$report_process_option_output'); ! Assume that the report initialization has already validated the target ! parameter, so we can just fill it in. IF GET_INFO (sca$report_target, 'TYPE') = UNSPECIFIED THEN temp_target := tpu$k_unspecified ELSE ! Strip quotes from /TARGET value, if they're present. It should ! be safe to assume that if there are any quote marks in the value, ! they're balanced and there are exactly 2. ! temp_target := sca$report_target; IF INDEX (temp_target, '"') <> 0 THEN temp_target := temp_target - '"'; ENDIF; IF INDEX (temp_target, '"') <> 0 THEN temp_target := temp_target - '"'; ENDIF; ENDIF; sca$report_add_valid_option ('target', sca$report_target, ''); sca$report_add_valid_option ('fill', 1, 'sca$report_process_option_boolean'); sca$report_add_valid_option ('languages', '', ''); sca$report_add_valid_option ('help_library', '', ''); ENDPROCEDURE PROCEDURE sca$report_get_option_defs !++ ! FUNCTIONAL DESCRIPTION: ! ! Get option definitions for the current report. If there is no option ! definition procedure, return FALSE. ! ! FORMAL PARAMETERS: ! ! None ! ! IMPLICIT INPUTS: ! ! sca$report_name ! ! IMPLICIT OUTPUTS: ! ! [~description-or-none~] ! ! ROUTINE VALUE: ! ! TRUE if the options were successfully defined, FALSE if not. !-- LOCAL opt_proc_name, status; ON_ERROR [OTHERWISE]: sca$report_common_error_cleanup ("SCA$REPORT_GET_OPTION_DEFS"); ENDON_ERROR; ! If options have already been initialized, just return. ! IF GET_INFO (sca$report_options_initialized, 'TYPE') = UNSPECIFIED THEN sca$report_options_initialized := FALSE; ENDIF; IF sca$report_options_initialized THEN RETURN TRUE; ENDIF; ! Look up the option definition procedure name and call the option ! definition procedure, if one is defined. ! IF sca$report_construct_option_proc_name ('SCA_REPORT_DEFINE_OPTIONS_', opt_proc_name) THEN EXECUTE (opt_proc_name); sca$report_options_initialized := TRUE; RETURN TRUE; ELSE sca$report_hard_error ('Option definition procedure not found'); RETURN FALSE; ENDIF; ENDPROCEDURE PROCEDURE sca$report_lookup_option (option_name_in, option_name_out) !++ ! FUNCTIONAL DESCRIPTION: ! ! Look up an option name. If it is not a valid, unambiguous option name for ! the current report, give an error message. If it is valid and unambiguous, ! return the full option name. ! ! FORMAL PARAMETERS: ! ! option_name_in - option name to be looked up. IN parameter. ! option_name_out - full option name, if valid and unambiguous. ! OUT parameter. ! ! ROUTINE VALUE: ! ! TRUE if exactly one option name matches the input name. FALSE otherwise. !-- LOCAL name_start, option_name_UC, temp_name; ON_ERROR [OTHERWISE]: sca$report_common_error_cleanup ("SCA$REPORT_LOOKUP_OPTION"); ENDON_ERROR; ! Get an upcased version of the list of valid option names, and of the ! user's input. ! sca$report_valid_options_UC := CHANGE_CASE (sca$report_valid_options, UPPER, NOT_IN_PLACE); option_name_UC := CHANGE_CASE (option_name_in, UPPER, NOT_IN_PLACE); ! See if a valid option name exactly matches the given option name. If so, ! return it. ! IF INDEX (sca$report_valid_options_UC, ' ' + option_name_UC + ' ') <> 0 THEN option_name_out := option_name_UC; RETURN TRUE; ENDIF; ! See if there is exactly one valid option name whose prefix matches the ! given option name. ! name_start := INDEX (sca$report_valid_options_UC, ' ' + option_name_UC); ! If none, give a message and don't set any option. ! IF name_start = 0 THEN sca$report_status_message ('No such option for current report: ' + option_name_in + '...'); RETURN FALSE; ENDIF; ! If it's ambiguous, give a message and return FALSE. ! IF INDEX (SUBSTR (sca$report_valid_options_UC, name_start+1), ' ' + option_name_UC) <> 0 THEN ! Option name is ambiguous - issue message and return. ! sca$report_status_message ('Option name is ambiguous: ' + option_name_in + '...'); RETURN FALSE; ENDIF; ! Find the full name of the option, and return it. ! temp_name := SUBSTR (sca$report_valid_options_UC, name_start+1); option_name_out := SUBSTR (temp_name, 1, INDEX(temp_name, ' ') - 1); RETURN TRUE; ENDPROCEDURE PROCEDURE sca$report_reset_option (option_name) !++ ! FUNCTIONAL DESCRIPTION: ! ! Reset an option value, or a list of option values, for the RESET REPORT ! command. ! ! FORMAL PARAMETERS: ! ! option_name - the option name (as a string). May include wildcard ! characters, may be abbreviated. ! ! ROUTINE VALUE: ! ! TRUE if the option was reset successfully. FALSE if not. !-- LOCAL name_list, next_space, n_names, option_name_UC, prefix, temp_name; ON_ERROR [TPU$_NONAMES, TPU$_MULTIPLENAMES]: ! trap expand_name errors ; [OTHERWISE]: sca$report_common_error_cleanup ("SCA$REPORT_RESET_OPTION"); ENDON_ERROR; prefix := "SCA$REPORT_OPTION_"; temp_name := prefix + option_name ; ! Get a list of all names that match the input expression (including ! wildcard characters). ! name_list := EXPAND_NAME (temp_name, VARIABLES); IF name_list = "" THEN sca$report_status_message ('No such option for current report: ' + option_name + '...'); RETURN FALSE; ENDIF; ! Add a trailing blank to make processing easier. ! name_list := name_list + ' '; ! Get an upcased version of the list of valid option names, and of the ! user's input. ! sca$report_valid_options_UC := CHANGE_CASE (sca$report_valid_options, UPPER, NOT_IN_PLACE); option_name_UC := CHANGE_CASE (option_name, UPPER, NOT_IN_PLACE); ! See if a single valid option name was given as the parameter. If so, ! process it and return. ! IF INDEX (sca$report_valid_options_UC, ' ' + option_name_UC + ' ') <> 0 THEN sca$report_set_one_option (option_name, tpu$k_unspecified); RETURN TRUE; ENDIF; ! For each name in the list, if it's valid for the current report, reset it. ! n_names := 0; LOOP next_space := INDEX (name_list, ' '); EXITIF next_space = 0; temp_name := SUBSTR (name_list, 1, next_space-1); IF sca$report_set_one_option (temp_name - prefix, tpu$k_unspecified) THEN n_names := n_names + 1; ENDIF; name_list := SUBSTR (name_list, next_space+1); ENDLOOP; IF n_names = 0 THEN sca$report_status_message ('No such option for current report: ' + option_name + '...'); RETURN FALSE; ENDIF; RETURN TRUE; ENDPROCEDURE PROCEDURE sca$report_set_name (option_value) !++ ! FUNCTIONAL DESCRIPTION: ! ! Store an option value from a SET REPORT NAME command, and do other ! necessary processing. If no define_options procedure is provided for ! the specified report name, SET REPORT NAME (and other SET REPORT commands) ! are not allowed. ! ! FORMAL PARAMETERS: ! ! option_value - the NAME option value (as a string). ! ! ROUTINE VALUE: ! ! TRUE if everything is successful, FALSE if not. ! ! SIDE EFFECTS: ! ! Initialization procedure sca_report_define_options_NAME is called. !-- LOCAL full_routine_name, status; ON_ERROR [OTHERWISE]: sca$report_common_error_cleanup ("SCA$REPORT_SET_NAME"); ENDON_ERROR; ! Find the full name of the report, by looking up its top-level routine ! name. Store the full report name in sca$report_name. ! NOTE: this routine is currently in the LSE section file. ! status := sca$report_construct_top_level_name (option_value, sca$report_name, full_routine_name); IF NOT status THEN RETURN status ENDIF; ! Define options for this report, if possible. ! sca$report_options_initialized := FALSE; sca$report_valid_options := tpu$k_unspecified; sca$report_valid_option_array := tpu$k_unspecified; sca$report_valid_option_procs := tpu$k_unspecified; RETURN sca$report_get_option_defs; ENDPROCEDURE PROCEDURE sca$report_set_one_CLI_option (option_name, option_value) !++ ! FUNCTIONAL DESCRIPTION: ! ! Set one option corresponding to a CLI qualifier. ! ! FORMAL PARAMETERS: ! ! option_name - the name of the option to be set ! option_value - the option value. Null string means to reset the option to ! its default value. !-- ON_ERROR [OTHERWISE]: sca$report_common_error_cleanup ("SCA$REPORT_SET_ONE_CLI_OPTION"); ENDON_ERROR; ! See whether this option is valid for the current report. If not, just ! quietly return. ! sca$report_valid_options_UC := CHANGE_CASE (sca$report_valid_options, UPPER, NOT_IN_PLACE); IF INDEX (sca$report_valid_options_UC, ' ' + option_name + ' ') = 0 THEN RETURN; ENDIF; ! Convert null qualifier value to unspecified (null means the qualifier was ! not entered on the command line, so the default should be used). ! IF option_value = '' THEN option_value := tpu$k_unspecified; ENDIF; ! Set the option value as if it was done via the portable [RE]SET REPORT ! command. ! sca$report_set_one_option (option_name, option_value); ENDPROCEDURE PROCEDURE sca$report_set_one_option (option_name, option_value) !++ ! FUNCTIONAL DESCRIPTION: ! ! Store an option value from a SET REPORT command. This procedure assumes ! that the caller has already checked that a report name has been set. ! ! FORMAL PARAMETERS: ! ! option_name - the option name (as a string). ! option_value - the option value (as a string). ! ! ROUTINE VALUE: ! ! TRUE if the option was filled in successfully. FALSE if not. ! ! SIDE EFFECTS: ! ! Option variable is updated. !-- LOCAL default_value, full_option_name, option_procedure, prefix, use_default; ON_ERROR [OTHERWISE]: sca$report_common_error_cleanup ("SCA$REPORT_SET_ONE_OPTION"); ENDON_ERROR; prefix := "SCA$REPORT_OPTION_"; IF NOT sca$report_lookup_option (option_name, full_option_name) THEN RETURN FALSE; ENDIF; ! Get the type of the default value for this option. If it's not a string ! (or unspecified), convert the input value to the appropriate type. ! default_value := sca$report_valid_option_array{full_option_name}; option_procedure := sca$report_valid_option_procs{full_option_name}; ! Check for null option value - that means set the default for this option. ! IF GET_INFO (option_value, 'TYPE') = UNSPECIFIED THEN use_default := TRUE; sca$report_temp_value := default_value; ELSE ! An option value was specified - use it. ! use_default := FALSE; sca$report_temp_value := option_value; ENDIF; ! Call the option processing procedure. If none was specified for this ! option, use the standard option processing procedure. ! IF option_procedure = '' THEN option_procedure := 'sca$report_standard_option_processing'; ENDIF; sca$report_temp_result := TRUE; EXECUTE (option_procedure + '("' + full_option_name + '",' + 'sca$report_temp_value,' + STR(use_default) +')' ); IF NOT sca$report_temp_result THEN sca$report_status_message ('Option value not changed'); RETURN FALSE; ENDIF; EXECUTE (prefix + full_option_name + ':= sca$report_temp_value'); RETURN TRUE; ENDPROCEDURE PROCEDURE sca$report_show_one_option (option_name, option_var_name) !++ ! FUNCTIONAL DESCRIPTION: ! ! Display one report option for the current report. This routine checks ! whether the specified option is valid for the current report - if not, ! the option is not displayed and FALSE is returned. ! ! FORMAL PARAMETERS: ! ! option_name - option name, as a string. IN parameter. ! option_var_name - full name of variable containing option value, as a ! string. IN parameter. ! ! IMPLICIT INPUTS: ! ! sca$report_name - current report name ! ! ROUTINE VALUE: ! ! TRUE if option was dislayed successfully. FALSE if not. !-- LOCAL value_type; ON_ERROR [OTHERWISE]: sca$report_common_error_cleanup ("SCA$REPORT_SHOW_ONE_OPTION"); ENDON_ERROR; ! Check that the option name is valid for the current report. ! IF GET_INFO (sca$report_valid_options, 'TYPE') = STRING THEN IF INDEX (sca$report_valid_options_UC, option_name) = 0 THEN RETURN FALSE; ENDIF; ENDIF; execute( "sca$report_temp_value := " + option_var_name); value_type := GET_INFO (sca$report_temp_value, 'TYPE'); ! Check that value is displayable ! IF (value_type <> INTEGER) AND (value_type <> STRING) THEN sca$report_temp_value := ''; ENDIF; sca$report_status_message (option_name + ' : ' + STR(sca$report_temp_value)); RETURN TRUE; ENDPROCEDURE PROCEDURE sca$report_show_option (option_name) !++ ! FUNCTIONAL DESCRIPTION: ! ! Display an option value, or a list of option values, for the SHOW REPORT ! command. ! ! FORMAL PARAMETERS: ! ! option_name - the option name (as a string). May include wildcard ! characters, may be abbreviated. ! ! ROUTINE VALUE: ! ! TRUE if the option was displayed successfully. FALSE if not. !-- LOCAL name_list, next_space, n_names, option_name_UC, prefix, temp_name; ON_ERROR [TPU$_NONAMES, TPU$_MULTIPLENAMES]: ! trap expand_name errors ; [OTHERWISE]: sca$report_common_error_cleanup ("SCA$REPORT_SHOW_OPTION"); ENDON_ERROR; prefix := "SCA$REPORT_OPTION_"; temp_name := prefix + option_name ; name_list := EXPAND_NAME (temp_name, VARIABLES); IF name_list = "" THEN sca$report_status_message ('No such option for current report: ' + option_name + '...'); RETURN FALSE; ENDIF; ! Show the report name every time. ! sca$report_status_message ('Current report is ' + sca$report_name); ! Add a trailing blank to make processing easier. ! name_list := name_list + ' '; ! Get an upcased version of the list of valid option names, and of the ! user's input. ! sca$report_valid_options_UC := CHANGE_CASE (sca$report_valid_options, UPPER, NOT_IN_PLACE); option_name_UC := CHANGE_CASE (option_name, UPPER, NOT_IN_PLACE); ! See if a single valid option name was given as the parameter. If so, ! process it and return. ! IF INDEX (sca$report_valid_options_UC, ' ' + option_name_UC + ' ') <> 0 THEN sca$report_show_one_option (option_name_UC, prefix + option_name); RETURN TRUE; ENDIF; ! For each name in the list, display its name and value, if defined for ! the current report. ! n_names := 0; LOOP next_space := INDEX (name_list, ' '); EXITIF next_space = 0; temp_name := SUBSTR (name_list, 1, next_space-1); IF sca$report_show_one_option (temp_name - prefix, temp_name) THEN n_names := n_names + 1; ENDIF; name_list := SUBSTR (name_list, next_space+1); ENDLOOP; IF n_names = 0 THEN sca$report_status_message ('No such option for current report: ' + option_name + '...'); RETURN FALSE; ENDIF; RETURN TRUE; ENDPROCEDURE !=============================================================================== ! Standard option processing procedures ! ! The procedures below process options from the SET REPORT and RESET REPORT ! commands. Each procedure accepts 3 parameters: ! the full option name, as a string ! the option value ! a flag indicating whether the input value is the default PROCEDURE sca$report_standard_option_processing (option_name, option_value, is_default) !++ ! FUNCTIONAL DESCRIPTION: ! ! Perform standard option processing for options that have no specified ! processing procedure. The standard processing is to attempt to convert ! the option value to an integer if the option default value is an ! integer, otherwise to accept the option value as is. ! ! FORMAL PARAMETERS: ! ! See above. ! ! ROUTINE VALUE: ! ! TRUE if the option value is ok. FALSE if not. !-- LOCAL temp_value; ON_ERROR ! Catch "not an integer" exception. ! [TPU$_INVNUMSTR]: sca$report_temp_result := FALSE; sca$report_status_message ( 'Value of ' + option_name + ' option must be an integer'); RETURN; [OTHERWISE] : sca$report_temp_result := FALSE; sca$report_common_error_cleanup('SCA$REPORT_STANDARD_OPTION_PROCESSING'); ENDON_ERROR; IF GET_INFO (sca$report_valid_option_array{option_name}, 'TYPE') = INTEGER THEN temp_value := INT(option_value); ELSE temp_value := option_value; ENDIF; option_value := temp_value; ENDPROCEDURE PROCEDURE sca$report_process_option_boolean (option_name, option_value, is_default) !++ ! FUNCTIONAL DESCRIPTION: ! ! Process a Boolean option. ! ! FORMAL PARAMETERS: ! ! See above. ! ! ROUTINE VALUE: ! ! TRUE if the option value is ok. FALSE if not. !-- LOCAL temp_value; ON_ERROR [TPU$_INVNUMSTR]: sca$report_temp_result := FALSE; sca$report_status_message ( 'Value of ' + option_name + ' option must be 0 or 1'); RETURN; [OTHERWISE] : sca$report_temp_result := FALSE; sca$report_common_error_cleanup('SCA$REPORT_PROCESS_OPTION_BOOLEAN'); ENDON_ERROR; temp_value := option_value; IF GET_INFO (temp_value, 'TYPE') = STRING THEN temp_value := EDIT (temp_value, COMPRESS, TRIM, UPPER); IF temp_value = 'ON' THEN temp_value := 1; ENDIF; IF temp_value = 'OFF' THEN temp_value := 0; ENDIF; IF temp_value = 'TRUE' THEN temp_value := 1; ENDIF; IF temp_value = 'FALSE' THEN temp_value := 0; ENDIF; ENDIF; temp_value := INT(temp_value); ! Check that the option value is 0 or 1. ! IF (temp_value <> TRUE) AND (temp_value <> FALSE) THEN sca$report_status_message ( 'Value of ' + option_name + ' option must be 0 or 1'); sca$report_temp_result := FALSE; ELSE option_value := temp_value; ENDIF; ENDPROCEDURE PROCEDURE sca$report_process_option_domain_query (option_name, option_value, is_default) !++ ! FUNCTIONAL DESCRIPTION: ! ! Process the DOMAIN option. ! ! FORMAL PARAMETERS: ! ! See above. ! ! ROUTINE VALUE: ! ! TRUE if the domain is ok. FALSE if not. ! ! SIDE EFFECTS: ! ! The query result SCA$REPORT_DOMAIN is created. !-- LOCAL sca_status; ON_ERROR ! Catch "no such query" error. Report the bad domain expression to ! the user and abort the report. ! [sca$_noqueryexists] : IF NOT sca$report_invoked_via_portable THEN sca$do_command (lse$sca_command_context, 'SET COMM LANG VMS'); ENDIF; sca$report_temp_result := FALSE; sca$report_domain_query := ''; sca$report_status_message ('Query ' + option_value + ' (from /DOMAIN qualifier) does not exist' ); RETURN; ! Do normal cleanup for any other errors. ! [OTHERWISE] : IF NOT sca$report_invoked_via_portable THEN sca$do_command (lse$sca_command_context, 'SET COMM LANG VMS'); ENDIF; sca$report_temp_result := FALSE; sca$report_domain_query := ''; sca$report_common_error_cleanup('SCA$REPORT_PROCESS_OPTION_DOMAIN_QUERY'); ENDON_ERROR; ! Associate the query name SCA$REPORT_DOMAIN with the domain query, if one ! was specified. ! sca$report_domain_query := option_value; IF option_value <> '' THEN IF NOT sca$report_invoked_via_portable THEN sca$do_command (lse$sca_command_context, 'SET COMM LANG PORT'); ENDIF; sca_status := sca$do_command (lse$sca_command_context, 'FIND -name SCA$REPORT_DOMAIN ' + '@' + option_value ); IF NOT sca$report_invoked_via_portable THEN sca$do_command (lse$sca_command_context, 'SET COMM LANG VMS'); ENDIF; ENDIF; ENDPROCEDURE PROCEDURE sca$report_process_option_output (option_name, option_value, is_default) !++ ! FUNCTIONAL DESCRIPTION: ! ! Process the OUTPUT option. ! ! FORMAL PARAMETERS: ! ! See above. ! ! ROUTINE VALUE: ! ! TRUE if the option value is ok. FALSE if not. !-- LOCAL temp_file_name; ON_ERROR [tpu$_parsefail] : sca$report_temp_result := FALSE; sca$report_status_message ( MESSAGE_TEXT(sca$_badrptoutput, 0, option_value) ); RETURN; [OTHERWISE] : sca$report_temp_result := FALSE; sca$report_common_error_cleanup('SCA$REPORT_PROCESS_OPTION_OUTPUT'); ENDON_ERROR; ! Parse OUTPUT value, to verify that the option value is for a valid ! file spec. ! temp_file_name := FILE_PARSE(option_value, sca$report_name + "." ); ENDPROCEDURE PROCEDURE sca$report_process_option_formatted_target (option_name, option_value, is_default) !++ ! FUNCTIONAL DESCRIPTION: ! ! Process the TARGET option for reports that generate output to be passed ! through a formatter (DSR or DOCUMENT). ! ! FORMAL PARAMETERS: ! ! See above. ! ! ROUTINE VALUE: ! ! TRUE if the option value is ok. FALSE if not. !-- LOCAL temp_value; ON_ERROR [OTHERWISE] : sca$report_temp_result := FALSE; sca$report_cmd_error_cleanup('SCA$REPORT_PROCESS_OPTION_FORMATTED_TARGET'); RETURN; ENDON_ERROR; IF (option_value = 'TEXT') OR (option_value = 'TXT') THEN sca$report_target_index := sca$report_k_target_text; sca$report_file_type_default := 'TXT'; ELSE IF (option_value = 'RUNOFF') OR (option_value = 'RNO') OR (option_value = 'DSR') THEN sca$report_target_index := sca$report_k_target_runoff; sca$report_file_type_default := 'RNO'; ELSE IF (option_value = 'DOCUMENT') OR (option_value = 'SDML') THEN sca$report_target_index := sca$report_k_target_document; sca$report_file_type_default := 'SDML'; ELSE sca$report_status_message ('Target ' + option_value + ' is not valid for this report'); sca$report_temp_result := FALSE; ENDIF; ENDIF; ENDIF; ENDPROCEDURE PROCEDURE sca$report_process_option_number_or_all (option_name, option_value, is_default) !++ ! FUNCTIONAL DESCRIPTION: ! ! Process an option whose value is either a number (> 0) or the string "ALL". ! ! FORMAL PARAMETERS: ! ! See above. ! ! ROUTINE VALUE: ! ! TRUE if the option value is ok. FALSE if not. !-- LOCAL option_ok, temp_value; ON_ERROR [TPU$_INVNUMSTR]: sca$report_temp_result := FALSE; sca$report_status_message ( 'Value of ' + option_name + ' option must be a number or ALL'); RETURN; [OTHERWISE] : sca$report_temp_result := FALSE; sca$report_common_error_cleanup('SCA$REPORT_PROCESS_OPTION_NUMBER_OR_ALL'); ENDON_ERROR; option_ok := FALSE; IF GET_INFO (option_value, 'TYPE') = STRING THEN option_value := EDIT (option_value, COMPRESS, TRIM, UPPER); IF option_value = 'ALL' THEN option_ok := TRUE; ENDIF; ENDIF; IF NOT option_ok THEN ! Try to process it as an integer. The ON_ERROR code will handle it ! if it's not actually an integer. ! option_value := INT (option_value); IF (option_value > 0) THEN option_ok := TRUE; ENDIF; ENDIF; IF option_ok THEN ! Convert option value to string, so it can be used in building query ! expression. ! option_value := STR (option_value); ELSE sca$report_status_message ( 'Value of ' + option_name + ' option must be a number or ALL'); sca$report_temp_result := FALSE; ENDIF; ENDPROCEDURE ENDMODULE