At(), AtC(), RAt(), $
Did you ever need to know whether a string contains a particular substring? Say you have a memo field containing notes about a phone conversation and you want to see whether you discussed the "Super Duper Pooper Scooper." Enter this group of functions.Technically, $ is an operator, while AT(), ATC() and RAT() are functions. But all of them are used to find a substring within a string. $ simply indicates whether or not the substring is there. The others all return the position where the string was found.
Usage |
lIsItInThere = cSearchFor $ cSearchIn nFoundPos = AT( cSearchFor, cSearchIn [ ,nOccurrence ]) nFoundPos = ATC( cSearchFor, cSearchIn [ ,nOccurrence ]) nFoundPos = RAT( cSearchFor, cSearchIn [ ,nOccurrence ]) |
Example |
lFoundIt = "Super Duper Pooper Scooper" $ mNotes nStartPos = AT("Super Duper Pooper Scooper", mNotes) nStartPos = ATC("Super Duper Pooper Scooper", mNotes) nLastOne = RAT("Super Duper Pooper Scooper", mNotes) * Here's a more useful example which shows how you'd take apart * a field containing city, state and zip code to create separate * fields. You'd call this routine like this: STORE "" TO cCity, cState, cZip DO PARSADDR WITH cCityStZip, cCity, cState, cZip * parsaddr.prg * Parse single address variable into city, state and zip * Assumes parameter cAddress has structure: * City, ST Zip * Zip can be either 5 or 10 digit LPARAMETERS cAddress, cCity, cState, cZip LOCAL nStartZip, nStartState nStartZip = RAT(" ",TRIM(cAddress)) cZip = TRIM(SUBSTR(cAddress, nStartZip+1)) nStartState = AT(",", cAddress) cState = ALLTRIM(SUBSTR(cAddress, nStartState+1, ; nStartZip-nStartState-1)) cCity = ALLTRIM(LEFT(cAddress, nStartState-1)) RETURN |
See Also |
AllTrim(), AtLine(), AtCLine(), At_C(), AtCC(), Left(), Occurs(), RatC(), RatLine(), Right(), Substr(), Trim(), Upper() |