home *** CD-ROM | disk | FTP | other *** search
- -- 19-Jan-88 NEHolt; Created - UPL 3.0 demo program
- --
- -- ------------------------------------ CHANGE.UPL ------------------
- -- PURPOSE: Change entity LAYER, COLOR, and/or FONT all in one command.
- -- This command has two modes of operation: A) you select LAYER, COLOR,
- -- and/or FONT values and then digitize the entities to change, or
- -- B) you digitize entities that are all to be changed to the same
- -- LAYER, COLOR, and/or FONT as that of a final digitized entity.
- --
- -- Command Syntax:
- -- A) Change LAYER, COLOR, and/or FONT of digitized entities
- -- >>RUN CHANGE LAY x FONT y COLOR z : ent d1d2... <CR>
- -- >>RUN CHANGE COLOR x : ent WIN d1d2 <CR>
- --
- -- B) LAYER, COLOR, and/or FONT of dig ents to be same as another ent
- -- >>RUN CHANGE SAME : ent WIN d1d2... ; same as ent d <CR>
- -- >>RUN CHANGE SLAY SCOLOR : ent d1d2.. ; same as ent d <CR>
- --
- -- This program illustrates how to set up a MODIFIER TABLE for
- -- command line parameters. It shows an application of "ReadEnt" to
- -- determine entity index information, "WriteEnt" to change entity
- -- index information, and "RpntEnt" to repaint modified entities.
- --
- --
- PROC MAIN
-
- INTEGER Ngot,Iend,i,ierr,MMIB(6000),SMib(1)
- INTEGER ModSet,ELay,EColor,EFont,MData(8),SameData(8)
- BOOLEAN ModYes,SL,SC,SF,AllSame
- STRING JunkStr:42
- REAL X
-
- -- * * * start of executable code * * *
- BREAK_CHAR = 3 -- set up CTRL-C in case of abort (^C=ASCII 003)
- --
- DefineModifier(1,'Lay','I',False,0.0) -- Define modifiers
- DefineModifier(2,'Color','I',False,0.0)
- DefineModifier(3,'Font','I',False,0.0)
- DefineModifier(4,'SLayer','N',False,0.0)
- DefineModifier(5,'SColor','N',False,0.0)
- DefineModifier(6,'SFont','N',False,0.0)
- DefineModifier(7,'SAME','N',False,0.0)
- DefineModifier(8,'HELP','N',False,0.0)
- --
- ELay=0; EColor=-1; EFont=-1
- SL=FALSE; SC=FALSE; SF=FALSE; AllSame=FALSE;
- -- Allow modifiers to be typed in by user
- AskModifiers(0) -- 0 = use UPL defined modifiers (above)
-
- GetModifier(8,ModYes,X,JunkStr) -- Check for modifier 8 (HELP)
- if ModYes then
- Print ' CHANGE utility 19-Jan-88 NEHolt'
- Print '1. Change LAY, FONT, and/or COLOR of entities in one command'
- Print ' EX: >>RUN CHANGE LAY x FONT y COLOR z : ent d1d2... [CR]'
- Print '2. Change LAY, FONT, and/or COLOR of ents to be same as another'
- Print ' EX: >>RUN CHANGE SAME : ent d1d2... ; same as ent d [CR]'
- Print ' >>RUN CHANGE SLAY SCOLOR : ent d1d2.. ; same as ent d [CR]'
- goto Done
- endif
-
- GetModifier(1,ModYes,X,JunkStr) -- If modifier 1 entered (LAY)
- if ModYes then ELay=Integer(X);endif -- then get LAYER value
- if ELay<1 or Elay>256 then Elay=-1;endif -- check LAYER limits
-
- GetModifier(2,ModYes,X,JunkStr) -- If mod 2 entered (COLOR)
- if ModYes then EColor=Integer(X);endif -- then get COLOR value
- if EColor<0 then EColor=-1;endif
-
- GetModifier(3,ModYes,X,JunkStr) -- If mod 3 entered (FONT)
- if ModYes then EFont=Integer(X);endif -- then get FONT number
-
- GetModifier(4,SL,X,JunkStr) -- If mod 4 selected then SL=TRUE
- GetModifier(5,SC,X,JunkStr) -- If mod 5 selected then SC=TRUE
- GetModifier(6,SF,X,JunkStr) -- If mod 6 selected then SF=TRUE
- GetModifier(7,AllSame,X,JunkStr) -- If mod 7 sel then AllSame=TRUE
- if AllSame then
- SL=TRUE; SC=TRUE; SF=TRUE
- endif
-
-
- DIGDIM:
- Print ' ent ', -- prompt user to digitize entities to change
- GetEnt(6000, Ngot, MMib(1), Iend) -- get mib of digitized ent(s)
- IF Ngot <1 then goto DONE;endif -- quit if none digitized
-
- if (SL or SC or SF) then
- -- G E T "S A M E A S" E N T I T Y I N F O
- Print' same as ent ', -- "Same As" mode selected
- GetEnt(1,i,SMib(1),Iend) -- get "same as" entity
- if i<1 then goto Done;Endif -- quit if none digitized
-
- -- Read entity index info of the digitized "same as" entity. It's
- -- MIB number is in SMib(1).
-
- ReadEnt(SMib(1),SameData(1)) -- 8 words of data into SameData
- if SL then ELay=SameData(4);Endif -- 4th word gives LAYER
- if SC then EColor=SameData(8);Endif -- 8th word gives COLOR
-
- -- If digitized "same as" entity is not one that can have a FONT value
- -- then don't allow any FONT changes. SameData(1) 1st word gives
- -- entity type. 1=LINE, 2=STRING, 3=ARC, 10=XHA, 14=ELLIPSE.
-
- if SF then
- if SameData(1)<=3 or SameData(1)=10 or SameData(1)=14 then
- EFont=SameData(7) -- 7th word gives FONT
- endif
- endif
-
- endif
-
- Print
-
- -- P R O C E S S E N T I T I E S T O C H A N G E
- Loop i=1 to NGot
- ReadEnt(MMib(i),MData(1)) -- Get entity's index data (8 words)
- if ELay>0 then MData(4)=ELay;Endif -- Set new LAYER if req'd
- if EColor>=0 then MData(8)=EColor;Endif -- Set new COLOR if req'd
-
- if EFont>=0 then
- if MData(1)<=3 or MData(1)=10 or MData(1)=14 then
- MData(7)=EFont -- if LINE, STR, ARC, XHA, or ELLIPSE set FONT
- endif
- endif
-
- WriteEnt(MMib(i),MData(1)) -- Write modified data back to ent
- End_Loop
-
- -- 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
- RpntEnt(MMib(1),NGot,ierr)
-
- DONE:
- END PROC
-