*--Examples of tcUserTyped: * B10 TS 4004, 100 N Main St, TX, 05, WM, 132lbs, 62", More Comments * C32 TS ABC123, TX, 2005, 100 N MAIN ST, 2 CHILDREN IN VEH * A10 TS 100 N MAIN ST, ABC123, SC, 06, WM 150LBS 60" * C10 TS SC, 4003, 04, 100 N MAIN ST * In the last example, 4003 is the vehicle tag and 2004 the year vstoploc = .T. && check for location vstoplnpos = AT('TS',tcUserTyped) && determine where to start parsing vstopik = 0 && used for counting parsed values items vstoplcstring = "" && temporary string to store the parsed results to IF vstoplnpos > 0 && IF "TS" is in the user typed value, continue FOR istep = vstoplnpos+2 TO LEN(RTRIM(tcUserTyped)) IF SUBSTR(tcUserTyped,istep,1) = "," vstopik = vstopik + 1 DIMENSION trafficinfo(vstopik,2) && store the parsed value into an array element trafficinfo(vstopik,1) = vstoplcstring trafficinfo(vstopik,2) = "" vstoplcstring = "" ELSE vstoplcstring = vstoplcstring + SUBSTR(tcUserTyped,istep,1) ENDIF ENDFOR *--Last item in the string get it as well IF !EMPTY(ALLTRIM(vstoplcstring)) vstopik = vstopik + 1 DIMENSION trafficinfo(vstopik,2) trafficinfo(vstopik,1) = vstoplcstring trafficinfo(vstopik,2) = "" vstoplcstring = "" ENDIF ENDIF IF TYPE('alen(trafficinfo,1)')="N" .AND. ALEN(trafficinfo,1) > 0 && valid traffic stop info entered vstoploc = .T. && check for location vstoplicensetag = .T. && check for license vstoplicenseyr = .T. && check for the license year vstoplicensest = .T. && check for the license state vstopvalue = "" && temporary var used to store the array element for checking vstopnlicvalue = 0 && temporary var used to verify if 2 digit year or license passed vstopclicvalue = '' && temporary var used to verify if 2 digit year or license passed FOR istep2 = 1 TO ALEN(trafficinfo,1) IF TYPE('trafficinfo(istep2,1)') = "C" .AND. !EMPTY(trafficinfo(istep2,1)) vstopvalue = ALLTRIM(trafficinfo(istep2,1)) *--2 digit - if the license year has not been processed yet, is it a year or a license tag number *--Any two digit value > 0 gets processed as license number or a year in the case below IF vstoplicenseyr .and. LEN(vstopvalue) = 2 .and. VAL(vstopvalue) > 0 && 01-99 vstopnlicvalue=VAL(vstopvalue) IF vstopnlicvalue<100 AND vstopnlicvalue>0 IF vstopnlicvalue<gnCentRollover vstopclicvalue=LTRIM(STR(2000+vstopnlicvalue)) ELSE vstopclicvalue=LTRIM(STR(1900+vstopnlicvalue)) ENDIF IF (LEN(vstopclicvalue) = 4 ; .AND. INT(VAL(vstopclicvalue)) >= YEAR(DATE())-3 ; .AND. INT(VAL(vstopclicvalue)) <= YEAR(DATE())+1) && three years ago to 1 year in the future vstopvalue = vstopclicvalue ENDIF ENDIF ENDIF DO CASE *--Verify speed after with check for ' " may be slow drawing screen when doing string comparison CASE CHR(34) $ vstopvalue .or. CHR(39) $ vstopvalue && ', " probably height passed IF EMPTY(THISFORM.Comments.VALUE) THISFORM.Comments.VALUE = vstopvalue ELSE THISFORM.Comments.VALUE = THISFORM.Comments.VALUE + " " + vstopvalue ENDIF CASE vstoploc .AND. ("/" $ vstopvalue .OR. "\" $ vstopvalue .or. (ISDIGIT(vstopvalue) .AND. AT(CHR(32),vstopvalue) > 0)) *--Does the value have /, \, or start with a number and contain a space - assume location vstoploc = .F. && location found, do not check for location anymore *--Verify the location done in field THISFORM.Location.VALUE = vstopvalue CASE vstoplicensest .and. LEN(vstopvalue) = 2 .AND. VAL(vstopvalue) = 0 *--Was a valid state entered by the user IF THISFORM.StateVer(vstopvalue) && valid state or WM, BF, et al entered THISFORM.State.VALUE = vstopvalue vstoplicensest = .F. ELSE IF EMPTY(THISFORM.Comments.VALUE) && is not a valid state so put it in comments THISFORM.Comments.VALUE = vstopvalue ELSE THISFORM.Comments.VALUE = THISFORM.Comments.VALUE + " " + vstopvalue ENDIF ENDIF CASE vstoplicenseyr .and. (LEN(vstopvalue) = 4 ; .AND. INT(VAL(vstopvalue)) >= YEAR(DATE())-3 ; .AND. INT(VAL(vstopvalue)) <= YEAR(DATE())+1) && three years ago to 1 year in the future THISFORM.LicenseYear.VALUE = vstopvalue vstoplicenseyr = .F. && don't check for the year again CASE vstoplicensetag .AND. LEN(vstopvalue) <= 10 .AND. AT(CHR(32),vstopvalue) = 0 && assume license tag *--No spaces and less than or equal to 10 chars vstoplicensetag = .F. && do not check for license again THISFORM.License.VALUE = vstopvalue OTHERWISE && assume comment after all other conditions have been checked *--Leftover stuff e.g. WM, BF, 62", 150lbs, 2 children in car, etc. IF EMPTY(THISFORM.Comments.VALUE) THISFORM.Comments.VALUE = vstopvalue ELSE THISFORM.Comments.VALUE = THISFORM.Comments.VALUE + " " + vstopvalue ENDIF ENDCASE ENDIF ENDFOR ENDIFAny ideas?