home *** CD-ROM | disk | FTP | other *** search
- Procedure Washer;
- {
- (Windows version)
- ⌐1996, Diehl Graphsoft, Inc.
- Developed by Tom Urie
-
- This procedure draws plain, lock, and user specified washers.
- }
-
- LABEL 10,20,30,99;
- CONST
- Filename1='External\Data\PlnWashi.txt';
- Filename2='External\Data\PlnWashm.txt';
- Filename3='External\Data\LokWashi.txt';
- Filename4='External\Data\LokWashm.txt';
- SWF=0.05; {Used to determine the width of the slot on lock washers.}
- Theta=30.0; {Angle of the slot on lock washers.}
- PathL=14;
- VAR
- ID,OD,T : REAL;
- OD1,T1 : ARRAY [1..3] OF REAL;
- x0,y0,x1,y1,x2,y2,SW:REAL;
- Style,Type,View,Series,n:INTEGER;
- RFlag : ARRAY[1..5] OF INTEGER;
- Ans,Abort,OK:BOOLEAN;
- Sz,Size,Size1:STRING;
- FileName:ARRAY [1..4] OF STRING;
- SA,DA:LONGINT;
- Fmt:INTEGER;
- SF,UPI:REAL;
- UM,UM2:STRING;
- Inch:BOOLEAN;
-
- Procedure WasherDialog;
- {
- This procedure defines the various dialog boxes.
- }
- VAR
- Width,x1,y1,x2,y2,px1,px2,px3,px4,py1,py2 : INTEGER;
-
- Procedure AlignScr(Width:INTEGER; VAR x1,x2:INTEGER);
- VAR
- scrx1,scry1,scrx2,scry2:INTEGER;
- BEGIN
- GetScreen(scrx1,scry1,scrx2,scry2);
- x1:=((scrx1+scrx2) div 2)-(Width div 2);
- x2:=x1+Width;
- END;
-
- Procedure MakeDialog1;
- {
- This procedure defines the dialog box for Plain Washers.
- }
- CONST
- y1=100;
- scnh=265; scnw=280;
- h=30;
- BEGIN
- AlignScr(scnw,x1,x2);
- y2:=y1+scnh;
- px3:=scnw-160;
- px4:=scnw-100;
- px1:=scnw-80;
- px2:=scnw-20;
- py1:=scnh-40;
- py2:=scnh-20;
-
- BeginDialog(1,1,x1,y1,x2,y2);
- AddButton('OK',1,1,px3,py1,px4,py2);
- AddButton('Cancel',2,1,px1,py1,px2,py2);
- AddField('Type:',13,1,20,40-h,60,55-h);
- AddButton('Inch (Type B Plain Washer)',14,3,20,65-h,250,80-h);
- AddButton('Metric (Metric Plain Washer)',15,3,20,85-h,260,100-h);
- AddField('Bolt or Screw Size:',4,1,20,118-h,160,133-h);
- AddField('',5,2,165,118-h,225,133-h);
- AddField('in',16,1,233,118-h,255,133-h);
- AddField('Series:',6,1,20,150-h,100,165-h);
- AddButton('Narrow',7,3,20,175-h,100,190-h);
- AddButton('Regular',8,3,20,195-h,100,210-h);
- AddButton('Wide',9,3,20,215-h,100,230-h);
- AddField('View:',10,1,165,150-h,205,165-h);
- AddButton('Top',11,3,165,175-h,205,190-h);
- AddButton('Side',12,3,165,195-h,210,210-h);
- EndDialog;
- END;
-
- Procedure MakeDialog2;
- {
- This procedure defines the dialog box for User Defined Plain Washers.
- }
- CONST
- y1=100;
- scnh=170; scnw=270;
- h=30;
- BEGIN
- AlignScr(scnw,x1,x2);
- y2:=y1+scnh;
- px3:=scnw-160;
- px4:=scnw-100;
- px1:=scnw-80;
- px2:=scnw-20;
- py1:=scnh-40;
- py2:=scnh-20;
-
- BeginDialog(2,1,x1,y1,x2,y2);
- AddButton('OK',1,1,px3,py1,px4,py2);
- AddButton('Cancel',2,1,px1,py1,px2,py2);
- AddField('Inside Diameter:',4,1,20,45-h,143,60-h);
- AddField('',5,2,156,45-h,240,60-h);
- AddField('Outside Diameter:',6,1,20,70-h,143,85-h);
- AddField('',7,2,156,70-h,240,85-h);
- AddField('Thickness:',8,1,20,95-h,143,110-h);
- AddField('',9,2,156,95-h,240,110-h);
- AddField('View:',10,1,20,120-h,90,135-h);
- AddButton('Top',11,3,20,145-h,60,160-h);
- AddButton('Side',12,3,20,165-h,65,180-h);
- EndDialog;
- END;
-
- Procedure MakeDialog3;
- {
- This procedure defines the dialog box for Lock Washers.
- }
- CONST
- y1=100;
- scnh=245; scnw=280;
- h=30;
- BEGIN
- AlignScr(scnw,x1,x2);
- y2:=y1+scnh;
- px3:=scnw-160;
- px4:=scnw-100;
- px1:=scnw-80;
- px2:=scnw-20;
- py1:=scnh-40;
- py2:=scnh-20;
-
- BeginDialog(3,1,x1,y1,x2,y2);
- AddButton('OK',1,1,px3,py1,px4,py2);
- AddButton('Cancel',2,1,px1,py1,px2,py2);
- AddField('Type:',13,1,20,40-h,60,55-h);
- AddButton('Inch',14,3,20,65-h,70,80-h);
- AddButton('Metric',15,3,80,65-h,140,80-h);
- AddField('Bolt or Screw Size:',4,1,20,98-h,160,113-h);
- AddField('',5,2,165,98-h,225,113-h);
- AddField('in',17,1,233,98-h,255,113-h);
- AddField('Series:',6,1,20,130-h,100,145-h);
- AddButton('Regular',7,3,20,155-h,100,170-h);
- AddButton('Heavy',8,3,20,175-h,100,190-h);
- AddButton('Extra Duty',9,3,20,195-h,100,210-h);
- AddField('',16,1,105,195-h,155,210-h);
- AddField('View:',10,1,165,130-h,205,145-h);
- AddButton('Top',11,3,165,155-h,205,170-h);
- AddButton('Side',12,3,165,175-h,210,190-h);
- EndDialog;
- END;
-
- Procedure MakeDialog4;
- {
- This procedure defines the main dialog box.
- }
- CONST
- y1=100;
- scnh=170; scnw=270;
- h=30;
- BEGIN
- AlignScr(scnw,x1,x2);
- y2:=y1+scnh;
- px3:=scnw-160;
- px4:=scnw-100;
- px1:=scnw-80;
- px2:=scnw-20;
- py1:=scnh-40;
- py2:=scnh-20;
-
- BeginDialog(4,1,x1,y1,x2,y2);
- AddButton('OK',1,1,px3,py1,px4,py2);
- AddButton('Cancel',2,1,px1,py1,px2,py2);
- AddField('Type of Washer:',4,1,20,40-h,195,55-h);
- AddButton('Plain Washer - Commercial',5,3,20,65-h,220,80-h);
- AddButton('Plain Washer - User Defined',6,3,20,85-h,220,100-h);
- AddButton('Helical Spring Lock Washer',7,3,20,105-h,220,120-h);
- EndDialog;
- END;
-
- Procedure MakeDialog5;
- {
- This procedure defines the warning dialog box for missing data files.
- }
- CONST
- y1=100;
- scnh=120; scnw=395;
- VAR
- Count1,Count2,Count3,Count4 : INTEGER;
- File1,File2,File3,File4,WarningMsg : STRING;
- BEGIN
- AlignScr(scnw,x1,x2);
- y2:=y1+scnh;
- Count1:=Len(Filename1)-PathL;
- Count2:=Len(Filename2)-PathL;
- Count3:=Len(Filename3)-PathL;
- Count4:=Len(Filename4)-PathL;
- File1:=Copy(Filename1,PathL+1,Count1);
- File2:=Copy(Filename2,PathL+1,Count2);
- File3:=Copy(Filename3,PathL+1,Count3);
- File4:=Copy(Filename4,PathL+1,Count4);
- WarningMsg:=Concat('The files: ',File1,', ',File2,', ',File3,', and ',File4,' must be in the Data folder located in
- the External folder for this program to run.');
- BeginDialog(5,1,x1,y1,x2,y2);
- AddButton('OK',1,1,155,75,235,105);
- AddField(WarningMsg,2,1,20,10,380,60);
- EndDialog;
- END;
-
- BEGIN
- MakeDialog1;
- MakeDialog2;
- MakeDialog3;
- MakeDialog4;
- MakeDialog5;
- END;
-
- Procedure GetWarning;
- {
- This procedure displays the file warning dialog box.
- }
- VAR
- Done:Boolean;
- Item:Integer;
- BEGIN
- Done:=FALSE;
- GetDialog(5);
- SetTitle('Warning!');
- REPEAT
- DialogEvent(Item);
- IF Item=1 THEN
- Done:=True;
- UNTIL Done;
- ClrDialog;
- END;
-
- Procedure SetRButton(i,Item : INTEGER);
- BEGIN
- IF RFlag[i] <> Item THEN BEGIN
- SetItem(RFlag[i],FALSE);
- SetItem(Item,TRUE);
- RFlag[i]:=Item;
- END;
- END;
-
- Procedure GetInfo1;
- {
- This procedure displays the Plain Washer dialog box and retrieves the information.
- }
- LABEL 10;
- VAR
- Done:boolean;
- Item:integer;
-
- BEGIN
- Done:=FALSE;
- Abort:=FALSE;
- IF Ans THEN BEGIN
- Ans:=FALSE;
- GOTO 10;
- END;
- Type:=1;
- View:=1;
- Series:=2;
- Inch:=TRUE;
- RFlag[1]:=8;
- RFlag[2]:=11;
- RFlag[3]:=14;
- 10:GetDialog(1);
- SetTitle('Plain Washers');
- SetItem(RFlag[1],TRUE);
- SetItem(RFlag[2],TRUE);
- SetItem(RFlag[3],TRUE);
- IF Inch THEN SetField(16,'in')
- ELSE SetField(16,'mm');
- SetField(5,Size1);
- SelField(5);
- REPEAT
- DialogEvent(Item);
- IF Item=1 THEN
- Done:=TRUE;
- IF Item=2 then BEGIN
- Done:=TRUE;
- Abort:=TRUE;
- END;
- IF (Item > 6) AND (Item < 10) THEN BEGIN
- SetRButton(1,Item);
- Series:=Item-6;
- END;
- IF (Item=11) OR (Item=12) THEN BEGIN
- SetRButton(2,Item);
- View:=Item-10;
- END;
- IF Item=14 THEN BEGIN
- SetRButton(3,Item);
- Type:=1;
- Inch:=TRUE;
- SetField(16,'in');
- SelField(5);
- END;
- IF Item=15 THEN BEGIN
- SetRButton(3,Item);
- Type:=2;
- Inch:=FALSE;
- SetField(16,'mm');
- SelField(5);
- END;
- UNTIL DONE;
- Size1:=GetField(5);
- UprString(Size);
- Size:=ConCat('''',Size1,'''');
- UprString(Size);
- ClrDialog;
- END;
-
- Procedure GetInfo2;
- {
- This procedure displays the User Defined Washer dialog box and retrieves the information.
- }
- LABEL 10,15,99;
- VAR
- Done:boolean;
- Item:integer;
-
- BEGIN
- Done:=FALSE;
- Abort:=FALSE;
- IF Ans THEN BEGIN
- Ans:=FALSE;
- GOTO 10;
- END;
- View:=1;
- RFlag[1]:=11;
- 10:GetDialog(2);
- SetTitle('User Defined Plain Washers');
- SetItem(RFlag[1],TRUE);
- SetField(5,Num2Str(4,ID));
- SetField(7,Num2Str(4,OD));
- SetField(9,Num2Str(4,T));
- SelField(5);
- 15:REPEAT
- DialogEvent(Item);
- IF Item=1 THEN
- Done:=TRUE;
- IF Item=2 then BEGIN
- Done:=TRUE;
- Abort:=TRUE;
- END;
- IF (Item = 11) OR (Item = 12) THEN BEGIN
- SetRButton(1,Item);
- View:=Item-10;
- END;
- UNTIL DONE;
- IF Abort THEN GOTO 99;
- OK:=ValidNumStr(GetField(5),ID);
- OK:=ValidNumStr(GetField(7),OD);
- OK:=ValidNumStr(GetField(9),T);
- 99:ClrDialog;
- END;
-
- Procedure GetInfo3;
- {
- This procedure displays the Helical Spring Lock Washer dialog box and retrieves the informaion.
- }
- LABEL 10;
- VAR
- Done:boolean;
- Item:integer;
-
- BEGIN
- Done:=FALSE;
- Abort:=FALSE;
- IF Ans THEN BEGIN
- Ans:=FALSE;
- GOTO 10;
- END;
- Type:=3;
- View:=1;
- Series:=1;
- Inch:=TRUE;
- RFlag[1]:=7;
- RFlag[2]:=11;
- RFlag[3]:=14;
- 10:GetDialog(3);
- SetTitle('Helical Spring Lock Washers');
- SetItem(RFlag[1],TRUE);
- SetItem(RFlag[2],TRUE);
- SetItem(RFlag[3],TRUE);
- IF Inch THEN BEGIN
- SetField(16,'');
- SetField(17,'in');
- END
- ELSE BEGIN
- SetField(16,'<n/a>');
- SetField(17,'mm');
- END;
- SetField(5,Size1);
- SelField(5);
- REPEAT
- DialogEvent(Item);
- IF Item=1 THEN
- Done:=TRUE;
- IF Item=2 then BEGIN
- Done:=TRUE;
- Abort:=TRUE;
- END;
- IF (Item > 6) AND (Item < 9) THEN BEGIN
- SetRButton(1,Item);
- Series:=Item-6;
- END;
- IF Item = 9 THEN BEGIN
- If Type <> 4 THEN BEGIN
- SetRButton(1,Item);
- Series:=Item-6;
- END
- ELSE Sysbeep;
- END;
- IF (Item=11) OR (Item=12) THEN BEGIN
- SetRButton(2,Item);
- View:=Item-10;
- END;
- IF Item=14 THEN BEGIN
- SetRButton(3,Item);
- Type:=3;
- Inch:=TRUE;
- SetField(16,'');
- SetField(17,'in');
- SelField(5);
- END;
- IF Item=15 THEN BEGIN
- SetRButton(3,Item);
- Type:=4;
- Inch:=FALSE;
- SetField(16,'<n/a>');
- SetField(17,'mm');
- SelField(5);
- IF Series = 3 THEN BEGIN
- SetRButton(1,7);
- Series:=1;
- END;
- END;
- UNTIL DONE;
- Size1:=GetField(5);
- UprString(Size);
- Size:=ConCat('''',Size1,'''');
- UprString(Size);
- ClrDialog;
- END;
-
- Procedure GetInfo4;
- {
- This procedure displays the main dialog box and retrieves the information.
- }
- VAR
- Done:BOOLEAN;
- Item:INTEGER;
-
- BEGIN
- Done:=FALSE;
- Abort:=FALSE;
- RFlag[1]:=5;
- GetDialog(4);
- SetTitle('Washers');
- SetItem(RFlag[1],TRUE);
- REPEAT
- DialogEvent(Item);
- IF Item = 1 THEN
- Done:=TRUE;
- IF Item = 2 then BEGIN
- Done:=TRUE;
- Abort:=TRUE;
- END;
- IF Item > 4 THEN BEGIN
- SetRButton(1,Item);
- Style:=Item-4;
- END;
- UNTIL DONE;
- ClrDialog;
- END;
-
- Procedure GetData;
- {
- This procedure opens the data file and reads the data.
- }
- LABEL 10,20,99;
- BEGIN
- Filename[1]:=Filename1;
- Filename[2]:=Filename2;
- Filename[3]:=Filename3;
- Filename[4]:=Filename4;
- Open(Filename[Type]);
- IF FndError THEN BEGIN
- Sysbeep;
- GetWarning;
- Abort:=TRUE;
- GoTo 99;
- END;
- WHILE NOT Eoln(Filename[Type]) DO BEGIN
- IF Type <> 4 THEN
- ReadLn(Sz,ID,OD1[1],OD1[2],OD1[3],T1[1],T1[2],T1[3])
- ELSE
- ReadLn(Sz,ID,OD1[1],OD1[2],T1[1],T1[2]);
- IF Sz=Size THEN GoTo 20;
- END;
- Close(Filename[Type]);
- 10:SysBeep;
- AlrtDialog('That size is not available!');
- Ans:=TRUE;
- GoTo 99;
- 20:Close(Filename[Type]);
- FOR n:=1 TO 3 DO BEGIN
- IF (Series = n) AND (OD1[n] = 0.0) THEN GOTO 10;
- END;
- 99:END;
-
- {
- Main program.
- }
- BEGIN
- DSelectAll;
- PushAttrs;
- Style:=1;
- {
- Create the dialog boxes.
- }
- WasherDialog;
- SetCursor(ArrowC);
- {
- Display the main dialog box and get the type of washer to draw.
- }
- GetInfo4;
- IF Abort THEN GOTO 99;
- {
- Display the proper dialog box and get the information.
- }
- IF (Style=1) OR (Style=3) THEN BEGIN
- Ans:=FALSE;
- 10:IF Style=1 THEN
- GetInfo1
- ELSE
- GetInfo3;
- IF Abort THEN GOTO 99;
- GetData;
- IF Abort THEN GOTO 99;
- IF Ans THEN GOTO 10;
- OD:=OD1[Series];
- T:=T1[Series];
- END
- ELSE BEGIN
- Type:=5;
- ANS:=FALSE;
- 20:GetInfo2;
- IF Abort THEN GOTO 99;
- IF ID < OD THEN GOTO 30;
- Ans:=TRUE;
- SysBeep;
- AlrtDialog('ID must be less than OD!');
- GOTO 20;
- END;
- {
- Get the units per inch and adjust the parameters accordingly.
- }
- GetUnits(SA,DA,Fmt,UPI,UM,UM2);
- IF Inch=TRUE THEN
- SF:=UPI
- ELSE
- SF:=UPI/25.4;
- ID:=SF*ID;
- OD:=SF*OD;
- T:=SF*T;
- 30:GetPt(x0,y0);
- IF View=1 THEN BEGIN
- {
- Draw Top View.
- }
- Absolute;
- MoveTo(x0,y0);
- Relative;
- Arc(-OD/2,OD/2,OD/2,-OD/2,0,360);
- Arc(-ID/2,ID/2,ID/2,-ID/2,0,360);
- IF (Type=3) OR (TYPE=4) THEN BEGIN
- SW:=SWF*ID;
- x1:=SW/2;
- y1:=Sqrt((OD/2)^2-x1^2);
- x2:=SW/2;
- y2:=Sqrt((ID/2)^2-x1^2);
- Move(-x1,-y1);
- Line(0,(y1-y2));
- Move(2*x1,0);
- Line(0,(y2-y1));
- END;
- END
- ELSE BEGIN
- {
- Draw Side View.
- }
- Absolute;
- MoveTo(x0,y0);
- Relative;
- Rect(-OD/2,t,OD/2,0);
- PushAttrs;
- PenPat(-2);
- Move(-ID/2,0);
- Line(0,t);
- Move(ID,0);
- Line(0,-t);
- PopAttrs;
- IF (Type=3) OR (TYPE=4) THEN BEGIN
- SW:=SWF*ID;
- x1:=T*Tan(Deg2Rad(Theta));
- Move(-ID/2,T);
- Line(-x1,-T);
- Move(-SW,0);
- Line(x1,T);
- END;
- END;
- Group;
- PopAttrs;
- 99:END;
-
- Run(Washer);
-