Create a file to all drives

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Create a file to all drives

Post by alemrantareq » Thu Dec 04, 2008 7:13 am

Hi everybody,
I need a solution. I want to create a file "MyFile.txt" in all the drives. How to do that? I've tried this script -

Code: Select all

on mouseUp
put the volumes & "/MyFile.txt" into tfile
open file tfile
end mouseUp
it creates that file only into the last volume, not all the volumes. Pls, show me the way....

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Thu Dec 04, 2008 11:10 am

Dear alemrantareq,

The volumes returns a linefeed-delimited list. You need to make a repeat structure that, with each loop, takes a line from the list and puts it, together with "/My File.txt" into a variable. You can use this variable with the open command.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Thu Dec 04, 2008 1:26 pm

You would need a repeat similar to the one below

Code: Select all

on mouseUp
  repeat for each line theVolume in the volumes
    put "Test" into URL (file:" & theVolume & "/test.txt")
  end repeat
end mouseUp
HTH,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Post by alemrantareq » Fri Dec 05, 2008 12:57 pm

Hi Janschenkel,
Thanks for your reply. Thanks for your scripting. I can make "Test.txt" to the all volumes by appling this script -

Code: Select all

on mouseup
 repeat for each line theVolume in the volumes
 put empty into url ("file:" & theVolume & "/Test.txt")
end mouseUp
After making, if I go to check that file by this script -

Code: Select all

on mouseUp
 repeat for each line theVolume in the volumes
 put theVolume & "/Test.txt" into tfile
 if there is a file tfile then
  answer "Found"
 end if
end mouseUp
But it doesn't work.
Again, if I try to make that file by this script -

Code: Select all

on mouseup
 repeat for each line theVolume in the volumes
 put url ("file:" & theVolume & "/Test.txt") into myfile
 open file myfile
end mouseUp
It doesn't work too. Why? Pls, help.....

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Fri Dec 05, 2008 1:22 pm

Dear alemrantareq,

You need to close your repeat loops. Repeat loops look like this:

Code: Select all

repeat for each line myLine in myList
  -- do everything between repeat and end repeat
  -- many times
end repeat
Do your scripts work, if you close the repeat loops correctly?

Best regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Post by alemrantareq » Sat Dec 06, 2008 5:14 am

Hi Mark,
Thanks for your reply and sorry to say I forgot to write "end repeat" in this forum but it was in my script and having it, I couldn't check that file using the second code and couldn't make that file using the third code.

alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Post by alemrantareq » Sat Dec 13, 2008 12:26 pm

Hi everybody,
Its a ling time nobody takes a response for my problem. I repeated my problem again - I want to check a text file in all of my volumes. To do this, I've made a script for a btn -

Code: Select all

on mouseUp 
 repeat for each line theVolume in the volumes 
 put theVolume & "/Test.txt" into tfile 
 if there is a file tfile then 
  answer "Found" 
 end if 
 end repeat
end mouseUp
But having the text file in some of my volumes, it doesnt show the message. Why ????????????

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Post by malte » Sat Dec 13, 2008 1:17 pm

Hi alemrantareq,

did you actually look at the value of the volumes?

In the messagebox:

put the volumes

What do you get there? Are all your drives listed in there? Are you logged in with permissions to write to / read from all drives?

Your script looks just fine to me. If it does not answer it is either, because the file is not there (you could check that with an else statement after your answer command) or because an error occured (check the result instead of it. If the result is not empty, something went wrong) and see what you got there.

Hope that helps a bit,,

Malte

alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Post by alemrantareq » Mon Dec 15, 2008 11:21 am

Hi malte,
Thanks for your reply. After getting your reply, I made another btn with a new stack and then put my script into it. It works nicely. I think my old stack had one or more problems.

Post Reply