• Welcome to Theos PowerBasic Museum 2017.

PB Objects (global scope?)

Started by Paul Squires, September 01, 2008, 04:20:39 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Paul Squires

Thanks José !  I would have stared at that code for hours and hours and not have realized to add INSTANCE.

Now I can continue on where I left off.

Thanks,
Paul Squires
FireFly Visual Designer SQLitening Database System JellyFish Pro Editor
http://www.planetsquires.com

Paul Squires

After struggling most of today, but thanks to the help of José I am finally very comfortable working with PB objects in an OOP setting. Personally, I will not be retro-fitting any of my older or existing programs with PB objects because I think it would be cleaner to start off a project totally object based. It is really a different mind set.

I have learned several lessons today:

(1) Allow objects to handle objects rather than dealing with OBJPTR's and POKE.
(2) Some PB functions do not work on PB objects. For example, SIZEOF and pointers.
(3) Arrays in an object can be resized via REDIM PRESERVE but the ARRAY INSERT/DELETE functions do not work. You need to DIM/AT over the array. For example:


         Dim nArray(UBound(m_pChildNodes)) As Dword At VarPtr(m_pChildNodes(0))
         Array Insert nArray(nPosition)


(4) I need to plug into José's brain.

:)
Paul Squires
FireFly Visual Designer SQLitening Database System JellyFish Pro Editor
http://www.planetsquires.com

Dominic Mitchell

Well, I have to admit I don't agree with your approach one bit.
In COM, the hierarchy I would use for a linked-list would look something like the following:

   Server
     |
    \|/
INodes(collection object)
     |
    \|/
   INode
   
                                                                 

INodes inherits IDispatch and implements an IEnumXXX object. It also has the standard methods
Count, Item, NewEnum, Add, Remove and Clear.   
Relatively easy to implement using low-level COM, and can be used from any development environment
when incorporated in an OCX.
         
By the way, I see no reason for a node to reference count another node.
Dominic Mitchell
Phoenix Visual Designer
http://www.phnxthunder.com

Paul Squires

So Dominic, if I understand you correctly, I should be using a COM collection instead of manually trying to track the objects via an array?

BTW, I am no longer using the linked list approach. I am using standard arrays in my object to store any child objects of that parent object. I will forego using those arrays if you think implementing the Collection approach is better. Please advise.

Thanks!
Paul Squires
FireFly Visual Designer SQLitening Database System JellyFish Pro Editor
http://www.planetsquires.com

Dominic Mitchell

I guess it depends on the intended users.  If it is only meant for the PowerBASIC
audience, then I guess it is okay. As an OCX released to the wider development community,
I don't see how this approach is going to fly.
Take a look at how objects are organized in apps such as Excel, Word and Rainer Morgen's
RMChart. That's no accident.

We are dealing with two separate things here. The first is the objects exposed by the server,
and the second is the manipulation of the data by these objects.  The method use to process
the data is immaterial.  Use the method you think is best(array or linked-list).
Can this hierarchy be built using PB9 COM?  I don't know, because I don't have PB9 yet.

I will order PB9 this week, because I am very curious to see the calibre of the type libraries it
produces.  This type of simple problem should be a good test case.
Dominic Mitchell
Phoenix Visual Designer
http://www.phnxthunder.com

Paul Squires

Thanks Dominic, I appreciate the info.

To be honest, I am only learning PB Objects and getting to know some of the workings of COM. The last time I did anything with Collections was back in my Visual Basic days about 8 years ago.

At this point, I am only tracking the child objects for my own use. It is not something that will be exposed as a library for others to use. If it was, then I definitely see your point that it should be standard like other libraries out there. My use of objects at this point is in preparation for my next project (an accounting/billing/invoicing program).

Good luck when you get PB9. I am enjoying it so far and as soon as I practice more I will get more comfortable with it.

Now get off that bike of yours and order PB9  :)   Actually, if your weather has been as crappy as ours, I doubt you've been biking much at all.
Paul Squires
FireFly Visual Designer SQLitening Database System JellyFish Pro Editor
http://www.planetsquires.com