Page 1 of 1

saving file to path

Posted: Wed Apr 09, 2008 4:55 pm
by reelstuff
I have a folder path, $folder_path1 which works as expected,

I am attempting to find a way to put or save a file from a field without using the dialog box,

I looked at the docs and tried to find different way to do this,

Code: Select all

put the text of fld Field_three into URL "file:test.txt"

//but now how to get the file test.txt to go to the correct directory as //defined by
$folder_path1
If I do this,

Code: Select all

get $folder_path1
the path is stored in the variable it,
(I believe)

So I did a test to see if that were true, by using a button and field, and that does seem to be the case, now I am trying to figure out how to use the path to put or save a file directly into that dir path and of course name that file accordingly.

I could just use ask, and it does work that way but I hate to have the user go through that process over and over again, so that is why I am looking at directly moving the contents of the file into the directory path.

Any thoughts and or advice, thanks.

Posted: Wed Apr 09, 2008 5:25 pm
by Mark
Hi reelstuff,

First of all, never use the $ keyword in front of variable, unless that variable is actually an environment variable, meant to communicate with the operating system.

If here is a folder folderPath1, you can put data into a file in that folder using the following syntax:

Code: Select all

put myData into url ("file:" & folderPath1 & "/filename.txt")
Best,

Mark

Posted: Wed Apr 09, 2008 6:20 pm
by reelstuff
Mark wrote:Hi reelstuff,

First of all, never use the $ keyword in front of variable, unless that variable is actually an environment variable, meant to communicate with the operating system.

If here is a folder folderPath1, you can put data into a file in that folder using the following syntax:

Code: Select all

put myData into url ("file:" & folderPath1 & "/filename.txt")
Best,

Mark
BTW thanks a lot for the help and advise,


Thanks Mark, that makes sense,


here is the code I am using,

Code: Select all

on mouseUp
  -- You said that I should not use the $ in this way is that correct. 
  --I tried it both ways just to see, and the folder path is generated, with the use of the fourth line.
  -- however, the file does not end up in the folderPath1 directory location. 
  --get $folderPath1
put the text of fld Field_one into myData
put myData into URL ("file:" & folderPath1 & "/test.txt")
end mouseUp

Now, I continued testing, and when I use this code

Code: Select all

on mouseUp
 get $folderPath1
put the text of fld Field_one into myData
put myData into URL ("file:" & it & "/test.txt")
end mouseUp
It works, but I dont want to use the code in the wrong way because it might cause a problem somewhere else.