how to write text file to root of HD

Edwin Gore edgore at shinra.com
Tue Jul 1 11:26:00 EDT 2003


You are going to run into lots of cross platform problems witht he code below. On windows, for example, it will try to write to "\A:", which is probably not what you are after. I don't have a Mac handy, but I'm guessing that it's probably going to do something weird there as well.

If what you are looking for is to place a text file in an easy to get to location for the user then I would recommend using the specialFolderPath function to put it on the desktop

set the defaultfolder to specialFolderPath(desktop)
open file "filetowrite.txt" for text write
write "test" to file "filetowrite.txt"
close file "filetowrite.txt"

or, if you really want it to go to the root directory (of the drive that the stack is on)then

-- find out where the stack is located
put the filename of this stack into lStackLocation
set the itemdelimiter to "/" -- to parse directories
set the defaultfolder to item 1 of lStackLocation & "/"
open file "filetowrite.txt" for text write
write "test" to file "filetowrite.txt"
close file "filetowrite.txt"

I've tested the above on Windows and it works - on Mac and LInux your milage may vary...

>> put "\" & line 1 of the volumes &
>"\filetowrite.txt" into filetowrite
>> 
>> open filetowrite for write
>> write "test" to file filetowrite
>> close file filetowrite
>
>It depends on the OS you're running.
>
>Given the range of potential issues with file I/O,
>it's a useful habit to
>check the result after opening a file.
>
>-- 
> Richard Gaskin 
> Fourth World Media Corporation
> Developer of WebMerge 2.2: Publish any database on
>any site
>
> Ambassador at FourthWorld.com	  
>http://www.FourthWorld.com
> Tel: 323-225-3717			  AIM:
>FourthWorldInc
>
>_______________________________________________
>use-revolution mailing list
>use-revolution at lists.runrev.com
>___________________________________________________
>________
>http://lists.runrev.com/mailman/listinfo/use-revolu
>tion



More information about the use-livecode mailing list