Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 18th, 2003, 02:53 PM
Authorized User
 
Join Date: Aug 2003
Location: , , .
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default help on functions instr....

I am writing a function to keep the values between the content class when i search an html page because I just want the text between the content class to be searched, but it keep giving me errors.

iPos = InStr(1,orig_string,"<p class=""content"">")

<%
Function Remove(orig_string)
iPos = InStr(1,orig_string,"<p class=""content"">")
If iPos = 0 then
strTitle = "Untitled"
    Else
strTitle = Mid(orig_string,iPos+21,InStr(iPos,orig_string,"<p class=""content"">")-iPos-21)
End If
orig_string=strTitle
End Function
%>

    contValue = "<p class=""content"">Monsignor Frank Rossi - Director<p class="content">"
x= remove(contValue)
response.write x

Reply With Quote
  #2 (permalink)  
Old September 19th, 2003, 02:56 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

I can see a few things here:
1. in your test string (contValue=...) you haven't doubled up the quotes around the ending "content"
2. in this line: strTitle = Mid(orig_string,iPos+21,InStr(iPos,orig_string,"<p class=""content"">")-iPos-21) you need to start the InStr at iPos+1 not at iPos
3. your iPos+21 and iPos-21 should be iPos+19 and iPos-19 because the double quotes don't actually exist in the string variable orig_string

I'm confused about one thing though, in that line contValue = "<p class=""content"">Monsignor Frank Rossi - Director<p class="content">" , shouldn't the ending tag be just </p>? Or is it the starting tag for another para element?

hth
Phil
Reply With Quote
  #3 (permalink)  
Old September 19th, 2003, 10:01 AM
Authorized User
 
Join Date: Aug 2003
Location: , , .
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default

actually i fixed my script and ipos is 21 =). Weird but it works....thanks.

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Oracle Instr ermutigen BOOK: SQL Functions Programmer's Reference 1 May 31st, 2009 12:04 AM
InStr() repeat instances spinout Classic ASP Components 7 November 23rd, 2006 10:55 AM
CHARINDEX instead of Instr... mircea Classic ASP Databases 7 July 19th, 2004 01:47 PM
instr function Beulah ASP.NET 1.0 and 1.1 Basics 1 September 18th, 2003 01:54 AM
InStr() in Access 2000 fordrs3 Access VBA 1 July 8th, 2003 05:42 AM



All times are GMT -4. The time now is 11:30 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.