France,
Toulouse,
Saturday, October, 30th, 2004,
5:48 pm.
Hi Barry,
There is a fast way to reuse code.
In REALbasic, open the first project that contains your codes.
The "Project Window" is in foreground.
Drag and drop modules or classes that contains your codes from the "Project
Window" of your project to the desktop.
Open the second project in REALbasic.
Drag and drop the modules and classes from the desktop to the "Project
Window" of this second project.
Now, the second project contains any modules or classes from the first
project, hence the codes of your methods.
See page 210, "Importing and Exporting Yours Classes, Menus, Modules, and
Windows" for more informations.
Tips:
If you have some methods you need to reuse, organize them. Create classes or
modules to group them.
Modules are useful for metodes that look like functions, that is to say
standalone methods.
Think of module as "library".
Classes are appropriate when methods are linked with a particular kind of
object, that is to say when methods are behaviors and rely on properties,
etc.
If a part of the methods hosted by a class is needed to reuse, create a
parent class. The parent class implements the methods to reuse and you class
become a subclass of this parent class with its own methods but not
reusable.
To be clear, you split your class.
Illustration:
Your actual organization:
MyClass
Method1
Method2
Method3
Method4
I need to export "Method1" and "Method3" without "Method2" and "Method4".
Here how to do.
First step, spilt your class:
MyParentClass
Method1
Method3
and:
MyClass (with MyParentClass as super class)
Method2
Method4
Since, "MyClass" is a subclass of "MyParentClass", it inherits "Method1" and
"Method3".
Now, you can drag and drop "MyParentClass" and reuse it at any time with the
required methods.
This tip is one of the main techniques used in the world of Object Oriented
Programming: simpler are classes, more usable these classes are.
If you need more explanation, let's me know.
Best Regards,
Nils
----
----
Le 30/10/04 15:06, « B Traver » <btraver at traver dot org> a écrit :
> I have two related questions, both of which ultimately have to do with
> situations where I want to use a lot of Methods from one REALbasic
> program in another REALbasic program.
>
> First, I know that you can't have two instances of the REALbasic IDE
> open at the same time. (Well, technically that's not entirely true.
> There is a trick that involves, I think, holding down the CTRL key while
> loading in the second instance of the RB IDE into Windows, but when I've
> done that, usually one of the instances seems to be instable.)
>
> Second, one solution (at least theoretically) to the problem of getting
> a lot of Methods from one RB program to another is to load a plain text
> listing of the Methods into a plain text editor and then just use copy
> and paste to get Methods from one to the other.
>
> BUT how can one create such a text listing of the RB program? What I
> want is what you get when you tell the RB IDE to _print_ the program,
> but that is neither .RB nor .XML format. Is there some way to tell the
> computer (in this case, a Windows PC), "OK. I want a plain text
> listing, but I want it in a disk file, not on paper"?
>
> What I want is, again, a plain text listing of my .RB program, and not
> some file in some strange format with all kinds of printer codes
> intermingled. When I print from the RB IDE, I'm not given a choice of
> "print to disk," and even if I were, the resulting disk file would
> probably contain control characters and such.
>
> I know there are "fake" printer drivers that will print to disk instead
> of to a printer, but they usually do things like convert the output to a
> disk file in some special format like PDF or something like that.
>
> The first question then is this: how can I get a plain text listing of
> my RB program on disk that looks like what you get when you print the
> listing on a printer?
>
> The second question is similar: If that can't be done, what IS the
> easiest way to get a lot of Methods from one RB program to another?
> (It's a real pain to load one program into the RB IDE, copy a Method,
> load in the other RB program, paste the Method, load in the first RB
> program, copy a Method, load in the second RB program, paste the Method,
> etc., etc.).
>
> Barry Traver
----
----
"On ne voit bien qu'avec le coeur. L'essentiel est invisible pour les yeux."
"We only see well with our hearts. What is truly important is invisible to
our eyes."
Le Petit Prince, Antoine de Saint Exupéry
----
----
"Ce n'est pas l'homme qui doit s'adapter à la machine mais la machine qui
doit répondre aux besoins de l'homme."
"It is not the man who should adapt himself to the machine but the machine
which should meet the needs of the man."
Nils Frisch
----
----
Nils Frisch
Toulouse,
France.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>
|