how to write text file to root of HD

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


Oops! I see a mistake...to make the second example work on the Mac and Liux, I *think* you need to do some extra work - try:

-- find out where the stack is located
put the filename of this stack into lStackLocation
set the itemdelimiter to "/" -- to parse directories
-- check to see if you are on Windows and deal with it
if char 2 of lStackLocation is ":" then -- Windows
set the defaultfolder to item 1 of lStackLocation & "/"
else -- Mac and Linux
set the defaultfolder to ("/" & item 1 of lStackLocation & "/")
end if
open file "filetowrite.txt" for text write
write "test" to file "filetowrite.txt"
close file "filetowrite.txt"

>----- ------- Original Message ------- -----
>From: "Edwin Gore" <edgore at shinra.com>
>To: use-revolution at lists.runrev.com
>Sent: Tue, 1 Jul 2003 12:18:35
>
>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
>>________
>>tion
>_______________________________________________
>use-revolution mailing list
>use-revolution at lists.runrev.com
>>__________________________________________________
>_
>>http://lists.runrev.com/mailman/listinfo/use-revol
>u
>http://lists.runrev.com/mailman/listinfo/use-revolu
>tion



More information about the use-livecode mailing list