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

  1. -- 19-Jan-88 NEHolt; Created - UPL 3.0 demo program
  2. --
  3. -- ------------------------------------  CHANGE.UPL  ------------------
  4. --  PURPOSE: Change entity LAYER, COLOR, and/or FONT all in one command.
  5. --  This command has two modes of operation: A) you select LAYER, COLOR,
  6. --  and/or FONT values and then digitize the entities to change, or
  7. --  B) you digitize entities that are all to be changed to the same
  8. --  LAYER, COLOR, and/or FONT as that of a final digitized entity.
  9. --
  10. --  Command Syntax:
  11. --  A) Change LAYER, COLOR, and/or FONT of digitized entities
  12. --      >>RUN CHANGE LAY x FONT y COLOR z : ent d1d2... <CR>
  13. --      >>RUN CHANGE COLOR x : ent WIN d1d2 <CR>
  14. --
  15. --  B) LAYER, COLOR, and/or FONT of dig ents to be same as another ent
  16. --      >>RUN CHANGE SAME : ent WIN d1d2... ; same as ent d <CR>
  17. --      >>RUN CHANGE SLAY SCOLOR : ent d1d2.. ; same as ent d <CR>
  18. --
  19. --  This program illustrates how to set up a MODIFIER TABLE for
  20. --  command line parameters. It shows an application of "ReadEnt" to
  21. --  determine entity index information, "WriteEnt" to change entity
  22. --  index information, and "RpntEnt" to repaint modified entities.
  23. --
  24. --
  25.  PROC MAIN
  26.  
  27.     INTEGER Ngot,Iend,i,ierr,MMIB(6000),SMib(1)
  28.     INTEGER ModSet,ELay,EColor,EFont,MData(8),SameData(8)
  29.     BOOLEAN ModYes,SL,SC,SF,AllSame
  30.     STRING JunkStr:42
  31.     REAL X
  32.  
  33. -- * * *   start of executable code   * * *
  34.     BREAK_CHAR = 3   -- set up CTRL-C in case of abort (^C=ASCII 003)
  35. --
  36.     DefineModifier(1,'Lay','I',False,0.0)   -- Define modifiers
  37.     DefineModifier(2,'Color','I',False,0.0)
  38.     DefineModifier(3,'Font','I',False,0.0)
  39.     DefineModifier(4,'SLayer','N',False,0.0)
  40.     DefineModifier(5,'SColor','N',False,0.0)
  41.     DefineModifier(6,'SFont','N',False,0.0)
  42.     DefineModifier(7,'SAME','N',False,0.0)
  43.     DefineModifier(8,'HELP','N',False,0.0)
  44. --
  45.     ELay=0; EColor=-1; EFont=-1
  46.     SL=FALSE; SC=FALSE; SF=FALSE; AllSame=FALSE;
  47. --  Allow modifiers to be typed in by user
  48.     AskModifiers(0)    --  0 = use UPL defined modifiers (above)
  49.  
  50.     GetModifier(8,ModYes,X,JunkStr)      -- Check for modifier 8 (HELP)
  51.     if ModYes then
  52.       Print ' CHANGE utility                                 19-Jan-88 NEHolt'
  53.       Print '1. Change LAY, FONT, and/or COLOR of entities in one command'
  54.       Print '  EX:  >>RUN CHANGE LAY x FONT y COLOR z : ent d1d2... [CR]'
  55.       Print '2. Change LAY, FONT, and/or COLOR of ents to be same as another'
  56.       Print '  EX:  >>RUN CHANGE SAME : ent d1d2... ; same as ent d [CR]'
  57.       Print '       >>RUN CHANGE SLAY SCOLOR : ent d1d2.. ; same as ent d [CR]'
  58.       goto Done
  59.     endif
  60.  
  61.     GetModifier(1,ModYes,X,JunkStr)      -- If modifier 1 entered (LAY)
  62.     if ModYes then ELay=Integer(X);endif -- then get LAYER value
  63.     if ELay<1 or Elay>256 then Elay=-1;endif  -- check LAYER limits
  64.  
  65.     GetModifier(2,ModYes,X,JunkStr)         -- If mod 2 entered (COLOR)
  66.     if ModYes then EColor=Integer(X);endif  -- then get COLOR value
  67.     if EColor<0 then EColor=-1;endif
  68.  
  69.     GetModifier(3,ModYes,X,JunkStr)          -- If mod 3 entered (FONT)
  70.     if ModYes then EFont=Integer(X);endif    -- then get FONT number
  71.  
  72.     GetModifier(4,SL,X,JunkStr)       -- If mod 4 selected then SL=TRUE
  73.     GetModifier(5,SC,X,JunkStr)       -- If mod 5 selected then SC=TRUE
  74.     GetModifier(6,SF,X,JunkStr)       -- If mod 6 selected then SF=TRUE
  75.     GetModifier(7,AllSame,X,JunkStr)  -- If mod 7 sel then AllSame=TRUE
  76.     if AllSame then
  77.       SL=TRUE; SC=TRUE; SF=TRUE
  78.     endif
  79.  
  80.  
  81. DIGDIM:
  82.     Print ' ent ',      -- prompt user to digitize entities to change
  83.     GetEnt(6000, Ngot, MMib(1), Iend)  -- get mib of digitized ent(s)
  84.     IF Ngot <1 then goto DONE;endif        -- quit if none digitized
  85.  
  86.     if (SL or SC or SF) then
  87.       --  G E T   "S A M E   A S"   E N T I T Y   I N F O
  88.       Print' same as ent ',                -- "Same As" mode selected
  89.       GetEnt(1,i,SMib(1),Iend)             -- get "same as" entity
  90.       if i<1 then goto Done;Endif          -- quit if none digitized
  91.  
  92. --  Read entity index info of the digitized "same as" entity. It's
  93. --  MIB number is in SMib(1).
  94.  
  95.       ReadEnt(SMib(1),SameData(1))   -- 8 words of data into SameData
  96.       if SL then ELay=SameData(4);Endif  -- 4th word gives LAYER
  97.       if SC then EColor=SameData(8);Endif -- 8th word gives COLOR
  98.  
  99. --  If digitized "same as" entity is not one that can have a FONT value
  100. --  then don't allow any FONT changes. SameData(1) 1st word gives
  101. --  entity type. 1=LINE, 2=STRING, 3=ARC, 10=XHA, 14=ELLIPSE.
  102.  
  103.       if SF then
  104.         if SameData(1)<=3 or SameData(1)=10 or SameData(1)=14 then
  105.           EFont=SameData(7)                    -- 7th word gives FONT
  106.         endif
  107.       endif
  108.  
  109.     endif
  110.  
  111.     Print
  112.  
  113.     -- P R O C E S S   E N T I T I E S   T O   C H A N G E
  114.     Loop i=1 to NGot
  115.       ReadEnt(MMib(i),MData(1))   -- Get entity's index data (8 words)
  116.       if ELay>0 then MData(4)=ELay;Endif     -- Set new LAYER if req'd
  117.       if EColor>=0 then MData(8)=EColor;Endif -- Set new COLOR if req'd
  118.  
  119.       if EFont>=0 then
  120.        if MData(1)<=3 or MData(1)=10 or MData(1)=14 then
  121.          MData(7)=EFont  -- if LINE, STR, ARC, XHA, or ELLIPSE set FONT
  122.        endif
  123.       endif
  124.  
  125.       WriteEnt(MMib(i),MData(1))    -- Write modified data back to ent
  126.     End_Loop
  127.  
  128.     --  D O N E.  R E P A I N T   M O D I F I E D   E N T I T I E S
  129.     RpntEnt(MMib(1),NGot,ierr)
  130.  
  131. DONE:
  132.  END PROC
  133.  
  134.