Recent

Author Topic: [SOLVED] To drop into DBMemo, filename is chopped (incomplete)  (Read 3345 times)

Elmug

  • Hero Member
  • *****
  • Posts: 849
Hi again,

This is what I have now, but finding an issue (FileName is correct at DBMemo box, but not when copied to Edit1.Text box):
Code: [Select]
procedure TForm1.FormDropFiles(Sender: TObject; const FileName: array of String);
var
  i: Integer;
begin

   DBmemo1.Lines.Insert(0, FileName[i]);   
      {result of above line is: DBMemo correctly shows FileName, with drive and PATH}

   Edit1.Text := DBMemo1.Lines[0];
       {result of above line is: Edit1.Text (the filename) is incomplete,
chopped off string. Starts correctly with    drive, folder, and ends in incomplete
 folder name, as if the string did not fit the container}

  {DBmemo1.Lines.LoadFromFile(Edit1.Text); }
        //this is intent, but now commented out
       // due to filename is CUT-OFF and if not commented out, error message: can't read  filename.
end;

I would appreciate help on why Edit1.Text string is incomplete, while the DBMemo1 box shows complete and correct filename, with drive, and all folders and subfolders in the path.

Thanks!
« Last Edit: July 03, 2012, 09:40:43 pm by Elmug »

Knipfty

  • Full Member
  • ***
  • Posts: 232
Re: [SOLVED] To drop into DBMemo, filename is chopped (incomplete)
« Reply #1 on: July 17, 2012, 05:03:16 pm »
Can you show us the string before and after?

You may be hitting a size limit, like 255.
64-bit Lazarus 2.2.0 FPC 3.2.2, 64-bit Win 11

Elmug

  • Hero Member
  • *****
  • Posts: 849
Re: [SOLVED] To drop into DBMemo, filename is chopped (incomplete)
« Reply #2 on: July 25, 2012, 10:37:52 am »
Can you show us the string before and after?

You may be hitting a size limit, like 255.

Hi Knipfty,

Thanks for replying.

I came back to this older thread to say that  I found out since that when fileName(s) are dropped in Memo box, the built in methods try to guess some sort of formatting (probably since there are no ends of line), since what is dropped may be long chunks of text. I was just dropping one filename, though, and this happens.

Well in this case, dropping filenames, complete with path, the "chopping" is not actually a chopping but a "formatting" that makes more than one line out of what I expected to be ONE single complet line.

On the fact that a Memo is an array of lines, I was fetching index [zero] and thus getting an incomplete path\filename.

So I had to use some code to resolve it.
« Last Edit: July 25, 2012, 10:42:59 am by Elmug »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: [SOLVED] To drop into DBMemo, filename is chopped (incomplete)
« Reply #3 on: July 25, 2012, 01:15:29 pm »
What platform is this? On Windows, there could be a limitation of file path size, defined by MAX_PATH constant.

Elmug

  • Hero Member
  • *****
  • Posts: 849
Re: [SOLVED] To drop into DBMemo, filename is chopped (incomplete)
« Reply #4 on: July 26, 2012, 03:48:54 am »
What platform is this? On Windows, there could be a limitation of file path size, defined by MAX_PATH constant.

Hi Leledumbo,

The platform is Windows 7, 32 bit Lazarus.

Since I verified the problem using rather short path names, in thinking the longpath\name could be the problem, or spaces in between filenames, and still the issue manifested, and since I did read somewhere documentation on the fact that formatting of what's dropped is tried to be "guessed" (?), I concluded that the problem was in THAT (in that formatting), and not on the length of the path.

Also, the total Path\FileName WAS available in the Memo field, and that allowed resolving with basic string functions, rather than what would have been simpler, i.e., get from the memo the first line using array [index=zero].

Thanks for the suggestion.

P.S. On really short and simple path names where no formatting seemed to occur, the array/index way was OK, but not when the path-name wa just a little longer.
« Last Edit: July 26, 2012, 03:53:45 am by Elmug »

 

TinyPortal © 2005-2018