[thelist] tip (was Avoiding Divide by Zero within SQL...)

Warden, Matt mwarden at mattwarden.com
Fri Nov 30 14:19:05 CST 2001


On Nov 30, Anthony Baratta had something to say about Re: [thelist]...


>'' URLData Function
>'' Required Info Passed to Function:
>''      varDataLine
>''''''''''''''''''''''''''''''''''''''''''''''''''
>Function URLData(varDataLine)
>     if not(varDataLine = "" OR isNull(varDataLine)) then
>                 varDataLine = Server.URLEncode(varDataLine)
>     end if
>         URLData = varDataLine
>End Function
>
>''''''''''''''''''''''''''''''''''''''''''''''''''
>'' HTMLData Function
>'' Required Info Passed to Function:
>''      varDataLine
>''''''''''''''''''''''''''''''''''''''''''''''''''
>Function HTMLData(varDataLine)
>     if not(varDataLine = "" OR isNull(varDataLine)) then
>                 varDataLine = Server.HTMLEncode(varDataLine)
>     end if
>         HTMLData = varDataLine
>End Function

Looks like a job for TrimNull:

function TrimNull(varShiz)
	if isNull(varShiz) then
		TrimNull = Null
	else
		if trim(varShiz)="" then
			TrimNull = Null
		else
			TrimNull = trim(varShiz)
		end if
	end if
end function


function HTMLData(varShiz)
	if isNull(TrimNull(varShiz) then
		...
	end if
end function

or you could leave out the call to TrimNull in the function and call the
function like so:

HTMLData(TrimNull(varShiz))

and hve the added benefit of automagically having it trimmed as well (if
it's not null).

Personally, though, I'd rather have it in the function itself.

--
mattwarden
mattwarden.com





More information about the thelist mailing list