OnOpenG.LST script file

<< Click to Display Table of Contents >>

Navigation:  Programming Mechworks PDM > DBWCommandShell > Event Scripts > Document >

OnOpenG.LST script file

Description

It is run every time an OPEN of a Generic Document (not CAD) is requested by a Mechworks client.

It allows to execute a non Windows-compliant executable, passing it the name of the file to be opened.

Activation

Options→General→More...

Input

@DOCUMENT_PATHNAME

full path name of the doc to open

Output

@OKOPEN

0:opening unprocessed (OS opening after the script)
1:opening processed by the script (no automatic file opening after the script)

See also

OnOpen.LST

Example

Suppose we want to intercept the files with extension "mi" and we want to run the process "notepad" to open such files; we will create the file LST\OnOpenG.LST as follows:

.VBSCRIPT

dim fs
sub main()
 DBWInit(TRUE)
 pathName = DBWInput("@DOCUMENT_PATHNAME")
 Set fs = CreateObject("Scripting.FileSystemObject")
 ext = fs.GetExtensionName(pathName)
 if UCase(ext) = "MI" then
  Dim shell
     Set shell = CreateObject("WScript.Shell")
  shell.Run("Notepad.exe " & pathName )
  DBWOutput "@OKOPEN","1",ForWriting 'This means the opening is driven by the script so no further action is expected once the script terminates
 else
  DBWOutput "@OKOPEN","0",ForWriting 'Nothing has been managed by the script so once the script terminates the OS will open as usual
 end if
end sub