/* LONGNOTE.cdp - creates long disk-file notes in Cadkey */ /* This MeritBar utility imports disk notes bigger than 1024 bytes in Cadkey */ /* Long notes are created as several collected standard Cadkey notes */ /* Line-wrap is applied every 80 characters. */ /* */ /* For more FREE Cadkey Utilities check http://www.merituk.co.uk/mbarfrm.htm */ /* */ /* Program is supplied for training purposes without any warranty whatsoever */ /* Copyright (c) C.Popov, Merit Computer Solutions Ltd '94-99 */ /* email: chavdar@compuserve.com */ local double xt,yt,yofs,ang local int nlines,linelen,notenum,maxbytes,bytecount,eof local string $linestr[85],$t[995],$fname[60],$newline[2] :start xt=yt=yofs=ang=0 nlines=linelen=notenum=bytecount=eof=0 maxbytes=900 $newline="\n" $t[0]=0 close devin getstr "LONGNOTE: Enter file name or ESC to end =>",$fname,$fname if (@key <= -2) exit set devin,$fname,0 if (@error != 0) { pause "LONGNOTE: Cannot open file %s ",$fname goto start } /* get position for note */ getpos "LONGNOTE: Indicate note position",1 if (@key <= -2) goto start xt=@xview yt=@yview ang=@noteang/3.1415926*180 set collect,1 while (eof == 0) { getkey $linestr[0]=0 input "%80[^\n]",$linestr /* read a line of text (max 80 chars) */ if ((@error != 0) || (@key == 27)) eof = 1 input "%*1[\n]" /* skip the \n character (if any) */ prompt "NOTE %d (%d)=> %s",notenum+1,bytecount,$linestr call strcat,$linestr,$newline call strlen,$linestr,linelen if ((bytecount+linelen < maxbytes) && (eof == 0)) { /* add the line to the current text note */ bytecount=bytecount+linelen call strcat,$t,$linestr nlines=nlines+1 } else { /* create the current text note */ note xt=xt+yofs*sin(ang),yt=yt-yofs*cos(ang),$t,ang notenum=notenum+1 /* add line to the next note and calculate offsets */ $t[0]=0 call strcat,$t,$linestr yofs=nlines*@noteht*(1+@noteline) nlines=1 bytecount=0 } } set collect, 0 prompt "LONGNOTE: File %s is split into %d note(s)",$fname,notenum wait 1 goto start