Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 wtd, ruby questions
Index -> Programming, Ruby -> Ruby Help
Goto page 1, 2, 3, 4, 5, 6, 7, 8, 9  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
dsantamassino




PostPosted: Thu Nov 04, 2004 10:56 pm   Post subject: wtd, ruby questions

hi wtd,

here is my post on Ruby questions..



Save your program (yes, that's a program!) as calc.rb (the .rb is what we usually put at the end of programs written in Ruby). Now run your program by typing ruby calc.rb into your command line. It should have put a 3 on your screen. See, programming isn't so hard, now is it?

ok i saved it as calc.rb but where and how do i or where do i type in ruby calc.rb ??
Sponsor
Sponsor
Sponsor
sponsor
Hikaru79




PostPosted: Thu Nov 04, 2004 11:01 pm   Post subject: (No subject)

I think he was assuming you were working in a UNIX environment, where 'ruby calc.rb' would look in the PATH for 'ruby' and then run it with the argument 'calc.rb'.

Not sure how that would work in Windows. Does Windows even have a global path? Try going "Start->Run" and putting "ruby calc.rb" there... ionno. Check the documentation of wherever you installed the ruby interpreter/compiler.
dsantamassino




PostPosted: Thu Nov 04, 2004 11:03 pm   Post subject: (No subject)

Hikaru79 wrote:
I think he was assuming you were working in a UNIX environment, where 'ruby calc.rb' would look in the PATH for 'ruby' and then run it with the argument 'calc.rb'.

Not sure how that would work in Windows. Does Windows even have a global path? Try going "Start->Run" and putting "ruby calc.rb" there... ionno. Check the documentation of wherever you installed the ruby interpreter/compiler.


I did typed that in run just now and it flashed a black windows but nothing happened.
wtd




PostPosted: Thu Nov 04, 2004 11:04 pm   Post subject: (No subject)

Which version of Windows are you using?

For Win 98, ME:

Go to Start -> Run, and type "command". This will give you a command prompt. You'll need to "cd" (change directory) to the directory where you saved calc.rb.

For Win 2000, XP:

Go to Start -> Run, and type "cmd". This will give you a command prompt. You'll need to "cd" (change directory) to the directory where you saved calc.rb.
wtd




PostPosted: Thu Nov 04, 2004 11:05 pm   Post subject: (No subject)

dsantamassino wrote:
Hikaru79 wrote:
I think he was assuming you were working in a UNIX environment, where 'ruby calc.rb' would look in the PATH for 'ruby' and then run it with the argument 'calc.rb'.

Not sure how that would work in Windows. Does Windows even have a global path? Try going "Start->Run" and putting "ruby calc.rb" there... ionno. Check the documentation of wherever you installed the ruby interpreter/compiler.


I did typed that in run just now and it flashed a black windows but nothing happened.


It's doing something, but your program runs and then finishes and Windows thinks it's done so it closes the output window. If you had a machine 100x slower, you might see something. Smile
dsantamassino




PostPosted: Thu Nov 04, 2004 11:08 pm   Post subject: (No subject)

wtd wrote:
Which version of Windows are you using?

For Win 98, ME:

Go to Start -> Run, and type "command". This will give you a command prompt. You'll need to "cd" (change directory) to the directory where you saved calc.rb.

For Win 2000, XP:

Go to Start -> Run, and type "cmd". This will give you a command prompt. You'll need to "cd" (change directory) to the directory where you saved calc.rb.


I dont have a clue about commands. I saved it to my E drive so i went cd E:\ but i know thats wrong. Im running Win XP Pro SP2.
wtd




PostPosted: Thu Nov 04, 2004 11:10 pm   Post subject: (No subject)

dsantamassino wrote:
wtd wrote:
Which version of Windows are you using?

For Win 98, ME:

Go to Start -> Run, and type "command". This will give you a command prompt. You'll need to "cd" (change directory) to the directory where you saved calc.rb.

For Win 2000, XP:

Go to Start -> Run, and type "cmd". This will give you a command prompt. You'll need to "cd" (change directory) to the directory where you saved calc.rb.


I dont have a clue about commands. I saved it to my E drive so i went cd E:\ but i know thats wrong. Im running Win XP Pro SP2.


Ah. To change directories...

code:
C:\Whatever\Yada\Yada> E:

E:\> cd "the directory\where\I\saved\the file"

E:\the directory\where\I\saved\the file> ruby calc.rb


Should look something like that. Learning how to use the command-line is key to learning how to program.
dsantamassino




PostPosted: Thu Nov 04, 2004 11:15 pm   Post subject: (No subject)

wtd wrote:
dsantamassino wrote:
wtd wrote:
Which version of Windows are you using?

For Win 98, ME:

Go to Start -> Run, and type "command". This will give you a command prompt. You'll need to "cd" (change directory) to the directory where you saved calc.rb.

For Win 2000, XP:

Go to Start -> Run, and type "cmd". This will give you a command prompt. You'll need to "cd" (change directory) to the directory where you saved calc.rb.


I dont have a clue about commands. I saved it to my E drive so i went cd E:\ but i know thats wrong. Im running Win XP Pro SP2.


Ah. To change directories...

code:
C:\Whatever\Yada\Yada> E:

E:\> cd "the directory\where\I\saved\the file"

E:\the directory\where\I\saved\the file> ruby calc.rb


Is this right so far?? I dont think it is because i got an error.

E:\>cd ruby calc.rb\E

The system cannot find the path specified.

Should look something like that. Learning how to use the command-line is key to learning how to program.
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Thu Nov 04, 2004 11:20 pm   Post subject: (No subject)

You don't want to cd to the file itself, just the directory it's in.

Consider if I start out in C:\ and I have calc.rb saved in E:\Programming\Ruby\

code:
C:\> E:

E:\> cd "Programming\Ruby"

E:\Programming\Ruby>


Now I'm in the right directory.

code:
E:\Programming\Ruby> ruby calc.rb
dsantamassino




PostPosted: Thu Nov 04, 2004 11:25 pm   Post subject: (No subject)

wtd wrote:
You don't want to cd to the file itself, just the directory it's in.

Consider if I start out in C:\ and I have calc.rb saved in E:\Programming\Ruby\

code:
C:\> E:

E:\> cd "Programming\Ruby"

E:\Programming\Ruby>


Now I'm in the right directory.

code:
E:\Programming\Ruby> ruby calc.rb


ok it worked. Now let me read some more of the tutorial..
wtd




PostPosted: Thu Nov 04, 2004 11:29 pm   Post subject: (No subject)

Happy hacking. Smile
dsantamassino




PostPosted: Fri Nov 05, 2004 6:18 pm   Post subject: (No subject)

My next set of Ruby questions will be in this topic. At the rate im going i probably wont get nothing done..
wtd




PostPosted: Fri Nov 05, 2004 6:33 pm   Post subject: (No subject)

dsantamassino wrote:
My next set of Ruby questions will be in this topic. At the rate im going i probably wont get nothing done..


Just remember.. one step at a time. Make sure you understand each idea before going on to the next. The author of a tutorial will assume you do.
dsantamassino




PostPosted: Fri Nov 05, 2004 6:41 pm   Post subject: (No subject)

wtd wrote:
dsantamassino wrote:
My next set of Ruby questions will be in this topic. At the rate im going i probably wont get nothing done..


Just remember.. one step at a time. Make sure you understand each idea before going on to the next. The author of a tutorial will assume you do.


I got a great idea.. Im getting no where. Im more on break.. how about u and i go over the tutorial togther in this thread??
wtd




PostPosted: Fri Nov 05, 2004 6:44 pm   Post subject: (No subject)

Fine with me. Just give me some time to reply. I'm writing an introduction/tutorial on Python's generators and iterators.
Display posts from previous:   
   Index -> Programming, Ruby -> Ruby Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 9  [ 129 Posts ]
Goto page 1, 2, 3, 4, 5, 6, 7, 8, 9  Next
Jump to:   


Style:  
Search: