...

View Full Version : limiting words



mivec
08-24-2005, 06:16 AM
hi all,
lets say i have a whole load of words as my content...but when u display it, u definitely won't want the whole thing....eg:



Abstract Embedding of microprocessors within electronic devices is at the heart of the current era of electronic consumerism. Artificial Neural Networks (ANNís) have played a relatively minor role in consumer electronics, so far. This is because, although ANNís are a useful tool in many applications where PC based simulation of networks may be used to extract features from otherwise opaque collections of data, popular supervised networks such as the Multi-Layer Perceptron (MLP) suffer from slow training times and difficulty of hardware implementation. This presentation considers the potential of Weightless Neural Networks (WNNís) in the area of intelligent embedded systems. WNNís have been around for sometime, they are trained in a single pass through the data set and may easily be implemented in FPGA hardware. Unfortunately, until now, they have demonstrated only trivial powers of generalization. In this seminar, a new generation of WNN is described that shows generalization capabilities, which compete with that of the MLP. This should open up entirely new application areas. Some of the envisaged possibilities are discussed, e.g. adaptive control, image recognition, bio-informatics. This seminar is open to the public by invitation only. Please fax (03 - 8996 0253) or email your confirmation of participation on or before 20th. November 2002 with the following details, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cut here ~~~~~~~~~~~~~ Name of Participant(s) : Company/Organisation : Address : Tel. : Fax. : email : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can contact Ms. Melissa Seah of the Adaptive Information Research Group at ext. 6409 or seah@mimos.my if you have any enquiries.


i might just want to output(limit the output) to:



Abstract Embedding of microprocessors within electronic devices is at the heart of the current era of electronic consumerism. Artificial Neural Networks (ANNís) have played a relatively minor role in consumer electronics, so far. This is because, although ANNís are a useful tool in many applications where PC based simulation of networks may be used to extract features from otherwise opaque collections of data, popular supervised networks such as the Multi-Layer Perceptron (MLP) suffer from slow training times and difficulty of hardware implementation.


in php it is :



nl2br(substr($row->contents, 0, 50))


how's it in asp??? thanking all of u in advance....

glenngv
08-24-2005, 06:26 AM
Look into Mid (http://www.devguru.com/technologies/vbscript/13951.asp) function. You can refer to devguru for other vbscript objects and functions.

mivec
08-24-2005, 07:06 AM
Look into Mid (http://www.devguru.com/technologies/vbscript/13951.asp) function. You can refer to devguru for other vbscript objects and functions.

i used it...but i am getting this error:


Error Type:
Microsoft VBScript runtime (0x800A0005)
Invalid procedure call or argument: 'Mid'
/eventView.asp, line 178




<%=Mid((DBRecordset("Synopsis")),0, 50)%>


so it doesn't work??

glenngv
08-24-2005, 09:13 AM
In VBScript, character position in string starts at 1 not 0 unlike in other languages. You should also check if the field is null as it will throw an error if the field is null.


<%
dim syn
syn = DBRecordset("Synopsis")
if IsNull(syn) then
response.write "-"
else
response.write Mid(syn,1, 50)
end if
%>

Bullschmidt
08-24-2005, 01:47 PM
And here's a related function I've written:



Function jpsvbParagraphAbbr(pvarFld, pintLen)
' Purpose: Paragraph abbreviate.
' Remarks: Doesn't chop up the final word. Usually puts ... after.
' Example: pintLen of 15, Can't stop now. -> Can't stop...

' Dim var.
Dim varFld
Dim strChar
Dim intFinalWhiteSpaceBlockStartPos
Dim intFinalWhiteSpaceBlockEndPos
Dim I

' Set var.
varFld = pvarFld

' Quick exit if blank.
If IsNull(varFld) Or (Len(varFld) = 0) Then
jpsvbParagraphAbbr = ""
Exit Function
End If

' Convert to string.
varFld = CStr(varFld)

' Quick exit if not too long.
If Len(varFld) <= pintLen Then
jpsvbParagraphAbbr = varFld
Exit Function
End If

' Truncate to 1 more char than the needed len.
varFld = Left(varFld, pintLen + 1)

' Init.
intFinalWhiteSpaceBlockStartPos = 0

' Go back char by char to find the final white space block start pos.
' (There could be several white spaces in a row.)
' (I.e. if desired len is 15, find pos of the 1st space after the p in "Can't stop now.")
For I = pintLen + 1 To 1 Step -1
' Set var.
strChar = Mid(varFld, I, 1)

' If space, tab, CR, or LF.
If (strChar = " ") Or (strChar = Chr(9)) Or (strChar = Chr(13)) Or (strChar = Chr(10)) Then
intFinalWhiteSpaceBlockStartPos = I
Else
If intFinalWhiteSpaceBlockStartPos > 0 Then
Exit For
End If
End If
Next ' Next I.

' Keep the proper num of chars from the left.
If intFinalWhiteSpaceBlockStartPos > 0 Then
' Truncate to just before final white space.
varFld = Left(varFld, intFinalWhiteSpaceBlockStartPos - 1)
Else
' Keep the orig up to the desired len (i.e. drop the temp addtl char).
varFld = Left(varFld, pintLen)
End If

' Add ... at end.
' (If varFld already ends in ., then only add two more .'s)
If Right(varFld, 1) = "." Then
varFld = varFld & ".."
Else
varFld = varFld & "..."
End If

' Return val.
jpsvbParagraphAbbr = varFld
End Function

neocool00
08-24-2005, 03:05 PM
Nice function Bull. Too many times if you are not careful, you'll end up cutting a word off in the middle.

Bullschmidt
08-24-2005, 07:34 PM
Nice function Bull. Too many times if you are not careful, you'll end up cutting a word off in the middle.


Thanks and it was designed not to only show part of a word (and that's actually why the function is so long). :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum