home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p115 / 10.ddi / GCD4 / UPL / BOLTCIR.UPL < prev    next >
Encoding:
Text File  |  1988-05-03  |  3.6 KB  |  98 lines

  1. -----------------------------------------------------------------------------
  2. --BOLTCIR.UPL
  3. --This UPL program will create and insert a bolt hole cirle.
  4. -- The user is prompted for: 1) the diameter of the bolt hole circle
  5. --                           2) number of bolt holes in circle
  6. --                           3) the diameter of the bolt holes
  7. --                           4) the starting angle of the first hole from 
  8. --                              horizontal (default=0; counter clockwise "+")  
  9. -- The system will do the rest! It will assure a correct bolt hole circle.
  10. --
  11. --This program demonstrates use of UPL to create an "intelligent" execute
  12. -- file. That is, using UPL to parametrically define repetitive tasks.
  13. --
  14. --Where possible "hints" are given showing useful techniques.
  15. -----------------------------------------------------------------------------
  16.  
  17. PROC MAIN
  18.  
  19. --Variable Declarations
  20. --    HINT: Use descriptive names for variables. Long names do not effect 
  21. --          speed or size of program. They do help to make the program clear
  22. --          and easy to understand. If short names are used, at least add a
  23. --          comment describing variable's purpose.
  24.  
  25. REAL BOLT_CIRCLE_DIAM, BOLT_CIRCLE_RAD, HOLE_SIZE
  26. REAL STARTING_ANGLE, INCREMENT_ANGLE 
  27.  
  28. COORD ORIGIN_BOLT_CIRCLE
  29.  
  30. INTEGER NUM_HOLES    --How many holes in bolt circle
  31. INTEGER NDIGS, I     --Temporary variable used in GETDIG intrinsic subroutine
  32. INTEGER CTRL_C = 3   --Ascii codes for ^C (to abort program)
  33.  
  34. STRING ANS:1         --Holds prompt for exiting program
  35.  
  36.  
  37. --Start of executable statements
  38.  
  39. SEND    --A blank SEND statement must be used before any other SEND 
  40.         --statement is used in a program. One should start all UPL  
  41.         --programs this way. 
  42. SEND "SET SCR 5"
  43.  
  44. BREAK_CHAR=CTRL_C
  45.  
  46. LOOP        --Main loop to insert sets of 'bolt' circles
  47.                 --    HINT: It is helpful to indent all statements effected by
  48.             --          a LOOP or IF statement. It makes the program easier
  49.             --          to read.
  50.  
  51.     PRINT; PRINT "This program draws any number of holes on a bolt circle."
  52.     ACCEPT ANS PROMPT("press S to stop or any other key to continue:") 
  53.     EXIT WHEN (ANS = "S" OR ANS = "s")
  54.  
  55.         --HINT: Note how the LOOP and ACCEPT statements are used here to 
  56.         --      check input to the program. The program will stay in the 
  57.         --      loop until the input is acceptable.
  58.     LOOP 
  59.         ACCEPT BOLT_CIRCLE_DIAM PROMPT("Diameter of the bolt circle:") NEWLINE
  60.         EXIT WHEN BOLT_CIRCLE_DIAM > 0.0
  61.     END_LOOP
  62.  
  63.     LOOP
  64.         ACCEPT NUM_HOLES PROMPT("Number of holes in bolt circle:") NEWLINE
  65.         EXIT WHEN NUM_HOLES > 1
  66.     END_LOOP
  67.  
  68.     LOOP 
  69.         ACCEPT HOLE_SIZE PROMPT("Diameter of the bolt holes:") NEWLINE
  70.         EXIT WHEN HOLE_SIZE > 0.0
  71.     END_LOOP
  72.  
  73.     PRINT "Starting angle 0 degrees is 3 o'clock position."
  74.     PRINT "Positive (counter-clockwise) or negative values from 0#248 to 90#248 accepted."
  75.     PRINT "Default value is 0 degrees"
  76.     STARTING_ANGLE = 0.0
  77.     LOOP
  78.        ACCEPT STARTING_ANGLE PROMPT("Starting angle:") NEWLINE
  79.        EXIT WHEN (STARTING_ANGLE => 0.0  OR \   --line continuation
  80.                    STARTING_ANGLE <= 90.0)
  81.     END_LOOP
  82.  
  83.     PRINT "dig center of bolt circle:"
  84.     GETDIG(1, 0, NDIGS, ORIGIN_BOLT_CIRCLE)
  85.  
  86.     INCREMENT_ANGLE = 360.0 / REAL(NUM_HOLES)
  87.     BOLT_CIRCLE_RAD = BOLT_CIRCLE_DIAM / 2.0
  88.      
  89.     SEND "INS CIR D ",HOLE_SIZE,":CORG",
  90.     SEND DIGSTR(ORIGIN_BOLT_CIRCLE), "A",STARTING_ANGLE,
  91.     SEND "R",BOLT_CIRCLE_RAD, ",IA",INCREMENT_ANGLE, " N",(NUM_HOLES-1)
  92.     SEND
  93.     ECHO ON
  94.  
  95. END_LOOP --main loop
  96. END PROC
  97.  
  98.