IonicWind Software

IWBasic => General Questions => Topic started by: king2k on September 09, 2008, 04:40:40 PM

Title: Deletefile
Post by: king2k on September 09, 2008, 04:40:40 PM
Hey,

I'm trying to use Deletefile function. It works fine if I use something like this: "Deletefile("d:\\test\\text.txt")".
My program gets full path as an agrument to the program. Ex: "d:\test\text.txt".
As I understand the Deletefile must have the "\\" notation.

My problem is now to convert the path from "d:\test\text.txt" to "d:\\test\\text.txt"
So far this is my best shot:

SUB convert_path(path:STRING),STRING

STRING out
out = ""

FOR x= 1 to len(path)
out += MID$(path,x,1)
IF MID$(path,x,1) = CHR$(92)
out += CHR$(92)
ENDIF
NEXT x
RETURN out
ENDSUB


This is not working since it interpret "\t" as tab and "\n" as new line etc.

Is there any trick to avoid this? Or any other function I can use?
Suggestions appreciated.

Regards,
Kim
Title: Re: Deletefile
Post by: billhsln on September 09, 2008, 05:51:43 PM
If your variable of path has:   d:\test\text.txt  in it then it should work ok.  You see "\\", but this stores \ not \\.  "\\" is EBasics way of storing a \.

You can use   Deletefile(path) and it should work fine, unless you do not have sufficient access to delete the file.

Bill
Title: Re: Deletefile
Post by: Ionic Wind Support Team on September 09, 2008, 06:00:13 PM
Review the users guide on string literals.  It is only when you are typing a string in the source code that you need to escape certain characters. 
Title: Re: Deletefile
Post by: king2k on September 10, 2008, 03:36:14 AM
Thanks! I see it now. My bad   :)