Changing the program to work with files

A

Alex Mr

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
 
P

Phlip

Alex said:
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...
 
Z

Zhukov Pavel

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

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

Alex Mr

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 ?
 
P

Phlip

Alex said:
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/ProgrammingRuby/

The chapter "Basic Input and Output" is here:

http://www.ruby-doc.org/docs/ProgrammingRuby/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?
 
D

Dave Bass

Alex said:
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.
 
P

Pablo Q.

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 said:
Use the builtin File class.
--=20
Ing. Pablo Andr=E9s Quir=F3s Sol=EDs
Tel (506) 833-7656
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,666
Latest member
selsetu

Latest Threads

Top