How to create and use multiple indices with get specific

The attached spec FONEINDEX.QPX shows how to use get specific with multiple indicies.

Important points:

The phone,get_specific_number is used for get specific and the data location on it stores a result code of what happened on that try for a number. All possible result codes all listed in the field question WHATHAP1. You can certainly change the text to be whatever you want.

Unlike a normal Phone,get_specific_number which sets a switch to put a prompt up to the interviewer when the Phone,get_number is encountered, a Phone,get_specific_number with a data location it will immediately try to GET a phone number from the phone file and it will look for mutliple indicies. If you also put a question label after the duplicate field, the program will search for the data in that question, rather than supplling the standard “Enter Number to dial” prompt.

Phone file layout is as follows:

1-10 Phone number

51-55 5 digit unique code number for each respondent

61-90 Respondent Name/Text

FONEINDEX.FBL shows how to build a phone file with multiple indicies. You can ampersand it into Fonebuld to build to build a phone file to use with this example.

FONEINDEX.RAW is a raw phone file which can be used with this example.

>PURGESAME~PREP COMPILE -SPECS[FONEINDEX,100,,MAXLABS=100] { TOP: !GOTO } {!COMMENTDetermine whether interviewer wants to be in Get Specific mode or not. Could save this in the local scratch if wanted this interviewing session to continue in this mode without reprompting on each interview. } { GETSPEC:DO YOU WANT TO BE GET SPECIFIC?!FIELD1 YES(SKIPTO GETNUMB) 2 NO } {!COMMENTDetermine which index the interviewer wants to use.  This is not required but allows you to do additional error checking on the interviewer input before the string is sent to the index.  For instance, you can make sure the string is the right length, has alpha or numeric as needed and you could append information from muliple questions into your search string. For instance, you could append the last name of the respondent to his state code so that you would only see the Smiths from California, instead of all the Smiths in the file.  }{ WHICHINDX:WHICH INDEX DO YOU WISH TO TRY?!FIELD1 PHONE NUMBER(SKIPTO INDEX2) 2 CODE NUMBER }{ ENTERNUM:ENTER IN 10 DIGIT PHONE NUMBER YOU WISH TO TRY TO GET !VARIABLE,NUMERIC_ONLY,10,10 } {!COMMENTThis question is the one that goes and looks for a phone number.  It says take the data that is in ENTERNUM and look for it in the index.  If there are duplicates show the information from Position 61-90 of the phone file and store the result code in question TESTIT.  When using multiple indicies you will usually want to set ALLOWDUPS=YES. } { TESTIT: .2!PHONE,get_specific_number,61,30,ENTERNUM }{!COMMENTIf the result code is blank, then you just got a valid phone number and can continue on with the interview. }{!IF TESTIT$ = "  "!GOTO START } {!COMMENTIf the result code is non-blank then you did NOT get a valid phone number and this reason why is stored here.  These are all the valid reasons why you should not get a number.  If you get a NI you need to rebuild or change the file access on the index file(s). If you get a SW there is something  wrong with the phone file and is should be fixed and/or rebuilt.  If you get a return code of SOMETHING ELSE please report this to the Support staff ASAP so we can figure out what is going on. }{ WHATHAP1: [TESTIT]!FIELD,USE_PREVIOUS_ANSWERNO No more numbers are currently availableSH Specific number is currently 'hidden' and unavailableSN Specific number not foundSC Specific number completedSR Specific number resolved (but not completed)SW Specific number wrong record (bad bug somewhere)SU Specific number is currently in use by another interviewerSS Specific number is for a special interviewerOA Specific number is owned by someone elseSB Number asked for is not a valid phone number (too few digits)TA No number returned, but wait a bit and try againNI No index file.  This aborts the interview.?? SOMETHING ELSE HAPPENED THAT WE DIDN'T EXPECT } {!COMMENTThis is just a debugging question to show what the return code was. }{ WHATHAPPENED?TRIED TO GET IT BY PHONE NUMBER -->