Receiving text from the windows clipboard with C/AL

Steeve_globetrotterSteeve_globetrotter Member Posts: 46
Hi everybody,

Sorry but in fact I have a little problem with the clipboard OCX that I donwnloaded here : http://www.mibuso.com/dlinfo.asp?FileID=149

We can use this like : t = Clipboard.TextFromClipboard;

In fact, we have to take care concerning the length of t because Navision does not allow strings largers than 250 chars. Ok...So...I have the problem and I would like a solution please because if t is larger than 250 chars I have always an error message...

Do you have other solutions like :

Count_Char := STRLEN(Clipboard.TextFromClipboard); --> Apparently, this doesn't work with the OCX directly... :-(

IF (Count_Char < 250) THEN BEGIN blablabla END

Thanks a lot for your help and I hope I will have answer about this because the deadline of the project is not far away...:-)

Comments

  • Timo_LässerTimo_Lässer Member Posts: 481
    YourTextVar := COPYSTR(Clipboard.TextFromClipboard,1,MAXSTRLEN(YourTextVar);
    
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • Steeve_globetrotterSteeve_globetrotter Member Posts: 46
    YourTextVar := COPYSTR(Clipboard.TextFromClipboard,1,MAXSTRLEN(YourTextVar);
    

    Thanks a lot Timo for your answer...

    But it doesn't work...

    This is what I have:

    Variables:
    String_GED - Text 250
    GED_Entete - Text - 50
    String_GED := COPYSTR(Clipboard.TextFromClipboard, 1, MAXSTRLEN(String_GED));

    GED_Entete := SELECTSTR(1, String_GED);

    IF (GED_Entete = '#*_*#GED#*_*#') THEN
    BEGIN
    Start := DIALOG.CONFIRM(GED detected, do you want to import it ?');
    END

    Try it and you will see...pffffff, I would like to resolve it...HELPPPPPPP...lol

    Thanks again
  • ajhvdbajhvdb Member Posts: 672
  • EugeneEugene Member Posts: 309
    probably the line of code SELECTSTR(1, String_GED); fails because there are no commas in the String_GED or the STRPOS of the first comma >50
  • rvduurenrvduuren Member Posts: 92
    Hello,

    I think this OCX is very limited usable in NAV, no offense of cource :)

    I've did some c# coding:
    using System;
    using System.Windows.Forms;
    namespace ConsoleClipB
    {
        class Program
        {
            [STAThread]
            static void Main(string[] args)
            {
                if (Clipboard.GetDataObject() != null)
                {
                    if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text))
                    {                    
                        Console.WriteLine("{0}", Clipboard.GetDataObject().GetData(DataFormats.Text).ToString());
                    }
                    else
                        Console.WriteLine("The clipboad does not contain any text");
                    Console.ReadLine();
                }
            }
        }
    }
    

    Combine this code in : How to create a Navision dll/ocx in Visual Studio 2005 .NET AND maby Access Navision Stream From DotNet ..and you're done..

    You can access the clipboard form a stream or text file..
    Met vriendelijke groet, best regards,

    Rvduuren
Sign In or Register to comment.