[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Changing the program to work with files

Alex Mr

6/21/2008 6:29:00 PM

Hi every body

I have a program that is working with Console ( input - output)

I wanted to see if anybody can help me to modify it so that it takes its
input from a file (text) and write its output also to a file (binary)

because I am new to Ruby and I dunnot working with files .

Thank you very much
--
Posted via http://www.ruby-....

6 Answers

Phlip

6/21/2008 6:49:00 PM

0

Alex Mr wrote:

> I have a program that is working with Console ( input - output)
>
> I wanted to see if anybody can help me to modify it so that it takes its
> input from a file (text) and write its output also to a file (binary)
>
> because I am new to Ruby and I dunnot working with files .

Google for "the Ruby book" - the free introductory book by the Pragmatic
Programmers.

All introductory language tutorials cover file handling - usually in a much
better way than a newsgroup ever could...

--
Phlip
http://assert2.rubyforge.org/assert_yin...

Zhukov Pavel

6/21/2008 7:00:00 PM

0

On Sat, Jun 21, 2008 at 10:29 PM, Alex Mr <hisastro@gmail.com> wrote:
> Hi every body
>
> I have a program that is working with Console ( input - output)
>
> I wanted to see if anybody can help me to modify it so that it takes its
> input from a file (text) and write its output also to a file (binary)
>
> because I am new to Ruby and I dunnot working with files .
>
> Thank you very much
> --
> Posted via http://www.ruby-....
>
>

which difference with file i/o and stdio that confuse you?

Alex Mr

6/21/2008 7:14:00 PM

0

Hi, Thank you for reply .

May I ask you to help me modify the program to take input form files
instead of Console ?

Can you please modify it for me ? if yes, Can I send the program to you
to do this favor for me ?
--
Posted via http://www.ruby-....

Phlip

6/21/2008 7:56:00 PM

0

Alex Mr wrote:

> May I ask you to help me modify the program to take input form files
> instead of Console ?

When I Google for "ruby book", the very first hit is this:

Programming Ruby: The Pragmatic Programmer's Guide
http://www.ruby-doc.org/docs/Progra...

The chapter "Basic Input and Output" is here:

http://www.ruby-doc.org/docs/Progra...html/tut_io.html

It says things like this:

aFile = File.new("testfile", "r")
# ... process the file
aFile.close

You can change the "r" to a "w" to read the file.

Does that help?

--
Phlip
http://assert2.rubyforge.org/assert_yin...

Dave Bass

6/22/2008 10:20:00 AM

0

Alex Mr wrote:
> I wanted to see if anybody can help me to modify it so that it takes its
> input from a file (text) and write its output also to a file (binary)

Use the builtin File class.
--
Posted via http://www.ruby-....

Pablo Q.

6/23/2008 1:15:00 PM

0

Just change ARGV values with variables from file. This example do the work
for 3 params taking them from command or file.

var1=3D ARGV[0]
var2=3D ARGV[1]
var3=3D ARGV[2]

file =3D 'where_is_the_file_with_param'

file_with_param =3DFile.new(file,"r")
param =3D file_with_param.gets.split(' ',-1)
file_with_param.close()

var1 ||=3D param[0]
var2 ||=3D param[1]
var3 ||=3D param[2]

2008/6/22 Dave Bass <davebass@musician.org>:

> Alex Mr wrote:
> > I wanted to see if anybody can help me to modify it so that it takes it=
s
> > input from a file (text) and write its output also to a file (binary)
>
> Use the builtin File class.
> --
> Posted via http://www.ruby-....
>
>
--=20
Ing. Pablo Andr=E9s Quir=F3s Sol=EDs
Tel (506) 833-7656