! crs_reserve_prr.scp reb, 19-Jan-1990 07:12 !PURPOSE: to select previous reservation in file for current ROOM .label begin decimal i get #prevkey=#lastkey=#firstkey=#nextkey=#old_dt="" get #cpref=$crs_last_used:8 get #sroom=crs_reserve.room[$crs_last_used] get #display_msg=- "Searching for previous reservation for '" #sroom "' . . . " get oa$display=#display_msg\force .label id_first_key get #firstkey="" for first crs_reserve with .crs_key:8 beginning #cpref and - .crs_key:30:30 beginning #sroom do - get #firstkey=.crs_key .if #firstkey:8 nes #cpref:8 or #firstkey eqs "" then - .goto decrement .label id_last_key get #lastkey=$crs_last_used .if #firstkey eqs #lastkey then .goto decrement .label loop_one get #prevkey="" for crs_reserve with - .crs_key:8 beginning #cpref and - .crs_key lts #lastkey and - .crs_key:30:30 beginning #sroom do - get #prevkey=.crs_key .if #prevkey:8 gts #cpref then .goto decrement .if #prevkey nes "" then .goto found .goto decrement .label found get $crs_last_used=#prevkey get #display_msg=- "The previous reservation for '" #sroom "' has been selected." get oa$display=#display_msg .goto exit_procedure .label decrement display Checking previous day's date...\force get #nextkey=crs_reserve:crs_key.%next[""] .if #cpref:8 lts #nextkey:8 or - #nextkey eqs $crs_last_used then - .goto top_of_file get #date=oa$date_nbs:8 get #cyr = #date:4 get #cmon = #date:2:4 get #cday = #date:2:6 compute #cday=#cday-8 .if #cday gts "1" then .goto build_date .label check_day compute #cmon=#cmon-1 .if #cmon gts "1" then .goto add_more_days get #cmon="12" compute #cyr=#cyr-1 .label add_more_days .if #cmon eq 1 or #cmon eq 3 or #cmon eq 5 or #cmon eq 7 - or #cmon eq 8 or #cmon eq 10 or #cmon eq 12 then - compute #cday=#cday+31 - else .if #cmon eq 4 or #cmon eq 6 or #cmon eq 9 or #cmon eq 11 then - compute #cday=#cday+30 else - compute #cday=#cday+29 .label build_date .if #cday:1:1 eqs "" then get #cday="0" #cday .if #cmon:1:1 eqs "" then get #cmon="0" #cmon get #firstdate=#cyr:4 #cmon:2 #cday:2 .if #cpref lts #firstdate then .goto top_of_file get #bday=#nextkey:8 .label calc_prev_date get #pyr=#cpref:4 get #pmon=#cpref:2:4 get #pday=#cpref:2:6 compute #pday=#pday-1 .if #pday gts "1" then .goto build_prev_date .label check_prev_day compute #pmon=#pmon-1 .if #pmon gts "1" then .goto add_more_prev_days get #pmon="12" compute #pyr=#pyr-1 .label add_more_prev_days .if #pmon eq 1 or #pmon eq 3 or #pmon eq 5 or #pmon eq 7 - or #pmon eq 8 or #pmon eq 10 or #pmon eq 12 then - compute #pday=#pday+31 - else .if #pmon eq 4 or #pmon eq 6 or #pmon eq 9 or #pmon eq 11 then - compute #pday=#pday+30 else - compute #pday=#pday+29 .label build_prev_date .if #pday:1:1 eqs "" then get #pday="0" #pday .if #pmon:1:1 eqs "" then get #pmon="0" #pmon get #cpref=#pyr:4 #pmon:2 #pday:2 .if #cpref lts #firstdate then .goto top_of_file get #bday=#nextkey:8 date_convert #old_dt,#cpref,9 get oa$display="Checking " #old_dt " . . . "\force .label loop_two get #prevkey="" for crs_reserve with - .crs_key:8 beginning #cpref and - .crs_key:30:30 beginning #sroom do - get #prevkey=.crs_key .if #prevkey nes "" then .goto found .goto id_first_key .label top_of_file oa$msg_purge get oa$display=- "You have reached the first reservation for room '" #sroom "'." .goto exit_procedure .label exit_procedure .exit