Solved

how to join two functions

Posted on 2006-07-01
11
238 Views
Last Modified: 2010-04-06
Hello,

I have this function below and it works great. how ever I also want to use the one below on the same variable how do I do it

 <%
' this will crop a sentence
Function CropSentence(strText, intLength, strTrial)
  If Len(strText) > intLength Then
    CropSentence = Left(strText, intLength) & strTrial
  Else
    CropSentence = strText
  End If
End Function
%>

<%= CropSentence((Recmostofuser.Fields.Item("country_usr").Value), 10, "...") %>

--------------------------------------------------------------------- above is used for cropping a sentence and works --------------------------------


below is for making the first letter of each word capital but i want to use that and the above but dont know how to use them both together.

<% function Proper(str)
  Proper = ucase(left(str,1)) & lcase(right(str,len(str)-1))
end function
%>

all help greatly received.

kenny


0
Comment
Question by:thatelvis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
11 Comments
 
LVL 20

Expert Comment

by:Gawai
ID: 17023799
try and let me know
<%
' this will crop a sentence
Function CropSentence(strText, intLength, strTrial)
  If Len(strText) > intLength Then
    CropSentence = Left(strText, intLength) & strTrial
  Else
    CropSentence = strText
  End If

Proper(strText)

End Function


function Proper(str)
  Proper = ucase(left(str,1)) & lcase(right(str,len(str)-1))
end function


%>


0
 
LVL 1

Author Comment

by:thatelvis
ID: 17023865
how can I apply both the CropSentence function and the Proper funcition to this

<%= ((Recmostofuser.Fields.Item("country_usr").Value), 10, "...") %>


0
 
LVL 20

Expert Comment

by:Gawai
ID: 17024003
try this, i m not sure but it may work

<%
' this will crop a sentence
Function CropSentence(strText, intLength, strTrial)
  If Len(strText) > intLength Then
    CropSentence = Left(strText, intLength) & strTrial
  Else
    CropSentence = ucase(left(strText,1)) & lcase(right(strText,len(strText)-1))
  End If

End Function

%>
<%= ((Recmostofuser.Fields.Item("country_usr").Value), 10, "...") %>
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:thatelvis
ID: 17024018
nope it didnt work,
0
 
LVL 20

Expert Comment

by:Gawai
ID: 17024036
let me try on this first, i wil get back 2 u.
0
 
LVL 35

Expert Comment

by:YZlat
ID: 17024080
<%
' this will crop a sentence
Function CropSentence(strText, intLength, strTrial)
  If Len(strText) > intLength Then
    CropSentence = Left(strText, intLength) & strTrial
  Else
    CropSentence = strText
  End If
End Function

function Proper(str)
  Proper = ucase(left(str,1)) & lcase(right(str,len(str)-1))
end function

dim arrText()
dim fullText, myText
myText=CropSentence((Recmostofuser.Fields.Item("country_usr").Value), 10, "...")
arrText=myText.Split(" ")
for i=0 to arrText.Length-1
      fullText=fullText & Proper(arrText(i) & " "
next
%>
0
 
LVL 11

Expert Comment

by:kelvinwkw
ID: 17040208
<%
Function CropSentence(strText, intLength, strTrial)
  If Len(strText) > intLength Then
    CropSentence = Left(strText, intLength) & strTrial
  Else
    CropSentence = strText
  End If
End Function

 function Proper(str)
  Proper = ucase(left(str,1)) & lcase(right(str,len(str)-1))
end function


for each element in split(CropSentence("ewtwet ery weryreyerwy ery er ywery er ywer", 20, "..."), " ")
      xx = xx & proper(element) & " "
next
response.write xx
%>

How bout this =)
0
 
LVL 11

Accepted Solution

by:
kelvinwkw earned 250 total points
ID: 17040235
<%
' this will crop a sentence
Function CropSentence(strText, intLength, strTrial)
  If Len(strText) > intLength Then
    tmpSentence = Left(strText, intLength) & strTrial
  Else
    tmpSentence = strText
  End If
  For Each element in split(tmpSentence, " ")
        CropSentence = CropSentence & Proper(element) & " "
      Next
End Function

function Proper(str)
  Proper = ucase(left(str,1)) & lcase(right(str,len(str)-1))
end function

response.write (CropSentence("ewtwet ery weryreyerwy ery er ywery er ywer", 20, "..."))
%>

Or this shorter version =)
0
 
LVL 1

Author Comment

by:thatelvis
ID: 17040429
what I have below works for the use I want, thanks all for your help.



this will capitilise every word in a sentence.

<%
function proper(str)
  proper = ""
  aStr = split(str," ")
  for i = 0 to ubound(aStr)
    proper = proper & ucase(left(aStr(i),1)) & lcase(right(aStr(i),len(aStr(i))-1)) & " "
  next
  proper = rtrim(proper)
end function
 %>


<%= proper(CropSentence((Recmostofuser.Fields.Item("country_usr").Value),10,"...")) %>



----------------------------------------------------------------------------------------------------


'this is for the first letter only and nothing else.


function Proper(str)
  Proper = ucase(left(str,1)) & lcase(right(str,len(str)-1))
end function



<%=Proper(Reclistall.Fields.Item("firstname_usr").Value)%>
0
 
LVL 1

Author Comment

by:thatelvis
ID: 17040445
<%
' this will crop a sentence
Function CropSentence(strText, intLength, strTrial)
  If Len(strText) > intLength Then
    CropSentence = Left(strText, intLength) & strTrial
  Else
    CropSentence = ucase(left(strText,1)) & lcase(right(strText,len(strText)-1))
  End If

End Function

%>
<% 'this will make the first word in each sentence capital
function proper(str)
  proper = ""
  aStr = split(str," ")
  for i = 0 to ubound(aStr)
    proper = proper & ucase(left(aStr(i),1)) & lcase(right(aStr(i),len(aStr(i))-1)) & " "
  next
  proper = rtrim(proper)
end function
 %>

above works briliant
0
 
LVL 35

Expert Comment

by:YZlat
ID: 17043349
you are welcome.

sorry I put
for i=0 to arrText.Length-1

as in ASP.NET insted of

for i = 0 to ubound(aStr)

as in classic ASP
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to deal with "Consider using Code First Migrations to update the database" ? 7 377
jQuery Date picker not working 16 218
Problem to file 3 92
Adjust the position 3 70
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question