Alpha Video Training
Results 1 to 6 of 6

Thread: How do I subtract one property array from another to find the missing entries

  1. #1
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    771

    Default How do I subtract one property array from another to find the missing entries

    I have two property Arrays LogdataReg and DisplayReg.

    DisplayReg may or may not have the same records as LogDataReg.

    How do I subtract DisplayReg from LogDataReg to get the Missing Entries that are in LogDataReg but not in DisplayReg?

    I am only interested in the first field "REG" of each record for use in the comparison. In the sample setup the Missing Entries are "MISSING1" and "MISSING2".

    I have been trawling through Table of Contents in the Alpha Five Documentation, but cannot find anything that might do it.

    'setup test data
    dim shared DisplayData as c = <<%a%
    4X-EDM|4X-EDM||ISRAEL|01|02/10/2019|{PAGANHILL SBS}
    9H-QAC|EI-FZS||MALTA|01|19/05/2017|{PAGANHILL SBS}
    A7-ANA|A7-ANA||QATAR|01|02/10/2019|{PAGANHILL SBS}
    D-ABYI|D-ABYI||GERMANY|01|16/03/2014|{PAGANHILL SBS}
    EC-MII|EC-MII||SPAIN|01|02/10/2019|{PAGANHILL SBS}
    EI-EKX|EI-EKX||IRELAND||03/11/2016|{PAGANHILL SBS}
    EI-LRB|EI-LRB||IRELAND|01|02/10/2019|{PAGANHILL SBS}
    G-BDZD|G-BDZD||UK|01|02/10/2019|{PAGANHILL SBS}
    G-BOYF|G-BOYF||UK|01|02/10/2019|{PAGANHILL SBS}
    G-IZZT|G-IZZT||UK|01|07/07/2018|KEMBLE
    G-NEOV|G-NEOV||UK|01|02/10/2019|{PAGANHILL SBS}
    G-SUEI|G-SUEI||UK|01|29/08/2019|STAVERTON
    G-XWBB|G-XWBB||UK|01|02/10/2019|{PAGANHILL SBS}
    HB-JCT|HB-JCT||SWITZERLAND|01|02/10/2019|{PAGANHILL SBS}
    N1F|N1F||USA|01|02/10/2019|{PAGANHILL SBS}
    N536LA|N536LA||COLOMBIA|01|02/10/2019|{PAGANHILL SBS}
    TC-JYM|TC-JYM||TURKEY|01|02/10/2019|{PAGANHILL SBS}
    %a%
    dim shared LogData as c = <<%a%
    MISSING1|MISSING1|||02/10/2019|01|{PAGANHILL SBS}
    MISSING2|MISSING2|||02/10/2019|01|{PAGANHILL SBS}
    4X-EDM|4X-EDM|||02/10/2019|01|{PAGANHILL SBS}
    D-ABYI|D-ABYI|||02/10/2019|01|{PAGANHILL SBS}
    A7-ANA|A7-ANA|||02/10/2019|01|{PAGANHILL SBS}
    G-NEOV|G-NEOV|||02/10/2019|01|{PAGANHILL SBS}
    N536LA|N536LA|||02/10/2019|01|{PAGANHILL SBS}
    TC-JYM|TC-JYM|||02/10/2019|01|{PAGANHILL SBS}
    EC-MII|EC-MII|||02/10/2019|01|{PAGANHILL SBS}
    9H-QAC|9H-QAC|||02/10/2019|01|{PAGANHILL SBS}
    G-BDZD|G-BDZD|||02/10/2019|01|{PAGANHILL SBS}
    EI-LRB|EI-LRB|||02/10/2019|01|{PAGANHILL SBS}
    EI-EKX|EI-EKX|||02/10/2019|01|{PAGANHILL SBS}
    G-BOYF|G-BOYF|||02/10/2019|01|{PAGANHILL SBS}
    G-IZZT|G-IZZT|||02/10/2019|01|{PAGANHILL SBS}
    G-SUEI|G-SUEI|||02/10/2019|01|{PAGANHILL SBS}
    N1F|N1F|||02/10/2019|01|{PAGANHILL SBS}
    G-XWBB|G-XWBB|||02/10/2019|01|{PAGANHILL SBS}
    HB-JCT|HB-JCT|||02/10/2019|01|{PAGANHILL SBS}
    %a%
    dd = *count(DisplayData)
    ld = *count(LogData)
    trace.clear()
    dim shared DisplayReg[dd] as p
    dim shared LogdataReg[ld] as p
    DisplayReg.initialize_properties("reg|as|code|Country|H|When|where",DisplayData)
    LogDataReg.initialize_properties("reg|as|code|Country|H|When|where",LogData)
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

  2. #2
    "Certified" Alphaholic
    Real Name
    Gregg Schmidt
    Join Date
    Mar 2001
    Location
    Milwaukee
    Posts
    1,381

    Default Re: How do I subtract one property array from another to find the missing entries

    Hi Graham,

    Here is one solution.
    I hope you don't mind but I did make a few changes for my sanity.
    This code will put the missing regs into the missingList.
    I changed missing1 and missing2 just to make things easier on my over-worked brain.

    Gregg
    Code:
    'setup test data
    
    dim shared DisplayReg[0] as p
    dim shared LogdataReg[0] as p
    dim shared LogData as c
    dim shared DisplayData as c 
    dim missingList as c
    dim checkList as c
    DisplayData = <<%a%
    4X-EDM|4X-EDM||ISRAEL|01|02/10/2019|{PAGANHILL SBS}
    9H-QAC|EI-FZS||MALTA|01|19/05/2017|{PAGANHILL SBS}
    A7-ANA|A7-ANA||QATAR|01|02/10/2019|{PAGANHILL SBS}
    D-ABYI|D-ABYI||GERMANY|01|16/03/2014|{PAGANHILL SBS}
    EC-MII|EC-MII||SPAIN|01|02/10/2019|{PAGANHILL SBS}
    EI-EKX|EI-EKX||IRELAND||03/11/2016|{PAGANHILL SBS}
    EI-LRB|EI-LRB||IRELAND|01|02/10/2019|{PAGANHILL SBS}
    G-BDZD|G-BDZD||UK|01|02/10/2019|{PAGANHILL SBS}
    G-BOYF|G-BOYF||UK|01|02/10/2019|{PAGANHILL SBS}
    G-IZZT|G-IZZT||UK|01|07/07/2018|KEMBLE
    G-NEOV|G-NEOV||UK|01|02/10/2019|{PAGANHILL SBS}
    G-SUEI|G-SUEI||UK|01|29/08/2019|STAVERTON
    G-XWBB|G-XWBB||UK|01|02/10/2019|{PAGANHILL SBS}
    HB-JCT|HB-JCT||SWITZERLAND|01|02/10/2019|{PAGANHILL SBS}
    N1F|N1F||USA|01|02/10/2019|{PAGANHILL SBS}
    N536LA|N536LA||COLOMBIA|01|02/10/2019|{PAGANHILL SBS}
    TC-JYM|TC-JYM||TURKEY|01|02/10/2019|{PAGANHILL SBS}
    %a%
    LogData = <<%a%
    HA-HA|HA-HA|||02/10/2019|01|{PAGANHILL SBS}
    HOA-HOA|HOA-HOA|||02/10/2019|01|{PAGANHILL SBS}
    4X-EDM|4X-EDM|||02/10/2019|01|{PAGANHILL SBS}
    D-ABYI|D-ABYI|||02/10/2019|01|{PAGANHILL SBS}
    A7-ANA|A7-ANA|||02/10/2019|01|{PAGANHILL SBS}
    G-NEOV|G-NEOV|||02/10/2019|01|{PAGANHILL SBS}
    N536LA|N536LA|||02/10/2019|01|{PAGANHILL SBS}
    TC-JYM|TC-JYM|||02/10/2019|01|{PAGANHILL SBS}
    EC-MII|EC-MII|||02/10/2019|01|{PAGANHILL SBS}
    9H-QAC|9H-QAC|||02/10/2019|01|{PAGANHILL SBS}
    G-BDZD|G-BDZD|||02/10/2019|01|{PAGANHILL SBS}
    EI-LRB|EI-LRB|||02/10/2019|01|{PAGANHILL SBS}
    EI-EKX|EI-EKX|||02/10/2019|01|{PAGANHILL SBS}
    G-BOYF|G-BOYF|||02/10/2019|01|{PAGANHILL SBS}
    G-IZZT|G-IZZT|||02/10/2019|01|{PAGANHILL SBS}
    G-SUEI|G-SUEI|||02/10/2019|01|{PAGANHILL SBS}
    N1F|N1F|||02/10/2019|01|{PAGANHILL SBS}
    G-XWBB|G-XWBB|||02/10/2019|01|{PAGANHILL SBS}
    HB-JCT|HB-JCT|||02/10/2019|01|{PAGANHILL SBS}
    %a%
    '''dd = *count(DisplayData)
    '''ld = *count(LogData)
    '''trace.clear()
    DisplayReg.initialize_properties("reg|as|code|Country|H|When|where",DisplayData)
    LogDataReg.initialize_properties("reg|as|code|Country|H|When|where",LogData) 
    LogdataReg.sort("A","reg")
    DisplayReg.sort("A","reg")
    
    for n = 1 to LogdataReg.size()
    	checkList = checkList+ LogdataReg[n].reg+crlf()
    next n
    debug(1)
    
    for each logreg in checkList
    	if DisplayReg.findI(logreg.value,"reg")=0 then
    		missingList = missingList+logreg.value+crlf()
    	end if
    next
    end

  3. #3
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    771

    Default Re: How do I subtract one property array from another to find the missing entries

    Thanks Gregg,

    nearly there.

    My Fault, I should have said that although I am only interested in the first field "REG" of each record for use in the comparison, I require the whole record to be in the Missing Entries array, not just the REG field.
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

  4. #4
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    771

    Default Re: How do I subtract one property array from another to find the missing entries

    Stumbled upon my own solution:

    Code:
    dim shared MyDisplayReg as U
    dim shared MyLogdataReg as U
    dim shared MissingReg[0] as c
    MyDisplayReg.initialize("1|2|3|4|5|6","1","1|2|3|4|5|6",DisplayData)
    MyLogDataReg.initialize("1|2|3|4|5|6","1","1|2|3|4|5|6",LogData)
    	KeyVal = myLogDataReg.first()
    	for n = 1 to MyLogdataReg.size()
    			Data = MyLogdataReg.get(KeyVal)
    			if .not. MyDisplayReg.exist(word(data,1,"|")) then
    				MissingReg[] = Data
    			end if	
    			KeyVal = MyLogdataReg.next(KeyVal)
    	next
    showvar(MissingReg.dump())
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

  5. #5
    "Certified" Alphaholic
    Real Name
    Gregg Schmidt
    Join Date
    Mar 2001
    Location
    Milwaukee
    Posts
    1,381

    Default Re: How do I subtract one property array from another to find the missing entries

    ok...just a minor change.
    Try this code.
    [code]
    DisplayReg.initialize_properties("reg|as|code|Country|H|When|where",DisplayData)
    LogDataReg.initialize_properties("reg|as|code|Country|H|When|where",LogData)
    '''LogdataReg.sort("A","reg")
    '''DisplayReg.sort("A","reg")
    '''for n = 1 to LogdataReg.size()
    ''' checkList = checkList+ LogdataReg[n].reg+"|"+convert_type(n,"C")+crlf()
    '''next n

    for each logreg in LogData
    ''' if DisplayReg.findI(logreg.value,"reg")=0 then
    if DisplayReg.findI(left(logreg.value,at("|",logreg.value)-1),"reg")=0 then
    missingList = missingList+logreg.value+crlf()
    end if
    next
    debug(1)
    ' The code below will add the missing items to the DisplayReg array.
    '''DisplayReg.initialize_properties("reg|as|code|Country|H|When|where",missingList,.t.)

    ' Uncomment the code below here to verify the missing data as been added to DisplayReg array.
    '''missingList = ""
    '''for each logreg in LogData
    ''' if DisplayReg.findI(left(logreg.value,at("|",logreg.value)-1),"reg")=0 then
    ''' missingList = missingList+logreg.value+crlf()
    ''' end if
    '''next
    end
    [\code]

  6. #6
    "Certified" Alphaholic
    Real Name
    Gregg Schmidt
    Join Date
    Mar 2001
    Location
    Milwaukee
    Posts
    1,381

    Default Re: How do I subtract one property array from another to find the missing entries

    Graham,

    Sometimes my best efforts are afterthoughts.
    This (in my opinion) is cleaner and easier to follow.
    I presumed you were going to add the missing logdataregs to the displayRegs, so I included the code to do that.

    Code:
    'setup test data
    
    dim shared DisplayReg[0] as p
    dim shared LogdataReg[0] as p
    dim shared LogData as c
    dim shared DisplayData as c 
    dim missingList as c
    dim checkList as c
    dim testList as c
    DisplayData = <<%a%
    4X-EDM|4X-EDM||ISRAEL|01|02/10/2019|{PAGANHILL SBS}
    9H-QAC|EI-FZS||MALTA|01|19/05/2017|{PAGANHILL SBS}
    A7-ANA|A7-ANA||QATAR|01|02/10/2019|{PAGANHILL SBS}
    D-ABYI|D-ABYI||GERMANY|01|16/03/2014|{PAGANHILL SBS}
    EC-MII|EC-MII||SPAIN|01|02/10/2019|{PAGANHILL SBS}
    EI-EKX|EI-EKX||IRELAND||03/11/2016|{PAGANHILL SBS}
    EI-LRB|EI-LRB||IRELAND|01|02/10/2019|{PAGANHILL SBS}
    G-BDZD|G-BDZD||UK|01|02/10/2019|{PAGANHILL SBS}
    G-BOYF|G-BOYF||UK|01|02/10/2019|{PAGANHILL SBS}
    G-IZZT|G-IZZT||UK|01|07/07/2018|KEMBLE
    G-NEOV|G-NEOV||UK|01|02/10/2019|{PAGANHILL SBS}
    G-SUEI|G-SUEI||UK|01|29/08/2019|STAVERTON
    G-XWBB|G-XWBB||UK|01|02/10/2019|{PAGANHILL SBS}
    HB-JCT|HB-JCT||SWITZERLAND|01|02/10/2019|{PAGANHILL SBS}
    N1F|N1F||USA|01|02/10/2019|{PAGANHILL SBS}
    N536LA|N536LA||COLOMBIA|01|02/10/2019|{PAGANHILL SBS}
    TC-JYM|TC-JYM||TURKEY|01|02/10/2019|{PAGANHILL SBS}
    %a%
    LogData = <<%a%
    HA-HA|HA-HA|||02/10/2019|01|{PAGANHILL SBS}
    HOA-HOA|HOA-HOA|||02/10/2019|01|{PAGANHILL SBS}
    4X-EDM|4X-EDM|||02/10/2019|01|{PAGANHILL SBS}
    D-ABYI|D-ABYI|||02/10/2019|01|{PAGANHILL SBS}
    A7-ANA|A7-ANA|||02/10/2019|01|{PAGANHILL SBS}
    G-NEOV|G-NEOV|||02/10/2019|01|{PAGANHILL SBS}
    N536LA|N536LA|||02/10/2019|01|{PAGANHILL SBS}
    TC-JYM|TC-JYM|||02/10/2019|01|{PAGANHILL SBS}
    EC-MII|EC-MII|||02/10/2019|01|{PAGANHILL SBS}
    9H-QAC|9H-QAC|||02/10/2019|01|{PAGANHILL SBS}
    G-BDZD|G-BDZD|||02/10/2019|01|{PAGANHILL SBS}
    EI-LRB|EI-LRB|||02/10/2019|01|{PAGANHILL SBS}
    EI-EKX|EI-EKX|||02/10/2019|01|{PAGANHILL SBS}
    G-BOYF|G-BOYF|||02/10/2019|01|{PAGANHILL SBS}
    G-IZZT|G-IZZT|||02/10/2019|01|{PAGANHILL SBS}
    G-SUEI|G-SUEI|||02/10/2019|01|{PAGANHILL SBS}
    N1F|N1F|||02/10/2019|01|{PAGANHILL SBS}
    G-XWBB|G-XWBB|||02/10/2019|01|{PAGANHILL SBS}
    HB-JCT|HB-JCT|||02/10/2019|01|{PAGANHILL SBS}
    %a%
    '''dd = *count(DisplayData)
    '''ld = *count(LogData)
    '''trace.clear()
    DisplayReg.initialize_properties("reg|as|code|Country|H|When|where",DisplayData)
    LogDataReg.initialize_properties("reg|as|code|Country|H|When|where",LogData) 
    
    for n = 1 to LogdataReg.size()
    	if DisplayReg.findI(LogdataReg[n].reg,"reg")=0 then	
    		missingList = missingList+LogdataReg[n].reg+ "|" +LogdataReg[n].as+ "|" +LogdataReg[n].code+ "|" +LogdataReg[n].Country+ "|" +LogdataReg[n].H+ "|" +LogdataReg[n].When+ "|" +LogdataReg[n].Where+crlf()
    	end if
    next n
    debug(1)
    ' The code below will add the missing items to the DisplayReg array.
    DisplayReg.initialize_properties("reg|as|code|Country|H|When|where",missingList,.t.)
    end

Similar Threads

  1. Replies: 0
    Last Post: 07-15-2014, 01:11 AM
  2. Find index of property array
    By kkfin in forum Application Server Version 11 - Web/Browser Applications
    Replies: 1
    Last Post: 12-01-2012, 06:37 AM
  3. Get property array directly from request object. Not possible?
    By kkfin in forum Application Server Version 10 - Web/Browser Applications
    Replies: 1
    Last Post: 04-24-2012, 02:02 PM
  4. Multidimensional property array??
    By Pat Bremkamp in forum Application Server Version 10 - Web/Browser Applications
    Replies: 1
    Last Post: 01-18-2010, 05:06 PM
  5. *for_each() property array enhancement
    By csda1 in forum Archived Wishlist
    Replies: 3
    Last Post: 05-03-2007, 10:02 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •