Validate your WAP pages with Wapalidate Many of the unsupported characters within WAP pages are created using website contributors whereby users (webmasters etc) add content via WEB forms which transform custom MS Word characters into HTML code characters e.g. ‘. These HTML code characters are then stored in databases which when displayed on WAP pages can create compilation errors. Wapalidate is a function that can be used to validate strings or database fields so that they compile correctly. This will hopefully help WAP developers to lower the chances of compilation errors and using the same databases for both WEB and WAP sites. Here is the code: Function Wapalidate(strToCheck) ' Replace unsupported characters e.g. HTML code characters strToCheck = Replace(strToCheck,"‘","'") strToCheck = Replace(strToCheck,"’","'") strToCheck = Replace(strToCheck,"“","'") strToCheck = Replace(strToCheck,"”","'") strToCheck = Replace(strToCheck,"–","-") strToCheck = Replace(strToCheck," ","&") strToCheck = Replace(strToCheck,"&"," ") ' Use the above line to add extra unsupported characters ' Replace(strToCheck,"CHANGE THIS","AND WHAT IT WILL BECOME") Wapalidate = strToCheck End Function To use the function: Wapalidate(VARIABLE NAME) e.g. Wapalidate(Article) Wapalidate(FIELD NAME) e.g. Wapalidate(rs("Article")) Another way to avoid compilation errors is to make sure that if you are retrieving a large amount of data from a database, that it will not make the output WAP page more than 1440 bytes. Here is a snippet of my code: LOS = Len(Article) ' Display Headline %> <p align="left"><small><b><%=Headline%></b></small></p> <% ‘ Display Article ' If there are more than 500 characters in string nospace = 0 If LOS > 500 Then ‘ change 500 to anything you like but think about the 1440 bytes per page chars = 500 ‘ change 500 to the same as above Do while nospace = 0 ' Retrieve characters from article tempArticle = Left(Article,chars) If Right(tempArticle,1) = " " then nospace = 1 ' Set tempArticle to Article Article = tempArticle Else nospace = 0 chars = chars + 1 End If Loop ' Calculate amount of characters left More = LOS - chars ' Display 500 characters within article response.write("<p align='left'><small>"&Article&"...</small></p>") ' Link to view more of the article %> <do type="accept" label="More"><go href="NEXT WAP PAGE TO DISPLAY MORE" method="post"><postfield name="id" value="<%=id%>"/><postfield name="more" value="<%=More%>"/></go></do> <% Else ' Display full article response.write(Article) End If To display the remainder on the NEXT WAP PAGE: Get the Article strings data again from the database using the id variable and then calculate the remainder by Article = Right(Article,more) then something like <p align="left"><small>...<%=Article%></small></p>. Don’t forget to retrieve the id and more variables first. Please do not contact me on the above code as I will not reply (I expect you to mess around with the code yourself). If you wish to contact me on updates to the Wapalidate function or job opportunities then please e-mail michael_wright@lineone.net. |