May 16, 2024, 02:05:23 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Deletefile

Started by king2k, September 09, 2008, 04:40:40 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

king2k

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

billhsln

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
When all else fails, get a bigger hammer.

Ionic Wind Support Team

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. 
Ionic Wind Support Team

king2k

Thanks! I see it now. My bad   :)