473,387 Members | 1,502 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Combine two functions

229 100+
Hi, I wonder if someone can tell me if its possible to combine two functions. Both work fine as they are written here, but i need them to work together in the output. I imagine that one must write to combine sNewsTitle and sDescription = statement.

Thanks for any pointers of theory
Richard



function 1 (shorten text)

Expand|Select|Wrap|Line Numbers
  1. Function Shorten(sString, sLength) 
  2. If Len (sString) > sLength Then 
  3.          Shorten = Left(sString,sLength) & "...." 
  4. Else 
  5.          Shorten = sString
  6. End If 
  7. End Function 
  8.  

Expand|Select|Wrap|Line Numbers
  1. Dim sNewsTitle
  2. sNewsTitle= rs("statement")
  3.  
  4.  
  5.  
  6.  
  7. <%
  8. sNewsTitle=Shorten(sNewsTitle,190)    
  9. Response.Write sNewsTitle 
  10. %>

function 2 ( to strip html from string)





Expand|Select|Wrap|Line Numbers
  1. Function RemoveHTML( strText )
  2.     Dim TAGLIST
  3.     TAGLIST = ";!--;!DOCTYPE;A;ACRONYM;ADDRESS;APPLET;AREA;B;BASE;BASEFONT;" &_
  4.               "BGSOUND;BIG;BLOCKQUOTE;BODY;BR;BUTTON;CAPTION;CENTER;CITE;CODE;" &_
  5.               "COL;COLGROUP;COMMENT;DD;DEL;DFN;DIR;DIV;DL;DT;EM;EMBED;FIELDSET;" &_
  6.               "FONT;FORM;FRAME;FRAMESET;HEAD;H1;H2;H3;H4;H5;H6;HR;HTML;I;IFRAME;IMG;" &_
  7.               "INPUT;INS;ISINDEX;KBD;LABEL;LAYER;LAGEND;LI;LINK;LISTING;MAP;MARQUEE;" &_
  8.               "MENU;META;NOBR;NOFRAMES;NOSCRIPT;OBJECT;OL;OPTION;P;PARAM;PLAINTEXT;" &_
  9.               "PRE;Q;S;SAMP;SCRIPT;SELECT;SMALL;SPAN;STRIKE;STRONG;STYLE;SUB;SUP;" &_
  10.               "TABLE;TBODY;TD;TEXTAREA;TFOOT;TH;THEAD;TITLE;TR;TT;U;UL;VAR;WBR;XMP;"
  11.  
  12.     Const BLOCKTAGLIST = ";APPLET;EMBED;FRAMESET;HEAD;NOFRAMES;NOSCRIPT;OBJECT;SCRIPT;STYLE;"
  13.  
  14.     Dim nPos1
  15.     Dim nPos2
  16.     Dim nPos3
  17.     Dim strResult
  18.     Dim strTagName
  19.     Dim bRemove
  20.     Dim bSearchForBlock
  21.  
  22.     nPos1 = InStr(strText, "<")
  23.     Do While nPos1 > 0
  24.         nPos2 = InStr(nPos1 + 1, strText, ">")
  25.         If nPos2 > 0 Then
  26.             strTagName = Mid(strText, nPos1 + 1, nPos2 - nPos1 - 1)
  27.         strTagName = Replace(Replace(strTagName, vbCr, " "), vbLf, " ")
  28.  
  29.             nPos3 = InStr(strTagName, " ")
  30.             If nPos3 > 0 Then
  31.                 strTagName = Left(strTagName, nPos3 - 1)
  32.             End If
  33.  
  34.             If Left(strTagName, 1) = "/" Then
  35.                 strTagName = Mid(strTagName, 2)
  36.                 bSearchForBlock = False
  37.             Else
  38.                 bSearchForBlock = True
  39.             End If
  40.  
  41.             If InStr(1, TAGLIST, ";" & strTagName & ";", vbTextCompare) > 0 Then
  42.                 bRemove = True
  43.                 If bSearchForBlock Then
  44.                     If InStr(1, BLOCKTAGLIST, ";" & strTagName & ";", vbTextCompare) > 0 Then
  45.                         nPos2 = Len(strText)
  46.                         nPos3 = InStr(nPos1 + 1, strText, "</" & strTagName, vbTextCompare)
  47.                         If nPos3 > 0 Then
  48.                             nPos3 = InStr(nPos3 + 1, strText, ">")
  49.                         End If
  50.  
  51.                         If nPos3 > 0 Then
  52.                             nPos2 = nPos3
  53.                         End If
  54.                     End If
  55.                 End If
  56.             Else
  57.                 bRemove = False
  58.             End If
  59.  
  60.             If bRemove Then
  61.                 strResult = strResult & Left(strText, nPos1 - 1)
  62.                 strText = Mid(strText, nPos2 + 1)
  63.             Else
  64.                 strResult = strResult & Left(strText, nPos1)
  65.                 strText = Mid(strText, nPos1 + 1)
  66.             End If
  67.         Else
  68.             strResult = strResult & strText
  69.             strText = ""
  70.         End If
  71.  
  72.         nPos1 = InStr(strText, "<")
  73.     Loop
  74.     strResult = strResult & strText
  75.  
  76.     RemoveHTML = strResult
  77. End Function
  78.  
  79.  








