home *** CD-ROM | disk | FTP | other *** search
- --------------------------------------------------------------------------
- --RECTANG.UPL
- --The user is prompted for the corners of a rectangle. The system computes
- --the remaining corners and inserts the rectangle into the database.
- --
- --This program demonstrates how UPL programs can act as an "intelligent
- --execute file". It gathers information, performs some calculation, and
- --then uses the resulting data as input to a command.
- --------------------------------------------------------------------------
-
- Proc Main
-
- --variable declarations: All data must be declared in a UPL program.
- -- Variables should be given names which help to
- -- remind you what they are used for.
- string ans:1
- Integer Cnt, NumDigs
- Coord Points(2), Corners(5)
-
- --Output name of program and prompt user for input
- Print "Insert Rectangle: a UPL program."
- Print "Digitize the opposite corners:",
-
- --Use an intrinsic procedure to get the coordinates of the digitizes.
- --Intrinsics procedures are built into the language to do useful tasks
- --for you.
- GetDig(2,1,NumDigs,Points(1))
-
- --The points digitized are broken into component parts and used to
- --create the remaining corners of the rectangle. The Coord function
- --converts the datatype of the components to match the datatype of
- --the variable they are assigned to.
- Corners(1) = Coord(Points(1).X, Points(1).Y, 0.0)
- Corners(2) = Coord(Points(1).X, Points(2).Y, 0.0)
- Corners(3) = Coord(Points(2).X, Points(2).Y, 0.0)
- Corners(4) = Coord(Points(2).X, Points(1).Y, 0.0)
- Corners(5) = Corners(1)
-
- --The resulting data is now used to build a rectangle. The SEND
- --statement will do all the work. Note how the intrinsic function
- --DigStr converts the coordinates to the form required by the Send
- --statement.
- Echo Off All
- Send
- Send "INSERT STRING:",
- Loop Cnt = 1 to 5
- Send DigStr(Corners(Cnt)),
- End Loop
- Send "REPA"
- Echo On
-
- End Proc