{*******************************************************************************}
{ }
{ GET LINE MODULE }
{ by Patrick McConnell }
{ v 1.0 }
{ 2/17/96 }
{ }
{*******************************************************************************}
{ This module will allow the user to select a linetype. The currently defined }
{ linetypes are retrieved from the users DCAD.LIN file and displayed as key }
{ labels. The only parameter needed in the calling routine is linenumber. This }
{ parameter is returned as an integer corresponding to the linetype selected. }
{ The parameter is an IN OUT type, therefore it must be initialized in the }
{ calling routine prior to its use. }
{ }
{ The original version of this module will not recognize all of the 50 lines }
{ available with dcad7. The dcad6 limitation of 24 lines is set under maxltyp }
{ }
{ A holdover from pre version 6.0 is the ability to tell the module to stop }
{ reading the line file. This is done by inserting a string in the line file }
{ that consists of at least 2 >> characters. This was done to have the module }
{ ignore extra definitions beyond the 25 supported lines in pre version 6.0 }
{ This procedure is not required if the module is used for versions 6.0+ since }
{ the max number of lines to read is set as a constant MAXLTYPE. }
{ Note for Dcadwin 8.06+ the MAXLTYPE may be increased to 175 }
{*******************************************************************************}
MODULE get_line; { GETLINE.DCS }
CONST
maxltyp = 50; { Maximum number of line types supported }
ListStrLen = 8; { Length of menu list strings }
VAR
ltypbuf : ARRAY [1..maxltyp] OF Str8; { array of line type names}
ltypbuf_tog : ARRAY [1..maxltyp] OF boolean; { array of booleans to toggle linenames on menu }
numltyp : integer; { number of linetype currently defined }
done : boolean;
FUNCTION lesser (arg1, arg2 : integer) : integer;
{ compares two items and determines which is less }
BEGIN
IF arg1 < arg2 THEN
RETURN arg1;
ELSE
RETURN arg2;
END;
END lesser;
PROCEDURE dokeys (linenumber : IN OUT integer; linename : IN OUT str8);
VAR
key,
num_keys, ! how many keys to display on menu
b,
i : integer;
BEGIN
b := 0;
done := false;
REPEAT
lblsinit;
IF numltyp < (15 + b) THEN ! if there are less lines than the 15 keys
num_keys := (numltyp - b); ! only show the number of keys necessary
ELSE
num_keys := 15; ! otherwise show all 15 keys
END;
FOR i := 1 to num_keys DO
lblsett (i, ltypbuf[i + b], ltypbuf_tog[i + b]); ! put the available line names on the keys
END; ! highlight the active linetype
IF b > 0 THEN
lblset (16, 'ScrlBack');
END;
IF b < numltyp - 15 THEN
lblset (17, 'ScrlFwrd');
END;
lblset (20, 'Exit');
lblson;
wrtmsg ('Select Linetype.');
getesc (key);
key := fnKeyConv (key);
IF (1 <= key) AND (key <= num_keys) THEN ! if a displayed key was selected...
linenumber := (key + b); ! set linenumber to the selected line
linename := ltypbuf[key + b]; ! set linename to the selected line
done := true;
ELSIF key = 16 AND b > 0 THEN
b := b - 15;
ELSIF key = 17 AND b < numltyp - 15 THEN
b := b + 15;
ELSIF key = 20 THEN
done := true;
END;
UNTIL done;
END dokeys;
PROCEDURE getline (linenumber : IN OUT integer; linename : IN OUT str8); PUBLIC;
{ Reads the user defined line types available and returns the selected lines name and number. }
VAR
entire,
line : str80;
fl : file;
iores,
nomore, ! nomore is used to stop the reading of linetypes
i, ! from dcad.lin once the seperator characters have
len : integer; ! been found '>>>>>'
BEGIN
FOR i := 1 TO numltyp DO { clear the linetype toggles for the label keys }
ltypbuf_tog[i] := false; { sets all toggles to false. Prior to calling the dokeys }
END; { routines the toggles are set accordingly See below }
ltypbuf [1] := 'Solid ';
ltypbuf [2] := 'Dotted '; ! the built in linetypes must be hard coded
ltypbuf [3] := 'Dashed ';
ltypbuf [4] := 'Dot-Dash';
wrterr ('Reading user-defined line types.');
getpath (entire, pathsup);
strcat (entire, 'DCADWIN.LIN'); {line type definition file}
wrtmsg (entire);
nomore := 4;
numltyp := 4;
IF f_open (fl, entire, true, fmode_read) = fl_ok THEN
WHILE NOT f_eof (fl) DO
iores := f_rdstr (fl, line);
iores := f_rdln (fl);
IF line [2] = ">" THEN
nomore := maxltyp +1;
END;
IF line [1] = "*" AND nomore < maxltyp THEN ! '*' is for dcad 5 or lower
nomore := nomore + 1;
numltyp := numltyp + 1; ! increment line number counter
len := lesser (strlen (line) - 1, ListStrLen); ! set line name length to either actual length or ListStrLen
strsub (line, 2, len, ltypbuf [numltyp]); ! strip off '>' or '*' indicator
ELSIF line [1] = ">" AND nomore < maxltyp THEN ! '>' is for dcad 6+
nomore := nomore + 1;
numltyp := numltyp + 1; ! increment line number counter
len := lesser (strlen (line) - 1, ListStrLen); ! set line name length to either actual length or ListStrLen
strsub (line, 2, len, ltypbuf [numltyp]); ! strip off '>' or '*' indicator
END;
END; {WHILE}
iores := f_close (fl);
FOR i := 1 TO numltyp DO { go through the linetypes and see which one is currenly active }
IF i = linenumber THEN
ltypbuf_tog[i] := true;
END;
END;
dokeys (linenumber, linename);
ELSE
wrterr ('Could not open the support file DCAD.LIN'); ! if dcad.lin is not found
END;
FOR i := 1 to numltyp DO
strpad (ltypbuf [i], ListStrLen, " "); ! pad line name with spaces to set length to ListStrLen
END;
END getline;
END get_line.
|