Expand|Select|Wrap|Line Numbers
  1. <%
  2.  
  3. Dim sDescription
  4. sDescription = rs("statement")
  5.  
  6. If IsBlank(rs("statement"))  Then
  7. %> 
  8. <p>This member has not yet written a statement</p>
  9. <%
  10. Else
  11. %> 
  12.  
  13. <p>
  14.  
  15. <%=RemoveHTML(sDescription)%>
  16. </p>
  17. <%
  18. End If
  19. %> 
Apr 17 '13 #1

✓ answered by Rabbit

Shorten(RemoveHTML(statement), 190)

3 1225
Rabbit
12,516 Expert Mod 8TB
You haven't explained how you want to combine them.
Apr 17 '13 #2
fran7
229 100+
Hi, Oh sorry. I want the results from the field "statement" to be shortened and also stripped of html.
Thanks for any pointers
Richard
Apr 17 '13 #3
Rabbit
12,516 Expert Mod 8TB
Shorten(RemoveHTML(statement), 190)
Apr 17 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Sergey | last post by:
Is it possible to realize such an algorithm (this one is not working): class a1 { public: void af () { bf(); } virtual void bf () = 0; };
9
by: Gibby Koldenhof | last post by:
Hiya, Terrible subject but I haven't got a better term at the moment. I've been building up my own library of functionality (all nice conforming ISO C) for over 6 years and decided to adopt a...
4
by: Telmo Costa | last post by:
What should i call the functions named Factorial_ in this sample code: class SomeClass { ... public int Factorial(int f) { if (f<0) throw SomeException("Some message."); if (f==0 || f==1)...
3
by: steve_h | last post by:
I think the subject says it all, but just in case: I know that I can call my own methods during an XSL transformation using <xsl:value-of select="myObject.someMethod(arg1)" /> having done...
4
by: T Perkins | last post by:
is there a way to have intellesence give a list of options for each parameter of a newly create functions. an example would be, using messagebox.show. after you put in the message and label, you...
5
by: Eric Fortier | last post by:
Hi all, Last year I posted a message regarding templates use in blitter functions, but the single answer I got didn't help. My problem is that I was writing blitter functions which takes a...
3
by: tshad | last post by:
I have about 10 functions that are identical except for one variable name that I am using in my "for" loop: for (ktr1=1;ktr1<=nhDataBean.projectCodeList.GetUpperBound(0);ktr1++) for...
6
by: Luvin lunch | last post by:
Hi, I'm new to access and am very wary of dates as I have limited experience in their manipulation and I know if they're not done properly things can turn ugly quickly. I would like to use a...
9
by: Amit Dedhia | last post by:
Hi All I have a VC++ 2005 MFC application with all classes defined as unmanaged classes. I want to write my application data in xml format. Since ADO.NET has buit in functions available for...
3
by: fjm | last post by:
I have one jquery function that submits data via a datastring to my server. This works great. On success, I currently have a little alert box that lets the user know that the data was stored. I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.