Jump to content

Procedure braces


MKMAY

Recommended Posts

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 frown.gif" border="0

[ 07-06-2002: Message edited by: MKMAY ]

Link to comment

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);

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...