Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 FSO ReadLine and Instr
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Carefree
Advanced Member

Philippines
4224 Posts

Posted - 26 December 2009 :  00:53:38  Show Profile  Reply with Quote
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 
%>

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 26 December 2009 :  08:26:54  Show Profile  Reply with Quote
I think the correct way to test for a InStr match is to check if it returns a value > 0.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

cripto9t
Average Member

USA
881 Posts

Posted - 26 December 2009 :  12:02:40  Show Profile  Reply with Quote
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 
%>

    _-/Cripto9t\-_
Go to Top of Page

Carefree
Advanced Member

Philippines
4224 Posts

Posted - 26 December 2009 :  12:33:06  Show Profile  Reply with Quote
Apparently the necessary ingredient was trimming the string. It works with/without a comparison to > 0 as long as it's trimmed first. Thanks.

Edited by - Carefree on 26 December 2009 12:35:37
Go to Top of Page

cripto9t
Average Member

USA
881 Posts

Posted - 26 December 2009 :  15:34:05  Show Profile  Reply with Quote
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 .

    _-/Cripto9t\-_
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.2 seconds. Powered By: Snitz Forums 2000 Version 3.4.07