An OLE object can be linked or embedded in your application. The method you choose depends on how you want to maintain the data.
The data for an embedded object is stored in your application. During development, it is stored in your application’s PBL. When you build your application, it is stored in the EXE or PBD file. This data is a template or a starting point for the user. Although the user can edit the data during a session, the changes cannot be saved because the embedded object is stored as part of your application.
Embedding is suitable for data that will not change (such as the body of a form letter) or as a starting point for data that will be changed and stored elsewhere.
To save the data at runtime, you can use the SaveAs and Open functions to save the user’s data to a file or OLE storage.
When you link an object, your application contains a reference to the data, not the data itself. The application also stores an image of the data for display purposes. The server application handles the actual data, which is usually saved in a file. Other applications can maintain links to the same data. If any application changes the data, the changes appear in all the documents that have links to it.
Linking is useful for two reasons:
More than one application can access the data.
The server manages the saving of the data, which is useful even if your PowerBuilder application is the only one using the data.
Maintaining link information The server, not PowerBuilder, maintains the link information. Information in the OLE object tells PowerBuilder what server to start and what data file and item within the file to use. From then on, the server services the data: updating it, saving it back to the data file, updating information about the item (for example, remembering that you inserted a row in the middle of the range of linked rows).
Fixing a broken link Because the server maintains the link, you can move and manipulate an OLE object within your application without worrying about whether it is embedded or linked.
If the link is broken because the file has been moved, renamed, or deleted, the Update setting of the control determines how the problem is handled. When Update is set to Automatic, PowerBuilder displays a dialog box that prompts the user to find the file. You can call the UpdateLinksDialog function in a script to display the same dialog box. You can establish a link in a script without involving the user by calling the LinkTo function.
PowerBuilder displays a control with a linked object with the same shading that is used for an open object.