Table of Content
HAL Forum
function longint FileSize (
string FilePath)
Description:
Returns specified file size in bytes.
Parameters:
FilePath File name and path from HansaWorld root directory
global
updating procedure CUST_AttachFileMn(record RcVc RepSpec)
begin
  Boolean found,testf;
  record INVc INr;
  record INVc oldINr;
  string 20 frin,toin;
  Integer cnt;
  String 100 fname;
  LongInt longvar;
  LongInt FileSizeLimit; // picture size limit in bytes
  Integer i,numoffiles;
  
  FileSizeLimit = 500000 // don't allow pictures that are bigger than 0.5MB
  
  if (blank(RepSpec.f1)) then begin
    frin = "00000000";
    toin = "ZZZZZZZZ";
  end;
  frin = FirstInRange(RepSpec.f1,20);
  toin = LastInRange(RepSpec.f1,20);
  INr.Code = frin;
  found = true;
  while (LoopMain(INr,1,found)) begin 
    if (nonblank(RepSpec.f1)) then begin 
      if (INr.Code>toin) then begin found = false; end;
    end;
    if (found) then begin
      if (blank(INr.AlternativeCode)) then begin
        goto LAttachFileMn2;
      end;
      numoffiles = CountFilesInDir("Pictures");
      for (i=0;i<numoffiles;i=i+1) begin
        fname = GetFileNameInDir("Pictures",i);
        if(FileSize("Pictures/" & fname)>FileSizeLimit) then begin
          if (Left(fname,Len(INr.AlternativeCode)+1) == INr.AlternativeCode & ".") then begin
           if (RecordLinkFile("Pictures/" & fname,0,INr,CurrentCompany)) then begin
               LogText(0,"File attached for Item " &  INr.Code &": " & fname);
           end;
           goto LAttachFileMn2;
         end;
        end;
      end;
    end;
LAttachFileMn2:;
  end;
LAttachFileMn:;  
  return;
end;
Related topics:
««