Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checking string for predefined format
Message
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00403485
Message ID:
00409008
Views:
64
Sergey,

Ok, this story has its continuation. Now we have to compare 2 fields: Mapref and APN. They have different formats, but the number of digits in both fields and number of alphas should be the same, e.g. this is the current program:
	rmapid=ALLTRIM(A.mapid)
	rapn=ALLTRIM(A.apn)
	rmapid=strtran(rmapid,"M:","")
	rmapid=strtran(rmapid,"P:","")
	rmapid=strtran(rmapid,"W:","")
	rmapid=strtran(rmapid,"L:","")
	rmapid=strtran(rmapid,"S:","")
	rmapid=strtran(rmapid,"T:","")
	rmapid=strtran(rmapid,"B:","")
	rmapid=strtran(rmapid,"U:","")
	rmapid=strtran(rmapid,"R:","")
	rmapid=strtran(rmapid,"D:","")
	AL=0
	DIG=0
	AAL=0
	ADIG=0
	For I=1 TO LEN(alltrim(rmapid))
		If ISALPHA(SUBSTR(rmapid,I,1))
			AL=AL+1
		Else
			If ISDIGIT(SUBSTR(rmapid,I,1)) AND VAL(SUBSTR(rmapid,I,1))>0
				DIG=DIG+1
			Endif
		Endif

	Endfor
	For I=1 TO LEN(alltrim(apn))
		If ISALPHA(SUBSTR(rapn,I,1))
			AAL=AAL+1
		Else
			If ISDIGIT(SUBSTR(rapn,I,1)) AND VAL(SUBSTR(rapn,I,1))>0
				ADIG=ADIG+1
			Endif
		Endif
	
	Endfor
** ?("AL"+STR(AL)+" aal"+STR(AAL))
IF ALAAL OR ADIGDIG
?(MAPID+"   "+apn)
K=K+1
ENDIF
Endscan
?k
Do you have some suggestions?

Thanks in advance.

>Nadya,
>The code below
> inlist(substr(lcAPN,37,1)," ","-"))
>
>wouldn't work because lcAPN is 36 characters long. I think you ment pcAPN.
>

>
>>
>>I used function, Sergey proposed, with some modifications:
>>
>>********************************************************************
>>*  Description.......: ValidateAPN1
>>*  Calling Samples...: ValidateAPN1(APN)
>>*  Parameter List....:
>>*  Created by........:  Sergey Berezniker
>>*  Modified by.......: Nadya Nosonovsky 08/10/2000 04:47:29 PM
>>********************************************************************
>>lparameters pcAPN
>>local lcMask,  lcDigits, lcLetters, lcAPNUniform
>>
>>lcMask = "999999X-X999999X-X999999XX-XX999999X"
>>*lcAPN  = "000000 - 001000 - 000000  -  000000"
>>lcApn = padr(ltrim(pcAPN),36)
>>lcDigits = "0123456789"
>>lcLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ "
>>lcAPNUniform = chrtran( lcAPN, lcDigits+lcLetters, ;
>>     replicate("9", 10)+ replicate("X", 27))
>>
>>*wait window lcAPNUniform+' lcMask:'+lcMask+" lcAPN:"+substr(lcAPN,37,1)
>>
>>return (left(lcAPNUniform,36) = lcMask and inlist(substr(lcAPN,37,1)," ","-"))
>>
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform