| Home | SQL | PHP | HTML | Perl | PowerBuilder | C/C++ | General | Solutions | Contacts |
PowerBuilderIndexTipsDatawindow TimerExecutable Name Include Objects Is Executable? Object Exists? ObjectsDownloads |
Include Dynamically Created ObjectsPurposeIncluding dynamic objects in your compiled application PrecursorPlease note that datawindow objects, bitmaps, and icons should be included in an application using a pbr (powerbuilder resource file). This document explains how to include powerbuilder object classes other than the datawindow object. Whats the issue?I quite often find I need to create objects dynamically in Powerbuilder, i.e.
objects for which the datatype is unknown until runtime. There are many reasons
for doing this, one of the more common is having a generic function to open a sheet
in your application which takes a string with the sheet's classname. SolutionsThere are 2 real solutions which you can use to include dynamically created objects in your application. Solution 1 - Including the objects in PBDsCreate pbds for all the pbls which have the dynamic objects, tick the PBD checkbox next to the relevant pbls in the project painter. This should get rid of the unknown object errors in the compiled application. Solution 2 - Including the objects in the actual EXEOf course many people don't like PBDs, they can be very troublesome, particularly if you have many applications which have been built at different times. Using a PBD from another application can cause crashes, even if the code is the same in the other PBD! So the solution is to include the dynamic objects by referencing them directly, but doing so in code which doesn't get executed. I find the best way is to create an event called, for instance ue_include, and write the code in there. A variation is to write a conditional statement which will not executed, for example IF 1=2 THEN ... Example for Solution 2You have sheets called w_sheet1, w_sheet2, and an object called nv_object1 which are created dynamically Where to put thisIt depends on your application really, if you're sharing the functionality between applications it can be worthwhile putting this code in the master application object, so that you don't reference objects which are irrelevant to the application itself. Of course this relies upon you remembering to include the objects in your application. If the code is specific to an application, or the dynamic objects are always used, I would personally place the inclusion code within the object itself. Quite often the best solution is to use a combination of both methods, and making sure there is good documentation in place to explain what's going on! DetailsAuthor: Wayne Jones Created: 16 April 2003 Works with: All versions | |
| This is Code, all contents copyright - © Wayne Jones 2004. |
