Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 FSO ReadLine and Instr

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!
Before posting, make sure you have read this topic!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
   

T O P I C    R E V I E W
Carefree Posted - 26 December 2009 : 00:53:38
I want to extract just mp3 files from a playlist using FSO. I thought this would do it, but it returns all lines. Any clue?


<%
dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Const FSOForReading = 1
Dim objTextStream
Set objTextStream = objFSO.OpenTextFile("c:\Playlist.m3u", FSOForReading)
Do while not objTextStream.AtEndOfStream
	if instr(objTextStream.ReadLine, ".mp3") then
		Response.Write	objTextStream.ReadLine & "<br>"
	end if
Loop
objTextStream.Close
set objTextStream = Nothing 
%>
4   L A T E S T    R E P L I E S    (Newest First)
cripto9t Posted - 26 December 2009 : 15:34:05
yep default comparison for inStr is binary. Just looked it up .

I trim all text out of habit. Been burned too many times by not using it .
Carefree Posted - 26 December 2009 : 12:33:06
Apparently the necessary ingredient was trimming the string. It works with/without a comparison to > 0 as long as it's trimmed first. Thanks.
cripto9t Posted - 26 December 2009 : 12:02:40
What Rui said and i don't know if you can check the line like that.

Try this if you haven't got it working yet
<%
dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Const FSOForReading = 1
Dim objTextStream
Set objTextStream = objFSO.OpenTextFile("c:\Playlist.m3u", FSOForReading)
dim tmpStr
Do while not objTextStream.AtEndOfStream
        tmpStr = trim(objTextStream.Readline)
	if instr(tmpStr,".mp3") > 0 then
		Response.Write	tmpStr & "<br>"
	end if
Loop
objTextStream.Close
set objTextStream = Nothing 
%>
ruirib Posted - 26 December 2009 : 08:26:54
I think the correct way to test for a InStr match is to check if it returns a value > 0.

Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000 Version 3.4.07