Assembly Posted September 27, 2010 Share Posted September 27, 2010 Procedure MyDuplicate; Var Htemp:HANDLE; hTemp1:Handle; BEGIN; BeginPoly; Moveto(0,0); Line(100,0); LIne(0,-100); ENDPOLY; Htemp:=LnewObj; BEGINGROUP; Htemp:=Hduplicate(Htemp,100,0); Htemp:=Hduplicate(Htemp,100,0); ENDGROUP; Message(Concat('Htemp:',Htemp,' Group:',lnewobj)); END; RUN (MyDuplicate); This procedure returns a Nil handle to the group. If I move the poly creation to inside the group call it works. ?. Quote Link to comment
MullinRJ Posted September 27, 2010 Share Posted September 27, 2010 Justin, ???Your way should work. I think it's a bug. This will do the same thing, without the elegance of concise code. Procedure MyDuplicate; Var Boo :Boolean; Htemp, GrpHnd: HANDLE; BEGIN BEGINPOLY; Moveto(0, 0); Line(100, 0); LIne(0, -100); ENDPOLY; Htemp := LnewObj; GrpHnd := nil; BEGINGROUPN(GrpHnd); Locus(0, 0); { dummy object } ENDGROUP; Htemp := Hduplicate(Htemp, 100, 0); Boo := SetParent(HTemp, GrpHnd); { move inside group } Htemp := Hduplicate(Htemp, 100, 0); { dups stay in group } DelObject(FinGroup(GrpHnd)); { Delete locus } Message('Htemp: ', Htemp, ' Group: ', GrpHnd); END; RUN (MyDuplicate); Quote Link to comment
Miguel Barrera Posted September 27, 2010 Share Posted September 27, 2010 Justin, To my surprise, the following also compiled correctly and explains the reason for the group nil handle in your code. Procedure MyDuplicate; VAR i,totDup: INTEGER; grpHdl,Htemp:HANDLE; BEGIN; BeginGroup; BeginPoly; Moveto(0,0); Line(100,0); LIne(0,-100); ENDPOLY; Htemp:=LnewObj; EndGroup; grpHdl:= LNewObj; IF grpHdl <> NIL THEN BEGIN totDup:= 2; FOR i:= 1 TO totDup DO Htemp:= HDuplicate(Htemp,100,0); ResetBBox(grpHdl); END; Message(Concat('Htemp:',Htemp,' Group:',grpHdl)); END; RUN (MyDuplicate); The HDuplicate function places the duplicate in the same container as the original. Since you created the poly outside the group, all the duplicates are created outside the group and consequently, the group is empty at the end of the script and returns a nil handle. But agree with Raymond that the duplicate should be placed in the right container to avoid any changes to HDuplicate in the future. Personally I use CreateDuplicateObject because it gives a handle to the duplicate object for further processing in case I need to modify its size or attributes. Procedure MyDuplicate; VAR i,totDup: INTEGER; grpHdl,Htemp,dupHdl:HANDLE; BEGIN; BeginGroup; BeginPoly; Moveto(0,0); Line(100,0); LIne(0,-100); ENDPOLY; Htemp:=LnewObj; EndGroup; grpHdl:= LNewObj; IF grpHdl <> NIL THEN BEGIN totDup:= 2; FOR i:= 1 TO totDup DO BEGIN dupHdl:= CreateDuplicateObject(Htemp,grpHdl); HMove(dupHdl,i * 100,0); END; ResetBBox(grpHdl); END; Message(Concat('Htemp:',Htemp,' Group:',grpHdl)); END; RUN (MyDuplicate); Quote Link to comment
Pat Stanford Posted September 27, 2010 Share Posted September 27, 2010 I don't think it is directly applicable to this problem, but I just want to bring up the fact that PIOs are not created during the running of a script, but rather during the redraw after the script is drawn. This means that if you use a PIO inside a script, there is no way to get a handle to it and modify it as it has not been created. Very annoying with no good work around if you don't have the original PIO code to work with. Quote Link to comment
Assembly Posted September 27, 2010 Author Share Posted September 27, 2010 I note there is also a new function in 2011. PROCEDURE BeginGroupN( VAR groupHandle :HANDLE); Waiting for my copy so have not tested MyDuplicate with BeginGroupN. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.