home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 July / Chip_1997-07_cd.bin / tema / mattes / ip / ip30 / data.1 / MEASURE.WBS < prev    next >
Text File  |  1996-09-21  |  2KB  |  55 lines

  1. '
  2. '    Creates a meter to measure distance between two
  3. '    selected points
  4. '
  5. '    Copyright(C) 1995 Knowledge Revolution.  All rights reserved.
  6. '
  7. '    Author:        Ken Tokusei
  8. '    History:    14 Jun 1995    Created
  9. '
  10. Sub Main()
  11.     Dim D as WMDocument, M as WMOutput, P1 as WMPoint, P2 as WMPoint
  12.     Dim P3 as WMPoint
  13.     Set D = Wm.ActiveDocument
  14.     If D is Nothing then
  15.         MsgBox "No document is open", ebExclamation, "ERROR"
  16.         Exit Sub
  17.     End If
  18.  
  19.     ' Check to see if a valid number of points are selected.
  20.  
  21.     Set P1 = D.Selection.Point(1)
  22.     Set P2 = D.Selection.Point(2)
  23.     Set P3 = D.Selection.Point(3)
  24.  
  25.     ' Make sure two points are selected.
  26.     If P2 is Nothing then
  27.         MsgBox "You need to select two points first.", ebExclamation, "ERROR"
  28.         Exit Sub
  29.     End If
  30.  
  31.     ' If P3 is not Nothing, the user has more than two points selected.
  32.     ' Provide an option to continue if necessary, although s/he has no idea
  33.     ' which pair of points are being used.
  34.  
  35.     If P3 is not Nothing then
  36.         Code = MsgBox("More than three points are selected.  Continue?", _
  37.                 ebOKCancel or ebExclamation, "WARNING")
  38.         if Code = ebCancel then
  39.             Exit Sub
  40.         End IF
  41.     End If
  42.     
  43.     ' Create the meter measuring the distance b/w P1 and P2
  44.  
  45.     Set M = D.NewOutput()
  46.     If M is Nothing then
  47.         MsgBox "Cannot create a meter", ebExclamation, "ERROR"
  48.         Exit Sub
  49.     End If
  50.     M.Name = "Distance b/w P"+str$(P1.ID)+" and P"+str$(P2.ID)
  51.     M.Column(1).Label = "Dist"
  52.     M.Column(1).Cell.Formula = "|point["+str$(P1.ID)+"].p-point["+str$(P2.ID)+"].p|"
  53.     M.Width = 170
  54. End Sub
  55.