Jump to content

Recommended Posts

This code is unfinished and still in its planning stage it will not compile.  Im just tring to find a method on how I can read a string and replace a number.  This scripts purpose is to capture the vistors Referer ID and proccess it.  If the referer ID does exist then the script adds 1 to the number at the end of the line.  If the Referer ID does not exist it adds it to the database with a counter value of 1.  Here is an example how the text file will be formated.

yahoo.com,1

google.com,3

somepage.org,9

As of now im completely lost on how to parse the string and add 1 to the ending number.

 

 

As Always Thanx

Grodo

 

<%
'  //////////////////////////////////////////////////////////////////
'  //
'  // 
'  //Based of Rafeeq's array function
'  // rafeeqce@myiris.com
'  // 
'  //
'  // Example: myarray=file("c:\mysongs.list")
'  //
'  //////////////////////////////////////////////////////////////////

  Function File(filename)	
    Dim fso,ts,data

    Const ForReading = 1
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set ts = fso.OpenTextFile(filename, ForReading)

    reDim data(0)

    i=-1

    While not ts.AtEndOfStream
      i=i+1

      Redim Preserve data(i)
      data(i)=ts.ReadLine
    Wend

    ts.Close
    File=data
  End Function
%>
<% 
'Read Data from the file
data=File("refer.txt")
'Get the size of the Array
iArraySize = (UBound(data) - LBound(data)) + 1

'Get the reffering URL
RefURL = Request.ServerVariables("HTTP_REFERER")
'Check if the person was referred by a page or not (e.g. bookmark) 
IF Len(RefURL) = 0 THEN

  'The person was not referred by a page
  InsertIntoID = 1
ELSE
  'The person was referrd by a page
  'Check if the URL already is in the database
  'if it is get the URL's value
  'if not set InsertIntoID = 0
  for (i = 0; i <  iArraySize + 1 ; i++) 
{
	if data(i) = RefURL then
		datalocation = i
                                      // This is just for testing
		response.write("Exists on line" & i )
		ELSE
			InsertIntoID = 0
	END IF
}
End if

'If InsertIntoID = 0 then the URL is a new URL
IF InsertIntoID = 0 THEN
'Insert new url with count = 1
ELSE
	'Add 1 to the counter
END IF

%>

Link to comment
https://forums.phpfreaks.com/topic/65496-asp-how-to-update-a-string/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.