Object Find and Replace
[Previous] [Main] [Next]

 
All htmlObject-derived classes support object find and replace operations. To find or replace an object, you must name the object using the Key() method. The Key() method accepts a text string as the name. Once named, an object can be found or replaced using the Find() or Replace() methods.  
 
Object find/replace operations are extremely powerful, and allow you to dynamically substitute any object for any other object using simple names.  
 
Objects are added to other objects using the << insertion operator or the Add() method. For example, an application typically adds table cell objects to table row objects, which are in turn added to table objects which are in turn added to page objects. Calling Find() or Replace() on any object will search an object plus any objects it contains. In the aforementioned scenario, calling page.Replace() would cause the page object and all the objects it contains to be searched.  
 
The Find() method searches an object and any objects it contains for the first occurrance of an object with a matching key name, returning a htmlObject base-class pointer to it or NULL if no match is found.  
 
The Replace() method searches an object and any objects it contains for all occurrances of objects with a matching key name, replacing them with a user-specified replacement object. Replace() returns an integer represeting the number of replacements performed. To effectively remove an object, just replace it with an empty object such as htmlText(). For an example of using Replace(), refer to the example program for htmlContainer.  
 


©1998 DC Micro Development. All rights reserved.
No portion of this document may be c opied or reproduced without expressed written consent.
html++ is a trademark of DC Micro Development.