Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 11th, 2006, 01:53 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default Assistance with function

Good day

The function below is supposed to take a string EG 'LAND CMD'. My intention is to simply loop through each caracter and place a '<br>' between them. If a space is found place a '&nbsp;<bR>'

Therefore the output should be:

L
A
N
D

C
M
D

However the output seems to be:

LAND CMDL
A
N
D

C
M
D

I am having trouble identifying why its out putting the whole string in the first iteration, then behaves as it should. It is cut and paste code that runs error free, some assistance would be appreciated.


<%
  function vertText(theText)
     dim strCount
     strCount = 1
     on error resume next
     vertText = CSTr(trim(theText))
     for strCount = strCount to len(vertText)
        if mid(vertText,strCount,1) = " " then
           vertText = vertText & mid(vertText,strCount,1) & "&nbsp;<bR>"
        else
           vertText = vertText & mid(vertText,strCount,1) & "<bR>"
        end if
     next
  end function
  response.write vertText("LAND CMD")
%>

TYIA

BTW: This relates to a post in the CSS area where I was tring to achieve vertical text using CSS. Not without assistance, we managed to acieve the objective however the printer(s) didnt like it. Therefore I find myself trying to achieve my objective using ASP.

For those who are interested in the client side solution where a printer prevented me from reaching my objective the post may be seen at http://p2p.wrox.com/topic.asp?TOPIC_...02&whichpage=2



Wind is your friend
Matt
__________________
Wind is your friend
Matt
 
Old August 11th, 2006, 02:55 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Isn't that because of this:

vertText = CSTr(trim(theText))


You start by assigning theText to vertText before you start the loop...

I think this will work a lot better:
Code:
  Function vertText(theText)
     Dim strCount
     theText = theText & "" ' fix null issues
     For strCount = 1 to Len(theText)
        If Mid(theText, strCount, 1) = " " Then
           vertText = vertText & Mid(theText, strCount, 1) & "&nbsp;<br>"
        Else
           vertText = vertText & Mid(theText, strCount, 1) & "<br>"
        End If
     Next
  End Function
  Cheers,

Imar
 
Old August 11th, 2006, 05:31 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Yes it is. Thanking you, works like a charm. Your assistance is very much appreciated, have a fine weekend :0)

Wind is your friend
Matt
 
Old August 11th, 2006, 12:01 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Thank you. You too...

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ Assistance KramRJ C++ Programming 2 May 19th, 2007 07:24 AM
I need u guys assistance acube4real C++ Programming 1 October 20th, 2006 08:27 AM
XSLT Assistance MarkHA XSLT 0 November 7th, 2005 12:08 AM
Network Assistance DuncanFinney C# 6 August 1st, 2005 06:42 PM
Project Assistance PetraMan Javascript How-To 5 April 7th, 2005 10:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.