Copy and paste a file on SDcard?

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

User avatar
RobH
Posts: 95
Joined: Wed Sep 11, 2013 7:51 pm
Has thanked: 29 times
Been thanked: 17 times
Contact:

Copy and paste a file on SDcard?

Postby RobH » Fri Sep 13, 2013 10:48 pm

Can anyone give pointers on copying and pasting a file from an SDcard to the same SDcard? I have been in a discussion with my Flowcode sparring partner about it today (we're both learning FC) and I think you have to do it in steps, like:

write file1 name to string1
make file2 name with string2 (modified string derived from string1 )
open file1 and copy contents to string3
open file2 and write string3

Thanks,
-Rob

User avatar
Benj
Matrix Staff
Posts: 14573
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4600 times
Been thanked: 4240 times
Contact:

Re: Copy and paste a file on SDcard?

Postby Benj » Tue Sep 17, 2013 3:17 pm

Hi Rob,

Which version of Flowcode are you using?

In v5.5 and v6 I added a option for simultaneous files to be manipulated allowing you to copy from one file to another without having to keep: opening file A, moving to the next uncopied sector, reading the data, opening file B, moving to the next free sector, writing the data.

User avatar
RobH
Posts: 95
Joined: Wed Sep 11, 2013 7:51 pm
Has thanked: 29 times
Been thanked: 17 times
Contact:

Re: Copy and paste a file on SDcard?

Postby RobH » Tue Sep 17, 2013 6:15 pm

FC6 trial, PIC pack, and soon to be Pro pack. I'm loving this programming environment, btw!

User avatar
Benj
Matrix Staff
Posts: 14573
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4600 times
Been thanked: 4240 times
Contact:

Re: Copy and paste a file on SDcard?

Postby Benj » Thu Sep 19, 2013 10:58 am

Hello Rob,

Here is a quick example I've put together. Not tested it but I think it should work ok.
Attachments
FAT File Copy.fcfx
(12.71 KiB) Downloaded 71 times
These users thanked the author Benj for the post:
RobH (Thu Sep 19, 2013 1:58 pm)
Rating: 5.26%
 

User avatar
RobH
Posts: 95
Joined: Wed Sep 11, 2013 7:51 pm
Has thanked: 29 times
Been thanked: 17 times
Contact:

Re: Copy and paste a file on SDcard?

Postby RobH » Thu Sep 19, 2013 1:49 pm

Thanks Ben. I'll check this out today.

User avatar
RobH
Posts: 95
Joined: Wed Sep 11, 2013 7:51 pm
Has thanked: 29 times
Been thanked: 17 times
Contact:

Re: Copy and paste a file on SDcard?

Postby RobH » Fri Sep 20, 2013 1:20 am

I checked you code and it kind of works, if you run the simulation twice. The first run of the simulation will successfully make the text file but doesn't add the text therein. If you run a second time, it will write the text. I haven't tried it on real hardware yet.

-Rob
These users thanked the author RobH for the post:
Benj (Fri Sep 20, 2013 2:23 pm)
Rating: 5.26%
 

User avatar
Benj
Matrix Staff
Posts: 14573
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4600 times
Been thanked: 4240 times
Contact:

Re: Copy and paste a file on SDcard?

Postby Benj » Fri Sep 20, 2013 9:15 am

Hi Rob,

That's interesting, wonder if you need a delay just after creating the file for the sim to work correctly first time.

User avatar
RobH
Posts: 95
Joined: Wed Sep 11, 2013 7:51 pm
Has thanked: 29 times
Been thanked: 17 times
Contact:

Re: Copy and paste a file on SDcard?

Postby RobH » Fri Sep 20, 2013 1:49 pm

That's what I was going to try next. I'll let you know what I come up with...
These users thanked the author RobH for the post:
Benj (Fri Sep 20, 2013 2:23 pm)
Rating: 5.26%