Can I say its been great working with v4. I'm desperately trying to use as much of the new functionality as possible but its hard as there is so much to choose from!

Finally some feedback! I'm very happy you are enjoying it. I've put a ton of stuff in that makes the overall experience so much more pleasant. It's great being able to add things to the language.



1) To install the latest beta over the previous, should I follow the instructions for "Updating an Existing A4D 3.0 Database.." including deleting "forms, methods, style" or can I just use Insider with moving preferences set to replace as previously? (BTW This chapter is repeated twice in the latest reference pg 12 & pg 13)

Just copy the groups over the old groups. I'm totally bummed out -- somehow most of the changes I made to the Installation chapter got lost. Oh well.


2) Lastly could you give us a clue to what you term "poor mans classes". Maybe you could just provide a brief overview of the how's and why's for syntax like "rs->GetRow".

Here's how it works in a nutshell. Let's say we want to create a new class called Foo:


1. Create a library "Foo" that will act as the class.


2. Make one or more constructor methods (newFoo, newFooFromBar, etc.). In the process of construction you create a collection which becomes the "object". Make sure the collection has an item called "__class__" whose name matches the library name.


3. If you want the object's data to be private (which you should, good object-oriented design dictates you should force data access to go through methods), prefix the key names with an underscore, that prevents them from being accessed outside of the object's class/ library. So if the newFromBar() constructor took a bar parameter, you would store it like this:

$object{"_bar"} := $inBar


4. Return the collection handle to the caller from the constructor, that is the object reference.


5. The object methods must begin with a parameter called $self, which will receive the "object" reference (which is actually a collection handle). So you would have methods like this:

  setBar($self; $inBar)
  getBar($self)


6. Given an object reference, you can call a method on that object using the dereference operator (this syntax is taken from C++, also shared by PHP), like this:


$foo := Foo.newFromBar("foobar")
write($foo->getBar)
$foo->setBar("barfoo")

When Active4D sees ->, it transforms

  $object->method(params)

internally into:

  $object{"__class__"}.method($object; $params)


So here's our complete Foo class:

library "Foo"

method "new"
   return (_init(""))
end method

method "newFromBar"($inBar)
   return (_init($inBar))
end method

method "_init"($inBar)
$object := new collection("__class__"; current library name; "_bar"; $inBar)
   return ($object)
end method

method "setBar"($self; $inBar)
   $self{"_bar"} := $inBar
end method

method "getBar"($self)
   return ($self{"_bar"})
end method


You can look at the RowSet and Breadcrumb libraries to see a more complex example.

Regards,

   Aparajita
   Victory-Heart Productions
   www.aparajitaworld.com

   "If you dare to fail, you are bound to succeed."
   - Sri Chinmoy   |   www.srichinmoylibrary.com

_______________________________________________
Active4D-dev mailing list
[email protected]
http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev
Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/

Reply via email to