REBOL 3.0

Comments on: Example of a minimal module

Carl Sassenrath, CTO
REBOL Technologies
22-Oct-2010 0:52 GMT

Article #0344
Main page || Index || Prior Article [0343] || Next Article [0345] || 2 Comments || Send feedback

Ok, you've heard about REBOL modules, and we've made a lot of changes recently... but, you're not really sure how to make one. Here's an example. It's very simple.

First, create a module file. This one is saved as simple.reb:

REBOL [
    title: "Simple module"
    type: module
]
export num: 1234
export sum: func ["Example" val] [val + num]

Notice it look like a normal script, but we specify the type module and the word export is used to indicate exported words.

Now, in your program, you can either import the module:

import %simple.reb

Or, another way is to specify it in the header of your program:

REBOL [
    title: "Main program"
    needs: %simple.reb
]

Then you can easily access the exported functions and data of the module:

print num
1234
sum 1000
2234

Of course, this is just scratching the surface of what modules can do. But, I wanted to start with a simple example to show how easy it is to get going. It's that easy.

2 Comments

Comments:

Louis Vuitton bags outle
12-Jul-2012 23:42:18
Visit buyIf want to know where you want to buy Louis Vuitton bags outlet sale, you can use online resources Designer Louis Vuitton bags outlet sale visit descriptions of the Louis Vuitton bags and the big guy for the different costs and other accessories. You can find the online destination and Overstock Handbagcrew reduced price handbags and designer handbags. Check out other great creators of these pages that have the same quality and you will be able to see, how much to save - prices really have to pay a department store shopping at this site is much more normal. Have fun while you shop Louis Vuitton bags outlet sale!
Supra shoes for girls
17-Jul-2012 23:25:33
The Supra shoes for girls Asia this training camp lineup,More than 50 players from China, Hong Kong, China, Chinese Taipei, Japan, Korea, Australia and other countries and regions,Players in the Supra shoes for girls list, we are familiar with the noble, Supra shoes for girls and consultant in the lineup, not only have Yi Jianlian, Gay and DeRozan and the other two NBA players, as well as the former coach of the United Arab O'Connor, and Chinese star Du Feng and so on.

Post a Comment:

You can post a comment here. Keep it on-topic.

Name:

Blog id:

R3-0344


Comment:


 Note: HTML tags allowed for: b i u li ol ul font span div a p br pre tt blockquote
 
 

This is a technical blog related to the above topic. We reserve the right to remove comments that are off-topic, irrelevant links, advertisements, spams, personal attacks, politics, religion, etc.

REBOL 3.0
Updated 19-Nov-2017 - Edit - Copyright REBOL Technologies - REBOL.net