Page 1 of 1

Indexing multiple email addresses in a file record

Posted: Wed Mar 30, 2016 11:08 am
by Cliff Wiernik
We have a file that has several email address in each record. There were added over time and have not been put into a separate database of email addresses.

Each record has email1, email2, email3, email4, email5.

We want to be able to browse all emails within a single browse in ordered order. The file currently has 15,000 record with many records have 3 or more of the emails populated.

Is there any way to accomplish short of accumulating into a separate file/array to browse that would have to be recreated every time they need to do the browse.

Our environment uses the ADS server.

Cliff

Re: Indexing multiple email addresses in a file record

Posted: Wed Mar 30, 2016 11:50 am
by bwolfsohn
Cliff,

We have the same issue with phone numbers in records...

Here's some partial code segments that might give you some ideas...

what we did was a single phone number search that accessed each index

FOR i := 1 TO 3
do case
case i==1
MAIL->(OrdSetFocus("PHONE"))
case i==2
MAIL->(OrdSetFocus("PHONE2"))
case i==3
MAIL->(OrdSetFocus("PHONEFAX"))
endcase
mail->(dbseek(trim(upper(xValue)) , .f. )) // .t. := softseek on
IF !mail->(eof()) .OR. i==3 // found it
MAIL->(OrdSetFocus("PHONE"))
exit
ENDIF
NEXT


if you want a dynamic search on each keypress,

bKeyBlock := {|nKey,b,oGet|oGet:getData(),MailSearch(nKey,oGet,GetList,oRegisterBrowse,cMode)}


// need to check all 3 indexes
nFound := At(' ',xValue)
IF nFound > 0
IF nFound = 6
nFound := At(' ',xValue,7)
ENDIF
IF nFound > 0
xValue := SubStr(xValue,1,nFound-1)
ENDIF
ENDIF
FOR i := 1 TO 3
do case
case i==1
MAIL->(OrdSetFocus("PHONE"))
case i==2
MAIL->(OrdSetFocus("PHONE2"))
case i==3
MAIL->(OrdSetFocus("PHONEFAX"))
endcase
MAIL->(DC_SetScope(0,xValue))
MAIL->(DC_SetScope(1,xValue))
IF mail->(dc_keycount())>0
exit
else
dc_clrscope()
sleep(2)
IF i==3
MAIL->(OrdSetFocus("PHONE"))
MAIL->(DC_SetScope(0,xValue))
MAIL->(DC_SetScope(1,xValue))
ENDIF
ENDIF
NEXT

Re: Indexing multiple email addresses in a file record

Posted: Wed Mar 30, 2016 12:11 pm
by rdonnay
Are you saying that you want 4 separate rows in the browse, one for each email?

Or do you want 1 row with 4 separate columns?

Re: Indexing multiple email addresses in a file record

Posted: Wed Mar 30, 2016 1:28 pm
by Cliff Wiernik
They just gave me a clarification on what they really want to do. We do not currently have index tags on each of the addresses, but they would like to search within our browse screen, a single email address column, but it would search all 5 index tags and go to the first record that has the matching email address. Normally, they would have to search what email address they want and seek in one, then move to the other.

It appears they are looking for something like what Brian is suggesting. In the browse format, that would be 1 record with 4-5 email address columns, but the seek process would go though each of them, typically with an incremental browse search.

The 1 record, many lines in a browse would also be something to consider as alternative.

Re: Indexing multiple email addresses in a file record

Posted: Wed Mar 30, 2016 1:50 pm
by Auge_Ohr
hi,

you can build a String from all Email Fields and use OrdWildSeek() which can work with increment Search.
i do it with Phone Number this Way

Code: Select all

IF USELOCK("XPPTEL",.T.,lock_dauer)

   _cdxname = "XPPTEL.CDX"                         
   _tagname = "ALLETELNO"                          
   _keyfeld = "TNR2STR(VORTELE)+"+;
              "TNR2STR(TELGES) +"+;
              "TNR2STR(VORFAX) +"+;
              "TNR2STR(TELFAX) +"+;
              "TNR2STR(VORPRIV)+"+;
              "TNR2STR(TELPRI) +"+;
              "TNR2STR(HANDY1) +"+;
              "TNR2STR(HANDY2) +"+;
              "TNR2STR(ANHANDY)+"+;
              "TNR2STR(PVVORT1)+"+;
              "TNR2STR(PVTEL1) +"+;
              "TNR2STR(PVVORF1)+"+;
              "TNR2STR(PVFAX1) +"+;
              "TNR2STR(PVHANDY)"

   OrdCreate(_cdxname,_tagname,_keyfeld)
   CLOSE INDEX
you only have to look that String is always same length. i do have to eliminate Space between Number ( if some )

Code: Select all

FUNCTION TNR2STR(value)
LOCAL RETVAR := ""
LOCAL nLen   := LEN(value)
LOCAL nSoll  := nLen
LOCAL i,nDiff
LOCAL cStr
// eliminate Space
FOR i = 1 TO nLen
    cStr := SUBSTR(value,i,1)
    IF cStr == CHR(32)
    ELSE
       RETVAR := RETVAR+cStr
    ENDIF
NEXT
// fill up same length
nDiff := nSoll - LEN(RETVAR)
FOR i = 1 TO nDiff
    RETVAR := RETVAR+CHR(32)
NEXT
RETURN RETVAR
now you can search (increment) this Way

Code: Select all

   ORDSETFOCUS("ALLETELNO")
   ORDWILDSEEK("*"+ALLTRIM(cString)+"*")

Re: Indexing multiple email addresses in a file record

Posted: Wed Mar 30, 2016 10:19 pm
by Wolfgang Ciriack
Hi Cliff,
if you use ADS, look at
http://bb.donnay-software.com/donnay/vi ... 231#p10231
This will filter your email adresses very fast.