Thanks Valdemar
I ended up with a similar approach using the g.members:
dim g as ABGroupMBS
if hGroup <> "" then
g = Get_ABGroup(hGroup)
end
dim actioMembers() as ABPersonMBS = g.members
dim rMembers() as ABPersonMBS
for each member as ABPersonMBS in actioMembers
dim fn as string = member.valueForProperty(a.kABFirstNameProperty)
dim mn as string = member.valueForProperty(a.kABMiddleNameProperty)
dim ln as string = member.valueForProperty(a.kABLastNameProperty)
dim matched as boolean = true
for each name as string in names
//exit if name is not matched by at least one of fn, mn, ln
if instr(fn, name) > 0 or instr(mn, name) > 0 or instr(ln, name) > 0
then
Continue
else
matched = false
exit
end
next
if matched = true then
rMembers.append member
end
next
ListOwners( rMembers, hGroup )
This now works fast enough to search for names on the fly.
Regards
Jim
>
> ------------------------------
>
> Message: 2
> Date: Wed, 16 May 2012 14:24:30 +0200
> From: Valdemar De SOUSA <[email protected]>
> Subject: Re: [MBS] Filter addressBook names within a Group
> To: [email protected]
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=us-ascii
>
>> Am 15.05.2012 um 21:39 schrieb Jim Pitchford:
>>
>>>
>>> s1=g.searchElementForProperty(a.kABLastNameProperty,"","",names(i),a.kABContainsSubStringCaseInsensitive)
>>
>> Please use a.searchElementForPersonProperty here.
>> g.searchElementForProperty is same as a.searchElementForGroupProperty, which
>> does not help here.
>>
>>> But this is producing a nil result for s.
>>>
>>> The examples in MBS don't seem to cover this type of application.
>>>
>>> Can anyone spot what I am doing wrong?
>>
>>
>> I tried the same thing, but it fails here, too.
>> Sorry, no idea why this fails.
>>
>> Greetings
>> Christian
> Maybe try this :
>
> dim a As new abaddressbookMBS
>
> dim ga() as ABGroupMBS = a.groups
>
> dim name_group as string
> dim name_user as string
>
> for each g as ABGroupMBS in ga
>
> name_group=g.valueForProperty(a.kABGroupNameProperty)
>
> if name_group = "VDSC" then // Change here the name of the Group that you
> want
>
> dim pa() as ABPersonMBS = g.members
>
> for each p as ABPersonMBS in pa
>
> name_user=p.valueForProperty(a.kABTitleProperty)+" "+
> p.valueForProperty(a.kABFirstNameProperty)+"
> "+p.valueForProperty(a.kABLastNameProperty)
>
> if name_user = " " then
> name_user = p.valueForProperty(a.kABOrganizationProperty)
> end if
> dim i As Integer = PopUsersAB.ListCount+1
>
> PopUsersAB.AddRow name_user
> next
> PopUsersAB.ListIndex = 0
> exit
> end
>
> next
>
> Regards
> Valdemar
>
> ------------------------------
>
> Message: 3
> Date: Wed, 16 May 2012 10:14:04 -0500
> From: Jim Pitchford <[email protected]>
> Subject: [MBS] Re: Mbsplugins_monkeybreadsoftware.info Digest, Vol
> 389, Issue 2
> To: [email protected]
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=windows-1252
>
> Christian
>
> I tried your suggestions - but no luck. By using
> s1=a.searchElementForPersonProperty ∑ instead of g.searchElementForProperty -
> it its now searching the entire AddressBook rather than just the desired
> Group.
>
> So I also tried:
>
> //create the seach elements for last, first and middlenames
> for i as integer = 0 to names.ubound
>
> s1=a.searchElementForPersonProperty(a.kABLastNameProperty,"","",names(i),a.kABContainsSubStringCaseInsensitive)
>
> s2=a.searchElementForPersonProperty(a.kABFirstNameProperty,"","",names(i),a.kABContainsSubStringCaseInsensitive)
>
> s3=a.searchElementForPersonProperty(a.kABMiddleNameProperty,"","",names(i),a.kABContainsSubStringCaseInsensitive)
>
> dim children() as ABSearchElementMBS = array(s1, s2, s3)
>
> //combine those element for this name
> sE(i) = a.searchElementForConjunction(cOR, children)
>
> next i
>
> sE(names.ubound+1) =
> a.searchElementForGroupProperty(a.kABGroupNameProperty, "", "", hGroup,
> a.kABEqualCaseInsensitive)
>
> end
>
> //now combine all the search elements for all names
>
> s = a.searchElementForConjunction(cAND, sE)
>
> if s<>nil then
>
> show_wDropDown(x,y, a.recordsMatchingSearchElement(s) )
>
> end
>
> But still no luck. Nil return.
>
> My only recourse now is to get the g.members from the group and do a manual
> search loop within RealBasic against the properties of each of the members.
>
> Is this a bug - should it be reported somewhere?
>
> Jim
>
>>
>>
>> ------------------------------
>>
>> Message: 4
>> Date: Tue, 15 May 2012 14:39:59 -0500
>> From: Jim Pitchford <[email protected]>
>> Subject: [MBS] Filter addressBook names within a Group
>> To: [email protected]
>> Message-ID: <[email protected]>
>> Content-Type: text/plain; charset=us-ascii
>>
>> I am trying to show a list of names from an addressbook group in a drop down
>> menu. I want to be able to show those people that match those in the names()
>> array.
>>
>> The code snippet I have is as follows:
>>
>> dim g as ABGroupMBS
>> if hGroup <> "" then
>> g = Get_ABGroup(hGroup) //separate function that returns the group
>> based on the name "hGroup"
>> end
>>
>> //create the seach elements for last, first and middlenames
>> for i as integer = 0 to names.ubound
>>
>> s1=g.searchElementForProperty(a.kABLastNameProperty,"","",names(i),a.kABContainsSubStringCaseInsensitive)
>>
>> s2=g.searchElementForProperty(a.kABFirstNameProperty,"","",names(i),a.kABContainsSubStringCaseInsensitive)
>>
>> s3=g.searchElementForProperty(a.kABMiddleNameProperty,"","",names(i),a.kABContainsSubStringCaseInsensitive)
>>
>> dim children() as ABSearchElementMBS = array(s1, s2, s3)
>>
>> //combine those element for this name
>> sE(i) = a.searchElementForConjunction(cOR, children)
>>
>> next i
>>
>> //now combine all the search elements for all names
>>
>> s = a.searchElementForConjunction(cAND, sE)
>>
>> show_wDropDown(x,y, a.recordsMatchingSearchElement(s) ) //seperate method
>> to show the resultant elements in a drop down
>>
>> But this is producing a nil result for s.
>>
>> The examples in MBS don't seem to cover this type of application.
>>
>> Can anyone spot what I am doing wrong?
>>
>> Jim
>>
>> ------------------------------
>>
>> Message: 5
>> Date: Wed, 16 May 2012 11:21:00 +0200
>> From: Christian Schmitz <[email protected]>
>> Subject: Re: [MBS] Filter addressBook names within a Group
>> To: MBS Real Studio Plugin List <[email protected]>
>> Message-ID:
>> <[email protected]>
>> Content-Type: text/plain; charset=us-ascii
>>
>>
>> Am 15.05.2012 um 21:39 schrieb Jim Pitchford:
>>
>>>
>>> s1=g.searchElementForProperty(a.kABLastNameProperty,"","",names(i),a.kABContainsSubStringCaseInsensitive)
>>
>> Please use a.searchElementForPersonProperty here.
>> g.searchElementForProperty is same as a.searchElementForGroupProperty, which
>> does not help here.
>>
>>> But this is producing a nil result for s.
>>>
>>> The examples in MBS don't seem to cover this type of application.
>>>
>>> Can anyone spot what I am doing wrong?
>>
>>
>> I tried the same thing, but it fails here, too.
>> Sorry, no idea why this fails.
>>
>> Greetings
>> Christian
>>
>> --
>> Real Studio Conferences, Training and Meetings.
>>
>> More details and registration here:
>> http://www.monkeybreadsoftware.de/realbasic/events/
>>
>>
>>
_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
[email protected]
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info