473,322 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Importing other files to run ruby programs

Hi all,
I have 2 files which are placed in two different folders. These folders
are not under any Classpath & i am using a windows system.

I have the following snippet of program, which i am stuck with,
File1:
---------------------------------------------------------------------------------
<rubycode>

class Test

puts " This output is from file1 "

end
<rubycode>
---------------------------------------------------------------------------------
FILE 2:
---------------------------------------------------------------------------------
<rubycode>

require "File1"
puts "This output is from File2"

<rubycode>
---------------------------------------------------------------------------------
If File 1 is and File 2 are in two different locations, i get the
following error :
FILE2.rb:1:in `require': no such file to load -- Test (LoadError)
from run.rb:1
If both the files are in same folder ,it works but if they are located
in different locations it fails,
How can make it work, should i provide anything under "require"
Hope this is clear!!

Thanks in Advance
Feb 14 '08 #1
2 3414
improvcornartist
303 Expert 100+
Include the file path in the require statement.
Expand|Select|Wrap|Line Numbers
  1. require '.../classes/file'
As a helpful note, you can use code tags when posting by clicking the # button. This inserts code tags which displays the code neatly and saves you some typing. See code tags for more info.
Feb 14 '08 #2
Include the file path in the require statement.
Expand|Select|Wrap|Line Numbers
  1. require '.../classes/file'
As a helpful note, you can use code tags when posting by clicking the # button. This inserts code tags which displays the code neatly and saves you some typing. See code tags for more info.
Thanks for your suggestions, I figured out that giving the following will work!!
require 'C:\Documents and Settings\Desktop\File1'
But what i am looking for is not hardcoding the path, since if someone else has to run my program he should be able to do it without touching in the code like modifying the path name etc..
I am using eclipse with RDT plugin, is there anyway i can setup these paths!!
Similar to Build Path for JAVA in eclipse, where in can specify the classpath variables and so on.
Please let me know if any other workaround for this.

Cheers
Feb 18 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: python | last post by:
I'm writing a function and it needs to use regular expressions and the super-fantastic mx.DateTime module. The first lines after the doc string in the function are: import re, mx.DateTime ...
13
by: Wayne Folta | last post by:
I've been a long-time Perl programmer, though I've not used a boatload of packages nor much of the tacky OO. A couple of years ago, I decided to look into Python and Ruby. Python looked OK, but...
77
by: Hunn E. Balsiche | last post by:
in term of its OO features, syntax consistencies, ease of use, and their development progress. I have not use python but heard about it quite often; and ruby, is it mature enough to be use for...
3
by: Charles Krug | last post by:
List: I'm trying to use the example files from Programming Python, 2nd Ed. I've copied them into c:\Python24\Examples\PP2E. Launching any of the examples programs by themselves seems to work...
65
by: Amol Vaidya | last post by:
Hi. I am interested in learning a new programming language, and have been debating whether to learn Ruby or Python. How do these compare and contrast with one another, and what advantages does one...
0
by: Typehigh | last post by:
HELP! I don't know what happened. I have an MS_Access 2000 application that imports 20 data files; some Excel, some fixed-length txt and some tab delimited. I use "DoCmd.TransferSpreadsheet . ....
2
by: warhero | last post by:
Hey all, sorry for the totally newb question. I recently switched over to python from ruby. I'm having problems figuring out how module importing works.. as a simple example I've got these files: ...
10
by: bruce | last post by:
hi... can someone point me to where/how i would go about calling a ruby app from a python app, and having the python app being able to get a returned value from the ruby script. something...
16
by: scholz.lothar | last post by:
I want to add some extension features to my program and this would require that i bundle a small c compiler with my program. On Unix it seems that tiny-c can do this, but i don't know about windows.
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.