Home > Archive > dBASE Knowledge Base > April 2005 > SuperArray.cc ?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author SuperArray.cc ?
Roland Wingerter

2005-04-04, 8:03 pm

The dUFLP Library.wfm refers to a custom class SuperArray by Bruce Beacham,
which should be in arrayEx.cc, but isn't.

The description is as follows:
"A new class that adds more functionality to the base Array class, and also
adds the functionality of the original ArrayEx class."

Where is it or what happened to it?

Thanks

Roland





Ivar B. Jessen

2005-04-04, 8:03 pm

On Fri, 18 Mar 2005 11:28:50 +0100, "Roland Wingerter" <RW@germany.de>
wrote:

>The dUFLP Library.wfm refers to a custom class SuperArray by Bruce Beacham,
>which should be in arrayEx.cc, but isn't.
>
>The description is as follows:
>"A new class that adds more functionality to the base Array class, and also
>adds the functionality of the original ArrayEx class."
>
>Where is it or what happened to it?


Roland,

I believe it refers to the function 'AssignMethods()' which makes a
"Super Array" out a normal plain array. It is best illustrated with an
example.

a = new array(1,3) // the plain array
a.fill("Super array")

set proc to :duflp:arrayex.cc additive
ax = new arrayex(a)

a.ListArray() // not a standard method for the array class.

Inspect array a and notice that it now has all the methods of array
ax, it is a SuperArray ;-)


Ivar B. Jessen
Bruce Beacham

2005-04-04, 8:03 pm

Ivar B. Jessen wrote:[color=darkred
]
> On Fri, 18 Mar 2005 11:28:50 +0100, "Roland Wingerter" <RW@germany.de>
> wrote:
>
>

It's in arrayex.cc but the class is zArray.

"This class extends the set of methods of a normal array.
It includes methods which simplify some (IMO) slightly clumsy
processes for normal use of an array, especially when 2D.
It also adds-in the methods of the dUFLP arrayex class.
Not suitable for arrays with more than 2 dimensions (I can't
get my brain round that)."

Try this trivial example:

set proc to :duflp:arrayex.cc additive
a = new zArray()
a.dir()
a.CarveOut().Upper().listarray()
a.release()

I find the grow() method specially useful in 2D arrays.


Bruce Beacham
Ivar B. Jessen

2005-04-04, 8:03 pm

On Sat, 19 Mar 2005 01:33:41 +0000, Bruce Beacham
<bbeacham@beacham.no-spam.co.uk> wrote:

>Ivar B. Jessen wrote:
>
>It's in arrayex.cc but the class is zArray.
>
>"This class extends the set of methods of a normal array.
>It includes methods which simplify some (IMO) slightly clumsy
>processes for normal use of an array, especially when 2D.
>It also adds-in the methods of the dUFLP arrayex class.
>Not suitable for arrays with more than 2 dimensions (I can't
>get my brain round that)."


Bruce,

Something is missing from my previous example, lines must have been
left out when I used copy/paste ;-)

Anyway, run the code below and notice from the inspector that the
method Flip() is not included amongst the methods added to array a.

I tried to add the following lines to FUNCTION AssignMethods in
arrayex.cc and now the method Flip() is included with the methods in
array a and appears to work as intended.

if type("aArg.Flip") = "U"
aArg.Flip = class::Flip
endif


Was the Flip() method left out by design because it would wreck some
other code and eventually reformat the hard disk, or is it safe to add
said lines and use the method in the way illustrated?


Ivar B. Jessen

//-----
a = new array(3,6)
set proc to :duflp:arrayex.cc additive
ax = new arrayex(a)
ax.assignMethods(a)
inspect(a)
Roland Wingerter

2005-04-04, 8:03 pm

Ivar B. Jessen wrote:
>
> I believe it refers to the function 'AssignMethods()' which makes a
> "Super Array" out a normal plain array. It is best illustrated with an
> example.

-----
Thanks for the example, Ivar.

Since the array is called zArray, the name should be corrected in
library.dbf, or else the class should be renamed. But that's for Ken to
decide. ;-)

Roland





Roland Wingerter

2005-04-04, 8:03 pm

Bruce Beacham wrote:
>
> Try this trivial example:
>
> set proc to :duflp:arrayex.cc additive
> a = new zArray()
> a.dir()
> a.CarveOut().Upper().listarray()
> a.release()

-----
Thanks, Bruce.

I have used your zArray class on previous occassions, and it it super. I
just wondered if you had added some other good stuff.

Roland



Bruce Beacham

2005-04-04, 8:03 pm

Roland Wingerter wrote:
> Bruce Beacham wrote:
>
>
> -----
> Thanks, Bruce.
>
> I have used your zArray class on previous occassions, and it it super. I
> just wondered if you had added some other good stuff.


Nope. When I was working on zArray originally I did add some methods
to arrayex itself, but nothing since then.

If you like this line of thinking, have you tried the kminspector (.cc)
in the dUFLP? The call is to a function inspectobject(). It replaces
inspect() and it can be used in the runtime. I have it called by a
tiny pushbutton that appears at the top left corner of my custom forms
when I toggle an _app setting. Very useful for debugging.

The significance is that it does better than inspect() does when it
encounters an array: it expands the array, as well as showing the
array's properties.


Bruce

Bruce Beacham

2005-04-04, 8:03 pm

Hi Ivar

Ivar B. Jessen wrote:

> Anyway, run the code below and notice from the inspector that the
> method Flip() is not included amongst the methods added to array a.


> Was the Flip() method left out by design because it would wreck some
> other code and eventually reformat the hard disk, or is it safe to add
> said lines and use the method in the way illustrated?


Yes, it was. Instead, I added FlipCopy(). The reason is that I
wanted the methods used by the zArray class to be capable of being
chained. But the output of Flip() is a logical, and I dared not break
existing code that depended on that output. So I wrote a modified
method, FlipCopy(), to do the same thing (I hope!) but be capable of
being chained.

I can't see any technical reason not to add Flip() to AssignMethods(),
although it might confuse and it is superfluous.


Bruce
Bruce Beacham

2005-04-04, 8:03 pm

PS

> Was the Flip() method left out by design because it would wreck some
> other code and eventually reformat the hard disk, or is it safe to add
> said lines and use the method in the way illustrated?


Hmm, but then I can't _guarantee_ that it won't reformat the hard disk...


B
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com