ASP learning the FSO component Operation example Skill (6)

Source: Internet
Author: User
fso| Skills

Next, the following example specifically covers the question of the open method, remember? Under normal circumstances, open the file is to use the FSO. OpenTextFile ("C:\testfile.txt", 1), and the function of parameter 1 is to open the file in read-only mode. This file cannot be written to. What if a file already exists and an append write is required? Simple, the parameter is 8.

What's the use? Oh, Amazon's network story solitaire is so: can Solitaire need to first show the original story, and then add their own stories to write files. One of the most exquisite writing files is the append write. So the following can be achieved.

Second, story. Asp

  <%if not request. Form ("nextline") = "" Then
  set fso=server.createobject ("Scripting.FileSystemObject")
   textfile1=server.mappath ("Story.txt")
  set Cnrs=fso. OpenTextFile (textfile1,8)
  cnrs. WriteLine (Request.Form ("nextline"))
  cnrs. The close
  end if
  %> story is as follows: <%
  set fso=server.createobject (" Scripting.FileSystemObject ")
  textfile1=server.mappath (" Story.txt ")
  set Cnrs=fso. OpenTextFile (textfile1,1)
  while not CNRS. AtEndOfStream
  response.write "" & CNRS. Readlinewend
  cnrs.close%>
     <form method= "POST" action= "story.asp" > Please enter a new line for this story:
  <input name= "nextline" type= "text" size= "All" >
   <input type= "Submit" value= "submitted" ></form>

The whole is a very simple read information and add information to the mixed use, I believe there is the basis of the previous understanding should not be a problem. Of course, the lack of a story.txt file, inside the beginning of a good story can be.

Debugging

Next, go on, the main focus is to practice some of the use of functions of skills.

1,instr function: Returns the position in which a string appears for the first time in another string.

For example, now look for the first occurrence of the letter "A" in the string "a110b121c119d1861", you can

<script language=vbs>
my_string = "a110b121c119d1861"
A_num = InStr (my_string, "A")
Alert (A_num)
</script>

The position of the same letter "B" can be determined. Here we go. The key: Advance the letter "A" and "B" in the middle of the value "110".

Remember the mid function? The mid function's main function is to return a specified number of characters from a string.

For example, the current "110" should be from the 2nd bit of the string to get 3 units of value.







Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.