Tutorials to .com

Tutorials to .com » Asp » Encoding » A URL string in the procedure with examples of links

A URL string in the procedure with examples of links

Print View , by: iSee ,Total views: 12 ,Word Count: 760 ,Date: Wed, 3 Jun 2009 Time: 8:26 PM

Sometimes we may have such a request, if we enter a period the link with the text, such as: "Today, I visited the website of China Central Television: http://www.cctv.com" Well, we hope to automatically for our "http://www.cctv.com" link to add a few characters, in fact, many sites have this feature, therefore, Afghanistan has to try to write more than a small program, one can use to facilitate, the other can also be provided for the beginners that the source code, so the process of code written in the Arab-Israeli than the easy-to-understand as possible, so that in some places appear to have been Grosso. Of course, you should read to the Arab-Israeli than the. Stand on the Arab-Israeli Balance: http://www.zydn.net/index.asp experts welcomed the criticism.

Well. Here are some basic ideas of this process

1. First of all, find out which section of text links, they are stored in array

2. To identify their location in the text, they are stored in the array.

3. According to these locations to an entire paragraph of text into a short, in order to insert the link in the middle.

4. In the middle to insert the link, and this section of the text of paragraph together.

Well, the basic idea is, in fact, in front of Step 3 can be completed together, but in order to easily understand the procedure, I had separated them.

In order to facilitate the use, I put them into a Function and the way the name from a CTOU ()

Usage:

1 Copy the following code to a file at any one location,

2 should be stored in variables such as the characters in the MYDOC add links using MYDOC = CTOU (MYDOC) on the list.

Code is as follows:

Function CTOU (MYCH)
On Error Resume next
TE1 = MYCH
IF INSTR (TE1, "_bLaNk") = 0 THEN
TE2 = LCASE (TE1)
zcd = len (te2)
dim star (100), myend (100), myurl (100), te3 (100,2)
for i = 1 to 100
CD = LEN (TE2)
STA = INSTR (TE2, "http://")
if sta = 0 then
STAR (I) = ZCD +1
exit for
END IF
urla = mid (te2, sta, 50)
urcd = instr (urla, "")
if urcd = 0 then urcd = instr (urla, "")
if urcd = 0 then urcd = instr (urla, "<br>")
if urcd = 0 then urcd = instr (urla, chr (34))
if urcd = 0 then urcd = instr (urla ,"'")
if urcd = 0 then urcd = 50
myurl (i) = mid (te2, sta, urcd-1)
MYEN = STA + URCD
if myen> = CD then exit for
te2 = right (te2, CD-myen +2)
next
'Over a period to identify which URL
TE2 = LCASE (TE1)
FOR II = 1 TO I
IF MYURL (II )<>"" THEN

STAR (II) = INSTR (TE2, MYURL (II) & "")
IF STAR (II) = 0 THEN STAR (II) = INSTR (TE2, MYURL (II) & "")
IF STAR (II) = 0 THEN STAR (II) = INSTR (TE2, MYURL (II) & "<br>")
IF STAR (II) = 0 THEN STAR (II) = INSTR (TE2, MYURL (II) & chr (34))
IF STAR (II) = 0 THEN STAR (II) = INSTR (TE2, MYURL (II )&"'")
IF STAR (II) = 0 THEN STAR (II) = INSTR (TE2, MYURL (II))
MYEND (II) = STAR (II) + LEN (MYURL (II))
END IF
NEXT
'Over a period of these URL to find the beginning and the end position
TE2 = TE1
for i1 = 1 to i
if i1 = 1 then
te3 (i1, 1) = mid (te2, 1, star (i1) -1)
else
te3 (i1, 1) = mid (te2, myend (i1-1), star (i1)-myend (i1-1))
end if
te3 (i1, 2) = mid (te2, star (i1), len (myurl (i1)))
next
'Over a period of the original into a string in order to insert the above link
for ii = 1 to i
IF MYURL (II )<>"" THEN
newte = newte & te3 (ii, 1) & "<a target='_bLaNk' href='"&te3(ii,2)&"'>" & te3 (ii, 2 )&"</ a> "
ELSE
newte = newte & te3 (ii, 1)
END IF
next
'Over a period of inserting links
CTOU = NEWTE
ELSE
CTOU = TE1
END IF
END Function


Asp Script encoding Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.