|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Get number of lines
hello
Im triying to get the number of lines of a long text from a recordset if recordset has 100 lines I want to show aside each line a " Line number " example: ' Results from the recordset <%=rs("description")%> text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text ok there are six lines from a recordset i want to display in this way ' Formatted Results from the recordset <%=rs("description")%> 1. text text text text text text text text text 2. text text text text text text text 3. text text text text text text 4. text text text text text text text text text 5. text text text text text text text text text 6. text text text text text text text like a list or like appears for example in dreamweaver or another web editor. I Know its possible, i have seen this somewhere but i don't remember where. Sorry for my poor English ( im Spanish )thank you |
|
#2
|
|||
|
|||
|
could you just use a counter starting at 1 and print that right before you print the items from the recordset. then increment the counter when you movenext.
~sam sorry for my poor english, im american :-P |
|
#3
|
|||
|
|||
|
Thanlk you for your answer
yes is the way im trying to do it but... Could be like this way http://www.asptutorial.info/learn/ASP-javascript.asp look at the tables. 1 text 2 text 3 text 4 text 5 text 6 text 7 text 8 text 9 text 10 text .... I Know how to get the numbers just looping, but i have to get a total number of lines to display ex. number_of_lines=5 count=number_of_lines Do While count > 0 Response.write count Response.write "<br>" count=count-1 Loop ok this will display numbres from 1 to 5 but how i know how many number_of_lines my recordset have.?? Any help??? Thank you |
|
#4
|
|||
|
|||
|
check out this post,http://forums.devshed.com/t49917/s.html, i think it has what you want in reference to finding the count of your recordset. basically you want to do this....
Code:
count = rs.recordcount hope that will work |
|
#5
|
|||
|
|||
|
repeated message
Please Delete Last edited by gurrutello : October 8th, 2003 at 05:47 PM. |
|
#6
|
|||
|
|||
|
repeated message
Please Delete Last edited by gurrutello : October 8th, 2003 at 05:47 PM. |
|
#7
|
|||
|
|||
|
repeated message
Please Delete Last edited by gurrutello : October 8th, 2003 at 05:47 PM. |
|
#8
|
|||
|
|||
|
thank you !!
but is not exactly what i need rs.recordcount ' Gets the number of records and i want to get example: response.write my_recordset("desription") then it will appears like: Code:
Neat, eh? There is, however, a much cleaner way for counting the number of words in a string and it involves regular expressions. (For more information on regular expressions be sure to visit the Regular Expressions Article Index!) The regular expression to count the number of words in a string uses the non- greedy repitition pattern matching symbol. This special symbol is only available in the regular expression engine that ships with the Microsoft Scripting Engines version 5.5 or greater. Then i want to get the number of lines from this text. response.write Total_lines Total lines = 8 Total words = 356 ' I know how to get the total words but not the total lines. then I can make appears my recordset like Code:
1. Neat, eh? There is, however, a much cleaner way for 2. counting the number of words in a string and it involves regular 3. expressions. (For more information on regular expressions be 4. sure to visit the Regular Expressions Article Index!) The regular 5. expression to count the number of words in a string uses the non- 6. greedy repitition pattern matching symbol. This special symbol is 7. only available in the regular expression engine that ships with 8. the Microsoft Scripting Engines version 5.5 or greater. I hope I explained better this time Last edited by gurrutello : October 8th, 2003 at 05:44 PM. |
|
#9
|
|||
|
|||
|
ah ok i get you now... only thing i could think to do would be to count the number of characters total in the recordset then divide this by how long you want your lines to be.... for example you have some text with 300 characters (including spacing, text, numbers, etc.) and you want the lines to be 50 characters long. so that would be you have 300/50 lines or 6 lines. then just do a count where you print out the line number, then characters 0-49, line number, 50-99 .... etc. i hope there is an easier way but this is the only way i can think right off my head.
|
|
#10
|
|||
|
|||
|
Aleluya!!
Thanks any way, but after 1 full day thinking, i did in this simple way Code:
<%
Dim str, numero_lineas
str = rs("ScriptCode")
str = Trim(str)
Do While InStr(1, str, " ")
' Convert to Spaces to one
str = Replace(str, " ", " ")
' Converting the line words to a long word with no spaces.
str = Replace(str, " ", "")
Loop
Dim aWords
' Conuting the new lines
aWords = split(str, vbCrLf)
numero_lineas = UBound(aWords) + 1
rsponse.write numero_lineas
%>
The rest of the code I do with a counter Code:
<% counter=1 do until counter=numero_lineas+1 response.write counter counter=counter+1 loop %> It works perfect. Live demo: http://www.tutores.org/tutores/code...=642&id=1&t=Asp Thank you Last edited by gurrutello : October 9th, 2003 at 02:21 AM. |
|
#11
|
|||
|
|||
|
great, ive always wondered how one do this. thanks.
i do love my text editting!!!
__________________
"Morgoth i Cried All Hope is Gone But i Swear REVENGE Hear my Oath!!" |
|
#12
|
|||
|
|||
|
If your lines are separated by cr-lf characters, something like this can work:
PHP Code:
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Get number of lines |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|