Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

File Handling

For general discussion related FlowStone

Re: File Handling

Postby RJHollins » Thu Mar 10, 2016 9:04 pm

cool ...

Is there a way to RENAME a file [using RUBY] ?
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Re: File Handling

Postby Nubeat7 » Thu Mar 10, 2016 9:11 pm

yes, just updated the list above..
for more watch here:
http://ruby-doc.org/core-1.9.3/File.html
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: File Handling

Postby RJHollins » Thu Mar 10, 2016 9:47 pm

Thanks for the LINK. Was having trouble finding the Ruby 1.9.3.

BookMarked 8-)
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Re: File Handling

Postby S1User » Thu Mar 10, 2016 9:48 pm

That's great. Now I just need to study Ruby to find out how to trigger subs with those code lines.

I know how to push strings in and out with "@" I/O, but not yet clear on how to trigger a Ruby sub on demand.

Ah... wait... I think I see. Just replace my modules with a Ruby module and those things will just run.

Great. Off to give it a go.
S1User
 
Posts: 58
Joined: Thu Sep 17, 2015 4:05 pm

Re: File Handling

Postby S1User » Thu Mar 10, 2016 11:57 pm

Oh man. :shock: I've been working way too hard not using Ruby modules. This below is much cleaner than the rats nest of primitives I had doing the same thing before.

You guys are great.

Schematic: http://i.imgur.com/ynRhihi.png
S1User
 
Posts: 58
Joined: Thu Sep 17, 2015 4:05 pm

Re: File Handling

Postby RJHollins » Fri May 13, 2016 6:44 am

Back to an issue I'm having :cry:

It seems FS RUBY does not have the FileUtils class.

What I'm trying to do is:

1. Copy a file to a new dest folder ... then,

2. Re-name the new [copied] file.

3. Insuring that the original file remains intact at original location.

I've used the posted 'File.rename(@old_name, @new_name)' , but it is removing the original file :roll:

Note: The goal. I have to make copies of a single file and rename them as new files in a new folder. There could be a dozen or more copies]. I'm using a filename list to increment through in the rename process.

Note 2. I also tried the EXEC primitive to do the copy. I can't seem to get that to work.

I suck :oops: :twisted:
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Re: File Handling

Postby Walter Sommerfeld » Fri May 13, 2016 11:38 am

Hi,

here a method 4U i got from DWB (hope he don't mind)

Code: Select all
def copy_file(src,dest)
    File.open(src, 'rb') do |s|
        File.open(dest, 'wb', s.stat.mode) do |f|
            IO.copy_stream(s, f)
        end
    end
end

Keep on Doing!
Walter
User avatar
Walter Sommerfeld
 
Posts: 249
Joined: Wed Jul 14, 2010 6:00 pm
Location: HH - Made in Germany

Re: File Handling

Postby RJHollins » Fri May 13, 2016 5:19 pm

Thanks Walter [....and DWB]

I'll give this a go when I get back.

Appreciate.
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Re: File Handling

Postby RJHollins » Sat May 14, 2016 12:37 am

hmmm ... no luck getting this code working ... as yet. :|
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Re: File Handling

Postby Walter Sommerfeld » Sat May 14, 2016 11:40 am

Here u go...

Have Phun ;-)

Warning: Dest will be overwritten and path must exist...
Attachments
copy file fom DWB in ruby (sun mod).png
...I think U need Admin rights because of ProgFiles path 4 this test schematic:
copy file fom DWB in ruby (sun mod).png (288.42 KiB) Viewed 18348 times
copy file fom DWB in ruby (sun mod).fsm
(1.31 KiB) Downloaded 816 times
User avatar
Walter Sommerfeld
 
Posts: 249
Joined: Wed Jul 14, 2010 6:00 pm
Location: HH - Made in Germany

PreviousNext

Return to General

Who is online

Users browsing this forum: No registered users and 45 guests