Results 1 to 10 of 10

Thread: FILES WITH ASP & HTML

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    Post

    Can anyone tell me how to very very very simply open a file from the web server.. ie: openning "myfile.txt" when a HTML file is viewed.



    <HTML>
    <HEAD><TITLE>My File</TITLE></HEAD>
    <H1><B>ASP Script</B></H1>
    <BODY>

    <BR>
    <HR>
    <% code to open a file %>
    <BR>
    <% Next %>
    <HR>
    </BODY>
    </HTML>

    Many Thanks

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    Post format

    What if i wanted to format the output somewhat?


    Regards Gary

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Try using the Open statement, as in a normal VB program.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4
    Lively Member
    Join Date
    Jul 2000
    Posts
    104
    Use CSS.

    Or you could use <style></style> tags before and after you open the text file. Just insert the style sheet attributes in the first tag.

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    SSI doesn't care about formatting, it just expands it in-place, so using CSS like that would work. If you want to format the individual parts of the file, then you'd have to open it yourself using ASP. My SSI method was THE simplest way imaginable...
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    use VB

    I would like to use VB to open a file and display it line by line wrapped in ASP tags

    <% vb code %>

    Can you show me how this is done to understand the declarations needed for the web.?

    Many Thanks

  7. #7
    Lively Member
    Join Date
    Jul 2000
    Posts
    104
    You use the FileSystem Object to open and read files.

    Here's some sample code using the object:
    http://msdn.microsoft.com/scripting/...gfsosample.htm

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    whaaaaooh

    **** me.. surely i dont need all that?

  9. #9
    Lively Member
    Join Date
    Jul 2000
    Posts
    104
    To read the file you should only need the following:

    Code:
    Function GetLyrics(FSO)
    
       Dim TextStream
       Dim S
       Dim File
    
       ' There are several ways to open a text file, and several 
       ' ways to read the data out of a file. Here's two ways 
       ' to do each:
    
       Set TextStream = FSO.OpenTextFile(TestFilePath & "\Beatles\OctopusGarden.txt", OpenFileForReading)
       
       S = TextStream.ReadAll & NewLine & NewLine
       TextStream.Close
    
       Set File = FSO.GetFile(TestFilePath & "\Beatles\BathroomWindow.txt")
       Set TextStream = File.OpenAsTextStream(OpenFileForReading)
       Do    While Not TextStream.AtEndOfStream
          S = S & TextStream.ReadLine & NewLine
       Loop
       TextStream.Close
    
       GetLyrics = S
       
    End Function
    Make sure you declare the constants (OpenFileForReading, etc) or if you don't want to declare them just use the constant's value in the method calls.

    [Edited by ttingen on 08-18-2000 at 11:28 AM]

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    WEB PAGE

    Is this for a Web page?

Posting Permissions

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



Click Here to Expand Forum to Full Width