{
    "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.CALL_VISIT' to DictCallVisitTable else\r\n   Void = msg( '', 'Unable to open DICT.CALL_VISIT...' )\r\n   return 0\r\nend\r\nSearchStr = ''\r\nCustIds       = .customer_info->array<1>\r\nCustContacts  = .contact_ids->array<1>\r\nCVDateFrom    = .call_visit_date_from->text\r\nCVDateThru    = .call_visit_date_thru->text\r\nActive        = .active_check->check\r\nNotActive     = .not_active_check->check\r\nAttendBy      = .attend_by->array<1>\r\nSubject       = .subject->text\r\nswap @vm:@vm with '' in CustIds\r\nif CustIds[-1,1] = @vm then CustIds[-1,1] = ''\r\nswap @vm:@vm with '' in CustContacts\r\nif CustContacts[-1,1] = @vm then CustContacts[-1,1] = ''\r\nswap @vm:@vm with '' in AttendBy\r\nif AttendBy[-1,1] = @vm then AttendBy[-1,1] = ''\r\nif CustIds then\r\n    SearchStr<-1> = 'CUST_ID':@vm:CustIds\r\nend\r\nif AttendBy then\r\n    SearchStr<-1> = 'ATTENDED_BY':@vm:AttendBy\r\nend\r\nif CustContacts then\r\n    SearchStr<-1> = 'NAME_IDS':@vm:CustContacts\r\nend\r\nif CVDateFrom and CVDateThru then\r\n    SearchStr<-1> = 'CALL_VISIT_DATE':@vm:CVDateFrom:'...':CVDateThru\r\nend else\r\n\tif CVDateFrom then\r\n\t    SearchStr<-1> = 'CALL_VISIT_DATE':@vm:'>=':CVDateFrom\r\n\tend\r\n\tif CVDateThru then\r\n\t    SearchStr<-1> = 'CALL_VISIT_DATE':@vm:'<=':CVDateThru\r\n\tend\r\nend\r\nActiveStatusVar = ''\r\nif Active then\r\n    ActiveStatusVar<1,-1> = 1\r\nend\r\nif NotActive then\r\n    ActiveStatusVar<1,-1> = 0\r\nend\r\nif ActiveStatusVar then\r\n   SearchStr<-1> = 'ACTIVE':@vm:ActiveStatusVar\r\nend\r\nif Subject <> '' then\r\n   SearchStr<-1> = 'SUBJECT_XREF':@vm:Subject\r\nend\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, 'CALL_VISIT', DictCallVisitTable, Keys, '', Flag )\r\n    if Flag <> 0 then\r\n       Void = msg( '', 'Error while extracting CALL_VISIT 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, 'CALL_VISIT', 'CUST_NAME':@fm:'#CALL_VISIT_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"
        }
    }
}