Help with a delete script...

Results 1 to 2 of 2

Thread: Help with a delete script...

  1. #1
    Join Date
    Dec 1969

    Default Help with a delete script...

    Hi<BR><BR>I try to develope a homepage scrip which let&#039s the users make their one homepages in 5 minutes.<BR>This script has a "delete this site" option which deletes a textfile including the header and <BR>text of the page they are deleting.<BR><BR>The site is built on lot&#039s of include files, one for each header, and one for each text file...<BR><BR>If you have 5 pages do you have theese files:<BR><BR><BR><BR>header2. inc<BR><BR><BR><BR>he<BR><BR><BR> <BR><BR>I thought that if the user is deleting the 3. site does the script have to delete and<BR> and rename the to and rename the to and the <BR> to and the to<BR><BR>I made this script which I thought should do it, and it also does 80% of the times i run it, <BR>but sometimes do I get an error that is saying that the spessified file doesn&#039t exist...<BR><BR>The script looks like this:<BR><BR>&#060;%<BR>Dim fso<BR>Dim side<BR>Dim tall<BR>Dim Sted<BR><BR>&#039Where the script has to search for the files...<BR>Sted="Location"<BR><BR>Set fso=CreateObject("Scripting.FileSystemObject")<BR> <BR>&#039The site which is going to be deleted<BR>side=Request.QueryString("side")<BR><BR >&#039session("anntallegenmeny") is telling the script how many<BR>&#039different pages the user has...<BR><BR>&#039I thought that if the user is trying to delete the last file then doesn&#039t I have to rename the other files...<BR>If session("anntallegenmney")=side then<BR>fso.DeleteFile Sted & session("username") & " ext" & side & ".inc", False<BR>fso.DeleteFile Sted & session("username") & "header" & side & ".inc", False<BR><BR>else<BR><BR>&#039If the user isn&#039t going to delete the last file...<BR><BR>&#039Here does the script delete the file which the user spesifyed so it can move the other files...<BR>fso.DeleteFile Sted & session("username") & " ext" & side & ".inc", False<BR>fso.DeleteFile Sted & session("username") & "header" & side & ".inc", False<BR><BR>&#039This part is moving the files...<BR>For nummer = side to session("anntallegenmeny")-1<BR>fso.MoveFile Sted & " ext" & nummer+1 & ".inc", Sted & " ext" & nummer & ".inc" <BR>fso.MoveFile Sted & "header" & nummer+1 & ".inc", Sted & "header" & nummer & ".inc" <BR>Next<BR><BR>&#039End of if comand...<BR>end if<BR><BR>Set fso=nothing<BR>%&#062;<BR><BR>Can you find any errors? Or tell me why it does works some time, but not always?<BR>I can&#039t fint any errors myself...<BR><BR>Please help me!<BR><BR><BR><BR>Best regards,<BR>Sebastian P. Eide (15) Norway

  2. #2
    Join Date
    Dec 1969

    Default RE: Help with a delete script...

    What you need is error checking my friend. Check to see if the file exists before you try to delete it or move it. You can also add &#039on error resume next&#039 and the top of the page and add this sub in the page and call it after every FSO function, thus trapping your error. You would want to remove this before going live, but it&#039s good for debugging. <BR><BR>sub checkErr<BR>if err &#060;&#062; 0 then<BR> response.write "<BR>error occured: " & err.number & " - " & err.description<BR>end if<BR>end sub <BR><BR>Good Luck, SamC

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts