The DataCAD Developer Network (DDN) is an online resource for information and support for DCAL® (DataCAD Applications Language) developers as well as anyone interested in creating fonts, toolbars, hatch patterns, or linetypes for use in DataCAD.
#74927 by dhs
Fri Oct 05, 2018 3:46 am
I have a problem with the lyr_read call in the following code:
Code: Select all   function CopyLyrContent (fromlyr, tolyr : lyraddr; zshift : double) : boolean;
  var
    tempfilename : str255;
    addr : entaddr;
    mode : mode_type;
    ent : entity;
  begin
     result := true;
     getpath (tempfilename, pathtmp);
     tempfilename := tempfilename + 'dh_lmtemp';
     if fileexists (tempfilename + '.dlf') then begin
      if not deletefile (tempfilename + '.dlf') then begin
        result := false;
        exit;
      end;
     end;
     result := (lyr_write (fromlyr, tempfilename) = 0);
     if result then
      result := (lyr_read (tolyr, tempfilename, false, false) = 0);

the lyr_read on the last line of the code snippet is returning a value of -5 (and hence the function result is false).
Some D4D notes I have suggest that -5 means that the layer file is not found, but I know that it is created as I can see it in FIle Explorer. The same notes suggest that I need to add the '.dlf' extension to the file name passed to lyr_read so I tried that but it produced a fault 19 error from 736 when I did so.
I believe that the layer parameters passed to this funciton are ok: fromlyr is the (not nil) result of either a lyr_first or lyr_next call, and tolyr is the address returned by a successful lyr_create call.

Is anybody able to offer any advice on the use of the lyr_read function? This bit of code is pretty much converted straight from some existing Classic DCAL code which works just fine.

Thanks,
David H.

Who is online

Users browsing this forum: No registered users and 7 guests

About DataCAD Forum

The DataCAD Forum is a FREE online community we provide to enhance your experience with DataCAD.

We hope you'll visit often to get answers, share ideas, and interact with other DataCAD users around the world.

DataCAD

Software for Architects Since 1984