DCAL Tools -- Selection Set Search
MODULE which_ss;                          {whichss.dcs}

Function whichss (ssno: IN OUT integer; SomeName : str8; LongName : str80): boolean;    PUBLIC;
{returns true & ss# & clears the set if a SS is available, false otherwise}
{SomeName is the name that will be given to the ss to be used}

VAR
  done,
  found_a_ss  : boolean;
  ss_num      : integer;
  ss_nam      : str8;
  msgstr      : str80;

BEGIN
  done := false;
  found_a_ss := false;
  ss_num := 7;
  REPEAT
    { Loop to find a named set}
    ssgetname(ss_num,ss_nam);
    IF strcomp(SomeName,ss_nam,-1) THEN
      ssClear(ss_num);
      ssno := ss_num;
      found_a_ss := True;
      done:= true;
    ELSIF ss_num = 0 THEN
      done := true;
    ELSE
    {loop to check next set}
      ss_num := ss_num -1;
    END;
  UNTIL done;
  IF NOT found_a_ss THEN
      done := false;
      ss_num  := 7;   { this was missing from original code   }
                      { causing the macro to ask the user for }
                      { assistance if the first (ss_num := 0) }
                      { set is in use                         }
    REPEAT
      ssgetname(ss_num,ss_nam);
      IF sslength(ss_num) =0 THEN
        {name and use empty ss}
        sssetname(ss_num,SomeName);
        ssno := ss_num;
        found_a_ss := True;
        done:= true;
      ELSIF ss_num = 0 THEN
        {user interaction, then repeat from start}
        msgstr := 'All Selection Sets are in use, ';
        strcat  (msgstr, LongName);
        strcat  (msgstr, ' requires an empty SS');
        wrterr  (msgstr);
        wrtmsg('Clear a Selection Set Now (Y/N)?');
        IF answer(0) THEN
          menuss;
          ss_num := 7;
        ELSE
          done := true;
        END;
      ELSE
      {loop to check next set}
        ss_num := ss_num -1;
      END;
    UNTIL done;
  END;
RETURN (found_a_ss);
END whichss;

END which_ss.

DDN Home

Revised: Monday, 18 January 2010
©2010 by DATACAD LLC. All rights reserved.
Please send all questions and comments
regarding this site to webmaster@datacad.com.
General Disclaimer