MODULE getyear_other; ! This module defines the subroutine that peruses ! a text string to find a year followed by a right paren INCLUDE FILE 'getyear.scn_inc'; ! this string variable is defined at the module level ! so that it can be used by the macro and the procedure; ! also, it becomes automatically is declared static ! so that its storage is still available for the calling program DECLARE four_digit_year: FIXED STRING(4); SET digit ( '0' .. '9' ); SET year_ender ( ')' OR ']' ); TOKEN century { '19' | '18' | '17' }; TOKEN prefix { '/' | '-' }; TOKEN year { digit digit }; TOKEN end_of_year { year_ender }; MACRO return_year TRIGGER { { cen: century | pfx: prefix } yy: year end_of_year }; ! if a prefix was matched, rather than century, ! cen will be empty, so assume the 20th century IF cen = '' THEN cen = '19'; END IF; four_digit_year = cen & yy; STOP SCAN; END MACRO; /* return_year PROCEDURE getyear ( field_text: VARYING STRING( str_param_len ) ) OF FIXED STRING( year_len ); DECLARE who_cares: FIXED STRING(1); four_digit_year = ''; START SCAN INPUT STRING field_text OUTPUT STRING who_cares; RETURN( four_digit_year ); END PROCEDURE; /* scan_for_year END MODULE; /* getyear_other