{
    "header": {
        "version": 1,
        "type": "record"
    },
    "body": {
        "record1": {
            "<1>": "declare subroutine btree.extract, update_index, rlist, end_dialog\r\ndeclare function msg, key_sort, utility\r\n$insert lsl_users_equ\r\n$insert msg_equates\r\n\r\nopen 'DICT.NCR' to DictNCRTable else\r\n   Void = msg( '', 'Unable to open DICT.NCR...' )\r\n   return 0\r\nend\r\nSearchStr     = ''\r\nNCRDateFrom   = .ncr_date_from->text\r\nNCRDateThru   = .ncr_date_thru->text\r\nRDSIds        = .rds_ids->array\r\nShifts        = .shift->text\r\nDeptsResp     = .departmentresp->text\r\n*\r\nMPost         = .mpost_check->check\r\nMPre          = .mpre_check->check\r\nCPost         = .cpost_check->check\r\nCPre          = .cpre_check->check\r\n*\r\n* need to convert field to value markers as the text property will \r\n* be field mark delimited if more than one is choosen\r\nconvert @fm to @vm in Shifts\r\nconvert @fm to @vm in DeptsResp\r\n\r\n* NCR status variables\r\nOpen          = .open_check->check\r\nClosed        = .closed_check->check\r\nVerified      = .verified_check->check\r\n\r\nswap @vm:@vm with '' in RDSIds\r\nif RDSIds[-1,1] = @vm then RDSIds[-1,1] = ''\r\nif RDSIds then\r\n    SearchStr<-1> = 'RDS_ID':@vm:RDSIds\r\nend\r\n\r\nif NCRDateFrom and NCRDateThru then\r\n    SearchStr<-1> = 'ENTRY_DATE':@vm:NCRDateFrom:'...':NCRDateThru\r\nend else\r\n\tif NCRDateFrom then\r\n\t    SearchStr<-1> = 'ENTRY_DATE':@vm:'>=':NCRDateFrom\r\n\tend\r\n\tif NCRDateThru then\r\n\t    SearchStr<-1> = 'ENTRY_DATE':@vm:'<=':NCRDateThru\r\n\tend \r\nend\r\n\r\n* NCR status\r\nNCRStatusVar = ''\r\nif Open then\r\n    NCRStatusVar<1,-1> = 'O'\r\nend\r\nif Closed then\r\n    NCRStatusVar<1,-1> = 'C'\r\nend\r\nif Verified then\r\n    NCRStatusVar<1,-1> = 'V'\r\nend\r\nif NCRStatusVar then\r\n   SearchStr<-1> = 'STATUS':@vm:NCRStatusVar\r\nend\r\n\r\n* Shifts\r\nif Shifts <> '' then\r\n   SearchStr<-1> = 'SHIFT':@vm:Shifts\r\nend\r\n\r\n* Responsible Departments\r\nif DeptsResp <> '' then\r\n   SearchStr<-1> = 'DEPT_RESP':@vm:DeptsResp\r\nend\r\n\r\n* Reject Types\r\nRejTypeVar = ''\r\nif MPost then\r\n   RejTypeVar<1,-1> = 'L_POST_REJ_CNT'\r\nend\r\nif MPre then\r\n   RejTypeVar<1,-1> = 'L_PRE_REJ_CNT'\r\nend\r\nif CPost then\r\n   RejTypeVar<1,-1> = 'C_POST_REJ_CNT'\r\nend\r\nif CPre then\r\n   RejTypeVar<1,-1> = 'C_PRE_REJ_CNT'\r\nend\r\nif RejTypeVar <> '' then\r\n   SearchStr<-1> = 'REJ_CNT_FIELD':@vm:RejTypeVar\r\nend\r\n\r\nif SearchStr then\r\n    SearchStr := @fm\r\n    Void = utility( 'CURSOR', 'H' )\r\n    * do a btree.extract\r\n    btree.extract( SearchStr, 'NCR', DictNCRTable, Keys, '', Flag )\r\n    if Flag <> 0 then\r\n       Void = msg( '', 'Error while extracting NCR records...' )\r\n       return 0\r\n    end\r\n    if Keys then\r\n       convert @vm to @fm in Keys\r\n       Keys = key_sort( Keys, 'NCR', '#ENTRY_DATE', 1 )\r\n       end_dialog( @window, Keys )\r\n    end else\r\n       MsgInfo = ''\r\n       MsgInfo<mtext$> = 'No records found meeting your criteria...' \r\n       MsgInfo<micon$> = '!'\r\n       Void = msg( '', MsgInfo )\r\n    end\r\n    Void = utility( 'CURSOR', 'A' )\r\nend else\r\n    MsgInfo = ''\r\n    MsgInfo<mtext$> = 'You have not entered any search criteria...' \r\n    MsgInfo<micon$> = '!'\r\n    Void = msg( '', MsgInfo )\r\nend\r\nreturn 0\r\n\r\n"
        }
    }
}