home *** CD-ROM | disk | FTP | other *** search
- -----------------------------------------------------------------------------
- --BOLTCIR.UPL
- --This UPL program will create and insert a bolt hole cirle.
- -- The user is prompted for: 1) the diameter of the bolt hole circle
- -- 2) number of bolt holes in circle
- -- 3) the diameter of the bolt holes
- -- 4) the starting angle of the first hole from
- -- horizontal (default=0; counter clockwise "+")
- -- The system will do the rest! It will assure a correct bolt hole circle.
- --
- --This program demonstrates use of UPL to create an "intelligent" execute
- -- file. That is, using UPL to parametrically define repetitive tasks.
- --
- --Where possible "hints" are given showing useful techniques.
- -----------------------------------------------------------------------------
-
- PROC MAIN
-
- --Variable Declarations
- -- HINT: Use descriptive names for variables. Long names do not effect
- -- speed or size of program. They do help to make the program clear
- -- and easy to understand. If short names are used, at least add a
- -- comment describing variable's purpose.
-
- REAL BOLT_CIRCLE_DIAM, BOLT_CIRCLE_RAD, HOLE_SIZE
- REAL STARTING_ANGLE, INCREMENT_ANGLE
-
- COORD ORIGIN_BOLT_CIRCLE
-
- INTEGER NUM_HOLES --How many holes in bolt circle
- INTEGER NDIGS, I --Temporary variable used in GETDIG intrinsic subroutine
- INTEGER CTRL_C = 3 --Ascii codes for ^C (to abort program)
-
- STRING ANS:1 --Holds prompt for exiting program
-
-
- --Start of executable statements
-
- SEND --A blank SEND statement must be used before any other SEND
- --statement is used in a program. One should start all UPL
- --programs this way.
- SEND "SET SCR 5"
-
- BREAK_CHAR=CTRL_C
-
- LOOP --Main loop to insert sets of 'bolt' circles
- -- HINT: It is helpful to indent all statements effected by
- -- a LOOP or IF statement. It makes the program easier
- -- to read.
-
- PRINT; PRINT "This program draws any number of holes on a bolt circle."
- ACCEPT ANS PROMPT("press S to stop or any other key to continue:")
- EXIT WHEN (ANS = "S" OR ANS = "s")
-
- --HINT: Note how the LOOP and ACCEPT statements are used here to
- -- check input to the program. The program will stay in the
- -- loop until the input is acceptable.
- LOOP
- ACCEPT BOLT_CIRCLE_DIAM PROMPT("Diameter of the bolt circle:") NEWLINE
- EXIT WHEN BOLT_CIRCLE_DIAM > 0.0
- END_LOOP
-
- LOOP
- ACCEPT NUM_HOLES PROMPT("Number of holes in bolt circle:") NEWLINE
- EXIT WHEN NUM_HOLES > 1
- END_LOOP
-
- LOOP
- ACCEPT HOLE_SIZE PROMPT("Diameter of the bolt holes:") NEWLINE
- EXIT WHEN HOLE_SIZE > 0.0
- END_LOOP
-
- PRINT "Starting angle 0 degrees is 3 o'clock position."
- PRINT "Positive (counter-clockwise) or negative values from 0#248 to 90#248 accepted."
- PRINT "Default value is 0 degrees"
- STARTING_ANGLE = 0.0
- LOOP
- ACCEPT STARTING_ANGLE PROMPT("Starting angle:") NEWLINE
- EXIT WHEN (STARTING_ANGLE => 0.0 OR \ --line continuation
- STARTING_ANGLE <= 90.0)
- END_LOOP
-
- PRINT "dig center of bolt circle:"
- GETDIG(1, 0, NDIGS, ORIGIN_BOLT_CIRCLE)
-
- INCREMENT_ANGLE = 360.0 / REAL(NUM_HOLES)
- BOLT_CIRCLE_RAD = BOLT_CIRCLE_DIAM / 2.0
-
- SEND "INS CIR D ",HOLE_SIZE,":CORG",
- SEND DIGSTR(ORIGIN_BOLT_CIRCLE), "A",STARTING_ANGLE,
- SEND "R",BOLT_CIRCLE_RAD, ",IA",INCREMENT_ANGLE, " N",(NUM_HOLES-1)
- SEND
- ECHO ON
-
- END_LOOP --main loop
- END PROC
-