MKMAY Posted July 6, 2002 Share Posted July 6, 2002 Hi everyone I've been reading your board for a while and decided to become a neebie.I'm trying to learn the language so we learn by example. Can anyone tell me why this procedure does not work. I copied it off a site that was reccomended. procedure braces;VAR x,y,x1,y1,x2,y2:REAL; ymid,xmid,temp:REAL;BEGIN Getrect(x1,y1,x2,y2); {get the box} GetMouse(x,y); {will use this to determine which way the boxwas drawn} ymid:=(y1+y2)/2; xmid:=(x1+x2)/2; if xymid then begin {box drawn bottom to top} temp:=y1; y1:=y2; y2:=temp; end; if (abs(y2-y1)>abs(x2-x1)) then begin {box drawn taller thanwide} beginpoly; moveto(x1,y1); curveto(xmid,y1); curveto(xmid,ymid); lineto(x2,ymid); curveto(xmid,ymid); curveto(xmid,y2); lineto(x1,y2); endpoly; end else begin {box drawn wider than tall} beginpoly; moveto(x1,y1); curveto(x1,ymid); curveto(xmid,ymid); lineto(xmid,y2); curveto(xmid,ymid); curveto(x2,ymid); lineto(x2,y1); endpoly; end; redrawall;END; run(braces); This is what I copied,so it my be garbled.Thanks for your help.MKMAY [ 07-06-2002: Message edited by: MKMAY ] Quote Link to comment
Fuge Posted July 6, 2002 Share Posted July 6, 2002 Just remove the section -----------------if xymid then begin {box drawn bottom to top}temp:=y1;y1:=y2;y2:=temp;end;------------------The script should work fine without it.The xymid was not declared as a variable. Dave Quote Link to comment
MKMAY Posted July 6, 2002 Author Share Posted July 6, 2002 Thanks Dave Will give it try MKMAY Quote Link to comment
MullinRJ Posted July 6, 2002 Share Posted July 6, 2002 No, No!!! Don't take it out. Add a little more. It looks like some code came up missing, but enough was there to recreate it. Try this. When you really get motivated, this piece of code would make a nice PIO (Plug In Object). procedure braces;VAR x, y, x1, y1, x2, y2 :REAL; ymid, xmid, temp :REAL;BEGIN Getrect(x1, y1, x2, y2); {get the box} GetMouse(x, y); {will use this to determine which way the box was drawn} ymid := (y1+y2)/2; xmid := (x1+x2)/2; { I played with the code here. XYMID was undefined, that is where the garbling occurred. }{ Change the "<" to ">" in the next 2 if's and the braces will draw the other way. } if (y < ymid) then begin {box drawn top to bottom} temp := y1; y1 := y2; y2 := temp; end; if (x < xmid) then begin {box drawn right to left} temp := x1; x1 := x2; x2 := temp; end; if (abs(y2-y1) > abs(x2-x1)) then begin {box drawn taller than wide} beginpoly; moveto(x1, y1); curveto(xmid, y1); curveto(xmid, ymid); lineto(x2, ymid); curveto(xmid, ymid); curveto(xmid, y2); lineto(x1, y2); endpoly; end else begin {box drawn wider than tall} beginpoly; moveto(x1, y1); curveto(x1, ymid); curveto(xmid, ymid); lineto(xmid, y2); curveto(xmid, ymid); curveto(x2, ymid); lineto(x2, y1); endpoly; end; redrawall;END;run(braces); Quote Link to comment
MKMAY Posted July 7, 2002 Author Share Posted July 7, 2002 MullinRJTo late! but I made a copy of course.Will play with it Again thanks MKMAY Quote Link to comment
MKMAY Posted July 8, 2002 Author Share Posted July 8, 2002 MullenRJ Hey that worked fine have already started to modify the code to make other braces. Thanks again I still have a long way to go. MKMay 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.