Ask Your Question
3

How to use a worksheet content in another worksheet?

asked 12 years ago

anatematic gravatar image

I have a long worksheet, whose first part defines functions and the second part use them. I would like to split it in two worksheet, keeping the definition in the first one and loading all of them in the second one where they are used. Is it possible to do it?

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
2

answered 12 years ago

ndomes gravatar image

You can use the data menu. Create a file, for example 'definitions.sage', move your functions into this file and load it in your worksheet:

load(DATA+'definitions.sage')

Preview: (hide)
link
1

answered 12 years ago

ndomes gravatar image

Do you want to use the definitions in different worksheets?

Unfortunately there is no way to store a data file in the users home directory (or I don't know about) unless you have direct access to the server. (I tried data file names like '../../test.sage', but it didn't work, the file appears in the data sub-folder of the current worksheet.

Suppose you have stored a data file 'test.sage' in a worksheet with ID 100, you can access this file in another worksheet with

load(DATA+'../../100/data/test.sage')

If you run your own server you can store a file (for example 'impressum.sage') in your sage notebook home directory. Access from any of your worksheets can be done like this:

MYHOME = os.path.normpath(DATA+'/../..')+os.sep
load(MYHOME+'impressum.sage')

May be it can be done more straightforward?

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 12 years ago

Seen: 1,052 times

Last updated: Jan 20 '13