home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p115 / 10.ddi / GCD4 / UPL / RECTANG.UPL < prev    next >
Encoding:
Text File  |  1988-06-01  |  1.9 KB  |  53 lines

  1. --------------------------------------------------------------------------
  2. --RECTANG.UPL
  3. --The user is prompted for the corners of a rectangle. The system computes
  4. --the remaining corners and inserts the rectangle into the database.
  5. --
  6. --This program demonstrates how UPL programs can act as an "intelligent
  7. --execute file". It gathers information, performs some calculation, and 
  8. --then uses the resulting data as input to a command.
  9. --------------------------------------------------------------------------
  10.  
  11. Proc Main
  12.  
  13. --variable declarations: All data must be declared in a UPL program. 
  14. --                       Variables should be given names which help to
  15. --                       remind you what they are used for.
  16. string ans:1
  17. Integer Cnt, NumDigs
  18. Coord Points(2), Corners(5)
  19.  
  20. --Output name of program and prompt user for input
  21.     Print "Insert Rectangle: a UPL program."
  22.     Print "Digitize the opposite corners:",
  23.  
  24. --Use an intrinsic procedure to get the coordinates of the digitizes.
  25. --Intrinsics procedures are built into the language to do useful tasks
  26. --for you.
  27.      GetDig(2,1,NumDigs,Points(1))
  28.  
  29. --The points digitized are broken into component parts and used to
  30. --create the remaining corners of the rectangle. The Coord function
  31. --converts the datatype of the components to match the datatype of 
  32. --the variable they are assigned to.
  33.     Corners(1) = Coord(Points(1).X, Points(1).Y, 0.0)    
  34.     Corners(2) = Coord(Points(1).X, Points(2).Y, 0.0)    
  35.     Corners(3) = Coord(Points(2).X, Points(2).Y, 0.0)    
  36.     Corners(4) = Coord(Points(2).X, Points(1).Y, 0.0)    
  37.     Corners(5) = Corners(1)    
  38.  
  39. --The resulting data is now used to build a rectangle. The SEND 
  40. --statement will    do all the work. Note how the intrinsic function
  41. --DigStr converts the coordinates to the form required by the Send
  42. --statement.
  43.     Echo Off All
  44.     Send
  45.     Send "INSERT STRING:",
  46.     Loop Cnt = 1 to 5
  47.         Send DigStr(Corners(Cnt)),
  48.     End Loop
  49.     Send "REPA"
  50.     Echo On
  51.  
  52. End Proc
  53.