The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

import-bot (20211) [Avatar] Offline
#1
[Originally posted by the_webmaestro]

Howdy folks!

I'm building an application, and I'd like to use an ASP function to build my
links. However, there are so many different types of links which could be
used, that it's giving me a headache just thinking about it. This is
especially true because I'm trying to make this same function able to output
either WML, HDML, CML (PALM's HTML) or HTML...

My intention is to first check to see the page format (wml, hdml, html, etc.)
and if it's WML, I'll check to see if it's a do/go, select/option, a/href etc.
Any ideas or feedback on this would be appreciated!

Web Maestro Clay

Here're two functions I have so far:

function buildLink(sFormat, sHREF, sClass, sText, sAlt, sButton, sNavType,
sLinkType)
'------------------------------------------------------
' DESCRIPTION : Builds links usable in many formats
' depending upon following attributes:
'------------------------------------------------------
' sFormat : w(wml),h(hdml),p(palm),else(html)
' sHREF : HREF -- including VARs
' sClass : CSS class
' sText : link text
' sAlt : LINK-specific (ALT, TITLE or key LABEL)
' sButton : PALM-specific link (makes link appear
' to be a button)
' sNavType : do, go, a, select
' sLinkType : accept, options, soft1, soft2
'
' Created 11/16/2001 by Clay Leeds
'------------------------------------------------------
dim sOut
select case sFormat
case w 'WML
sOut = "
if notNullBlank(sAlt) then sOut = sOut & " title=""" & sAlt & """"
sOut = sOut & ">" & sText & "
"
buildLink = sOut
case h 'HDML
sOut = "<action type="accept" task="go" dest=""" & sHREF & """">
if notNullBlank(sAlt) then sOut = sOut & " title=""" & sAlt & """"
sOut = sOut & ">" & sText & ""
buildLink = sOut
case p 'PALM
sOut = "
if notNullBlank(sClass) then sOut = sOut & " class=""" & sClass & """"
if notNullBlank(sButton) then
sOut = sOut & " button>" & sText & "
"
else
sOut = sOut & ">" & sText & ""
end if
buildLink = sOut
case else 'HTML
sOut = "
if notNullBlank(sAlt) then sOut = sOut & " alt=""" & sAlt & """"
if notNullBlank(sClass) then sOut = sOut & " class=""" & sClass & """"
sOut = sOut & ">" & sText & "
"
buildLink = sOut
end select
end function

function notNullBlank(mString)
'------------------------------------------------------
' DESCRIPTION : Determines if string is empty or null.
'------------------------------------------------------
' mString : The string to be checked.
'------------------------------------------------------
if mString <> "" and not isNull(mString) and not isEmpty(mString) then
notNullBlank = true
else
notNullBlank = false
end if
end function