DBWWalkTree

<< Click to Display Table of Contents >>

Navigation:  Programming Mechworks PDM > DBWCommandShell > Library Reference > Tree >

DBWWalkTree

Description

Traverses a document tree.

Syntax

Function DBWWalkTree(DocUID, Parent, OptionalQueryFilter)

Parameters

DocUID

It is the unique id of the root document.

Parent

<0/1>
If set to 0 it traverses document child tree.
If set to 1 it traverses document parent tree.

OptionalQueryFilter

further specification for the tree walking.

This it's a part of a query, so you've to set it in this way:

" AND <condition> "

For example you can specify that you want to search only in certain documents (projects, parts, ...).
You have to set the variable as

" AND T='0' "

Remarks

The example below is quite explanatory.

You must use a sub called UserProcessDocument to execute actions while traversing the tree; it is run for each node of the tree you traverse.
As you can note, in the sub main there is only a call to DBWWalkTree with parameters, the whole processese are exeuted in the UserProcessDocument sub.

Please note also the DBWStopProcessing statement. It stops the tree traversing.

See also

Related commands and functions

Example

Sub Main
 DBWInit(True)
 DBWShell("CurrentDocument")
 uid = DBWResult("@DOCUMENT_UNIQUE_ID")
 DBWWalkTree uid, 0, ""
end sub
'call back for the DBWWalkTree
sub UserProcessDocument( uid )
 state = DBWQueryByUid( uid, DBWLookUp("NAME_FIELD_STATE") )
 if state = DBWLookUp("NAME_STATE_NEW_STRING") or state = DBWLookUp("NAME_STATE_BEING_MODIFIED") then
  id = DBWQueryByUid( uid, DBWLookUp("NAME_FIELD_ID") )
  fileName = DBWQueryByUid( uid, DBWLookUp("NAME_FIELD_FILE_NAME") )
  fileDir = DBWQueryByUid( uid, DBWLookUp("NAME_FIELD_FILE_DIRECTORY") )
  MsgBox "Document ID=" & id & " File=" & fileDir & fileName & " is still in a MODIFIABLE state"
  DBWStopProcessing = True
 end if
end sub