OLE and ActiveX
Warning: This functions are not available in the Light edition.

Strawberry Prolog supports OLE Automation - COM and ActiveX. This enables you to command standard programs like MS Word or Excel using your Strawberry Prolog program. This will open opportunities to incorporate such  programs into your Prolog program. This is not an absolutely new opportunity because you can already do this by Visual Basic, Delphi and Visual C++. However, Prolog (especially Strawberry Prolog) has definite advantages over other program environments and they are:

 1. Basic is suitable only for short programs but when the program becomes longer it gets messy.

 2. Delphi and Visual C++ are known as environments for professionals not only because you can create professional work using them but also because you need so much time to study through them that it is worth taking it on only if this is your profession.

If you want to command another program (server) then you have to know its commands (methods and properties). You can use the tool Object Browser (from menu Tools). With the help of this tool you can see all OLE servers which are installed on your computer. Also you can see their methods and properties. You can use any other description of this server (interface) provided by the authors of the server.

Where to find a description of the server: We cannot say in the general case but for the most often used servers we will provide information and links to sources documentation. If you want to use Microsoft Office then we offer to visit Microsoft Office Developers page. If you want to use some other server turn to the company which made it. Most commercial applications support OLE Automation. This is the case of AutoCad 14 and of many products of Microsoft like Word, Excel, Developers Studio etc. Keep in mind that some programs do not support OLE Automation (are not written as servers) and cannot be ruled from outside.

Predicates for OLE Automation: If you want to call a server then you have first to open it. This can be done with the function:

Server is server(ServerName)

Here has to be a string containing the name of the server. You can take this name from the Object Browser. This function will return in Server the object server and you should to use it to invoke its methods and to set and get its properties.

If you want to invoke method then use the function (or predicate) point. What to use (function or the predicate) depends on that do you need the return value of this predicate.

R is Server.MethodName(Arg1, ... , Argn)
Server.MethodName(Arg1, ... , Argn)

Here Server has to be instantiated with an open server and MethodName has to be a string containing the name of one of the methods of this server. You can take this name also from the Object Browser. The arguments has to be from the types which this method needs.

If you want to get property then use again the function point. You can put in any expression Server.PropertyName where PropertyName is the string containing the name of one of the properties of this server. You can take this name also from the Object Browser. For exampele you can get property as follows:

X is Server.PropertyName

If you want to set property then it is easy again. Simply type this:

Server.PropertyName := Value

Here Value has to be this value which you want to set to this property. Here as you see := can be used as set property. Of course, this operation is stable on backtracking.

When you want to close one server then use the predicate close in this way:

close(Server)

Here Server has to be instantiated with an open server which you want to close.

Examples:

 OLE