Guys,
I've been meening to put this up for a while. I put it together for a presentation that didn't fly.
Most of us never start writing a script or program from a blank screen. We copy somethings from our toolbox that is close and modify. Well in the beginning my toolbox was empty. Heck I didn't even have a toolbox.
I find that many of the one-off requrests I get involve
1. Looking at each file in a folder and doing something in SmarTeam for each (walking the folder)
2. Doing a query in SmarTeam and looking at each row that results and doing something with each row (walking SmarTeam)
3. Reading each line of a text file and doing something in SmarTeam for the file decribed by the row (walking a text file)
This script demonstrates each of these "walking" situations.
It also contains a little function to take the results of DIR *.??? > dir.txt and strip the left side off so that the file name is in the left column. This allows the file to sorted using the DOS sort. Archaic but Quick and Dirty.
Option 1 - Create Readme and open in NotePad, Create/Edit INI file
Option 2 - Report on which files in a Vault Folder are NOT in SmarTeam
Option 3 - Report on which files in SmarTeam are NOT in the Vault Folder
Option 4 - See if Drawings in the Vault have PDF files and Parts/Products have CGR files
Option 5 - Copy a text file created with DIR > wo the left 40 char
Option 6 - Read a Text file and report how many are in SmarTeam
Note: This sample adds the word Special_X to the comment of CATDrawings found , this lets us go into Smarteam and query on "*Special_X*" in the comment field.
Option 7 - Test a routine that converts revisions to numbers - larger number = larger revision
Please note that this code is for educational use only. It has not been heavily tested. Use it to jump start your own programming and use it at your own risk. Sorry about the legaleze disclaimer and all that, but today you just gotta do it.
Hope this helps someone,
Regards,
Hale
|