WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples from Users
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Check string format

 Keywords: Check string format 

Sample:

#DefineFunction F_CheckString(InputStr, FormatStr)
	StrFLengte = 0
	StrILengte = 0
	Result = @FALSE
	ReturnResult = @TRUE
	InputStr = StrUpper(InputStr)
	FormatStr = StrUpper(FormatStr)
	StrFLengte = StrLen(FormatStr)
	StrILengte = StrLen(InputStr)
	
	; Lets check the length of both strings first!
	If StrFLengte == StrILengte ; is the stringlength equal?
		ArrayLength = StrILengte+1 ; we must have 1 more because strings start at zero and strsub starts at position 1
		MatchString = ArrDimension(ArrayLength)
		MatchString[0] = " " ; this guy wont be used 
		
		;now we create a formatstring based on the inputstring where every alfanum character will be replaced by an A and
		;any numeric characters by an 1
		For x=1 to StrILengte ; Length of inputstring 
			result = @FALSE
			result = IsNumber(StrSub(InputStr,x,1)) ; Is this character a number?
			If result ; yes it is a number
				MatchString[x] = "1" ;build our input format string, we discovered a number
			Else
				MatchString[x] = "A" ;build our input format string, we discovered a alfanumeric character
			Endif
		Next
		
		For x=1 to StrILengte
			If MatchString[x] != StrSub(FormatStr,x,1)
				ReturnResult = @FALSE ; We discovered a non valid type
				break
			Endif
		Next
		
	Else
		ReturnResult = @FALSE ; the stringlength of the input string and format string are not equal so the inputstring isnt valid
	Endif
	
	return ReturnResult
#EndFunction
;*******************************************************************
;***** End of function F_CheckString 
;*******************************************************************


ret = F_CheckString("deana1234", "aaaaa1111")
if ret == @true
	Message("Check string format","String matches specified format")
else
	Message("Check string format","String does not match specified format")
endif
exit


Article ID:   W15688
File Created: 2003:05:13:11:29:34
Last Updated: 2003:05:13:11:29:34