|
<< Click to Display Table of Contents >> Navigation: Programming Mechworks PDM > DBWCommandShell > How to write code |
Can I command DBWorks from any scripting?
What language can I use?
How should I call the commands available?
Can I control other applications from the same scripting?
You can command DBWorks from any scripting belonging to DBWorks. Typically there are two kind of scripts available and they are of the type .LST (responding to a button click in the edit dialog) and of the type .spt (responding to a double click on a field). As a third possibility you can send command from a scripting of a custom form, but in such case you need to copy manually the following rows into the code:
Sub DBWShell( cmd )
okDBW = swApp.CallBack( "DBWorks@DBWorksShell", 0, cmd )
if ( okDBW = False ) then
swApp.SendMsgToUser "Error in command:" & cmd
end if
End Sub
DBWorks cannot be commanded from a second application.
So far only Microsoft Visual Basic Scripting is supported. This language is virtually the same used in Visual Basic and VBA. More information can be found on the Microsoft site.
The commands are passed as string parameters of the DBWShell function, i.e.
call DBWShell( "OpenForBrowsing" ).
The parameters will follow the command within the same string being separated by spaces. It is important to notice that spaces inside each parameter should be put as '|' characaters. Let's see an example: I'm calling the command "SelectById" with the first parameter "Handle Bar Complete" and the second parameter "A". I'll write:
call DBWShell( "SelectById Handle|Bar|Complete A" ) .
You can control SolidWorks or any other application exposing itself to scripting via the iDispatch COM model: Excel, Word and many others. Please refer to Microsoft for further details on how to make a reference to the Object Model of an application inside a scripting.