#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2007
    Posts
    169
    Rep Power
    37

    Copy clipboard to memo field


    I have a memo field on my form. I copy lets say 5 records with 5 culums. Firstly i right click on the memo field then click on past.I get what i want but now i see my 5 colums with spaces in between them.I cannot loop through the memo and look for spaces as the fields in it self may have spaces. i want to validate each column and then put it in my database.

    how can i achieve this? Then is there a way with a click of a button to put what i have in the clipboard into the memo field?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2006
    Location
    Carlsbad, CA
    Posts
    2,054
    Rep Power
    383
    Seems to me that you need to look at the application from which you are copying the records
    and see if it offers any options for specifying the field separators, so that you can set it to something that will
    not be contained within your field data.

    See if you have an option to replace the <SPACE> character with ~ or |

    Alternatively, does it offer a fixed field length option so that you can count characters then trim
    leading/trailing spaces as appropriate?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    151
    Rep Power
    2
    Originally Posted by icuras
    I have a memo field on my form. I copy lets say 5 records with 5 culums. Firstly i right click on the memo field then click on past.I get what i want but now i see my 5 colums with spaces in between them.I cannot loop through the memo and look for spaces as the fields in it self may have spaces. i want to validate each column and then put it in my database.

    how can i achieve this? Then is there a way with a click of a button to put what i have in the clipboard into the memo field?
    Simple. When you detect a paste operation, retrieve the text content of Clipboard object to a temporary container (can be a simple string variable or a TStrings instance), do your processing (e.g. removing unneeded spaces), then insert the result to your memo field.

    To reliably intercept the pasting operation, you must handle WM_PASTE message in your memo control. So either you subclass your memo control, or create a child class from it where you could handle WM_PASTE.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2006
    Location
    Carlsbad, CA
    Posts
    2,054
    Rep Power
    383
    Simple. When you detect a paste operation, retrieve the text content of Clipboard object to a temporary container (can be a simple string variable or a TStrings instance), do your processing (e.g. removing unneeded spaces), then insert the result to your memo field.
    I may be wrong; but I think you are missing the problem.

    As I read the question, the issue is not how to paste, it is how to differentiate between spaces that represent
    column separators and spaces that are part of a column's content.

    Perhaps Icuras will confirm if he/she has not already found a solution.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    151
    Rep Power
    2
    Originally Posted by clivew
    I may be wrong; but I think you are missing the problem.

    As I read the question, the issue is not how to paste, it is how to differentiate between spaces that represent
    column separators and spaces that are part of a column's content.

    Perhaps Icuras will confirm if he/she has not already found a solution.
    Yes, you are wrong. I am not missing the problem.

    What the OP wants is how to remove unneeded spaces from the pasted value since he/she can't do that in the memo control. Let me quote the part that says so.

    I cannot loop through the memo and look for spaces as the fields in it self may have spaces. i want to validate each column and then put it in my database.
    So the solution is simple. If you can't process the clipboard content after it is pasted in the memo, then you process the clipboard content before you paste to the memo. Simple logic, right?
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2006
    Location
    Carlsbad, CA
    Posts
    2,054
    Rep Power
    383
    Yes, you are wrong. I am not missing the problem.
    While I admire your self confidence I do not share your interpretation.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    151
    Rep Power
    2
    @Clive

    Thanks, but I don't care about your interpretation.

IMN logo majestic logo threadwatch logo seochat tools logo