The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Now for those who don't know about this, the explanation:-
This function parses the links in a block of text & make them HTML links. Like if you have something like www.example.com/mypage.html in a block of text, this function will make it like <a href="http://www.example.com/mypage.html" target="_self">www.example.com/mypage.html</a> so that its an actual HTML link that works, something like the one here at SPF. Also works for email links, so something like me@example.com will be converted into <a href="mailto:me@example.com" target="_self">me@example.com</a>.

But unlike the original function by TheTank, the one above addresses the issue of setting target attribute of the link. The tgt parameter is optional but if you want to set the target as _blank or _top, you can pass the parameter as blank or top(without underscores). If nothing is passed for tgt parameter, it sets the target as _self.

Ok NOW, so this function above now also supports targetting frames. Just
another optional parameter added by name of frm. If this parameter is set to
any number but 0, it will not add an underscore(_) to the parameter tgtwhich specifies the target name. So if its omitted, then also it will add
underscore(_).
So, if you wanna target a frame, just set frm to any number, better be 1 of
ease of things.

There was a post in this thread asking how to post
the first 50 characters, so I wrote this thread to allow
you to do just this, but it will prevent it from stopping
in the middle of a word.

Code:

Function GetFirstN(FieldIn, NumChars)
Dim HoldLength
' Eliminate excessive spaces from end
FieldIn = Trim(FieldIn)
' If Less than the maximum, just return the field
If Len(FieldIn) <= NumChars then
GetFirstN = FieldIn : Exit Function
End If
If mid(FieldIn, NumChars, 1) = " " then
GetFirstN = Left(FieldIn, NumChars)
Else
HoldLength = instr(NumChars + 1, FieldIn, " ")
If HoldLength = 0 then HoldLength = instrev(FieldIn, " ", NumChars) ' in case no spaces are after
If HoldLength = 0 then
' no spaces found at all (doubtful but could happen), so take first numchars characters
GetFirstN = Left(FieldIn, ",", NumChars)
else
' take length based on the appropriate space.
GetFirstN = Left(FieldIn, HoldLength)
End if
End If
End Function

' ***** This function is used to print something *****
Private Function print(pVal)
Response.Write(pVal)
End Function
' ***** This function is used to redirect to a URL *****
Private Function reDir(pURL)
Response.Redirect(pURL)
End Function
' ***** This function is used to get value from ServerVariables collection *****
Private Function sVar(pVal)
sVar = Request.ServerVariables(pVal)
End Function

I'm not sure. I'm not much of a hash/encryption expert. What method do you
use for SHA1? Coded function? Built-in VBScript function? I would sorta assume
that the SHA256 would stand for 256 bit encryption, but I'm not sure. (see first
two sentences If you go to their website, they have an MD5 hash function
as well. On their website they have the SHA256 and MD5 functions in VB and
VBScript. The MD5 function is in JavaScript as well.

Last edited by starrsoft; Aug 31, 2004 at 04:45.
Reason: Just realized that SP doesn't do auto VbCrLf, <br> or whatever...

Well, I use a user-defined function like this for SHA1
hashing. It isn't built in VBScript. And as far as I know,
its 160bit hashing. So maybe the function you posted
produces a stronger hash. I think I'll hash a string with
both functions & compare them.

You can access your parameters in your stylesheet by instantiating them with the prefix param and their number in the array. I started with 1. so in your stylesheet for this example you'll have something like:
<xsl:param name="param1" /> <!--this would be: "some text" -->
<xsl:param name="param2" /> <!--this is: 23 -->
<xsl:param name="param3" /> <!--this is: 34 -->

Read a File into a variable

Here's a function that I made long ago to read the contents of a file in a variable. This function accepts the file name as parameter & is a bit raw, but it serves my purpose, so hopefully it'll serve others as well.

Code:

Private Function readMyFile(pFileName)
SET FSO = Server.CreateObject("Scripting.FileSystemObject")
IF (TRIM(pFileName)="") THEN
EXIT FUNCTION
ELSE
IF FSO.FileExists(Server.MapPath(pFileName)) THEN
SET mFile = FSO.OpenTextFile(Server.MapPath(pFileName))
readMyFile = mFile.ReadAll
ELSE
readMyFile = "File Not Found"
END IF
END IF
SET mFile = NOTHING
SET FSO = NOTHING
End Function