[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

run scipt under irb

Ben

4/17/2006 9:51:00 PM

It should be simple, but I have not found the answer yet.

How to run File1.rb under irb prompt?

I can run script under DOS prompt:

C:\> ruby File1.rb

But how can I do this under irb prompt:

irb(main):001:0> File1.rb <== did not work
irb(main):001:0> File1 <== did not work

Thanks.

Ben

3 Answers

greg.rb

4/17/2006 10:30:00 PM

0

File1 should be in the search path....type:

require 'File1'

or

load 'File1.rb'

from ruby central:
8.12 What is the difference between load and require?

load will load and execute a Ruby program (*.rb).

require loads Ruby programs as well, but will also load binary Ruby
extension modules (shared libraries or DLLs). In addition, require
ensures that a feature is never loaded more than once.

Ben

4/18/2006 2:16:00 PM

0

Thanks.

So using require is a better choice.

Ross Bamford

4/18/2006 5:58:00 PM

0

On Mon, 17 Apr 2006 22:51:29 +0100, Ben <laserbin@gmail.com> wrote:

> It should be simple, but I have not found the answer yet.
>
> How to run File1.rb under irb prompt?
>
> I can run script under DOS prompt:
>
> C:\> ruby File1.rb
>
> But how can I do this under irb prompt:
>
> irb(main):001:0> File1.rb <== did not work
> irb(main):001:0> File1 <== did not work
>

Not sure if this is what you're after, but you can pass a filename to irb
to have it executed line-by-line, e.g.:

irb File1.rb


--
Ross Bamford - rosco@roscopeco.remove.co.uk