Compare string

Hello (edited this post since its just sitting here)

I need to compare content from clipboard.

In my program when a trade is opened there are only 2 names in this room, mine and an unknown.

I will click in an area to send name to clipboard. I want to comapare this name to the name of mine.
If it IS mine then click the second name and send to clipboard.
If it is NOT mine then goto another part of code.

How can I compare the name in clipboard to see if it is mine or not??

Thank you.

Comments

  • : Figured it out sorry
    You can delete and edit your own posts.
  • : : Figured it out sorry
    : You can delete and edit your own posts.
    edit yes, no option to delete.
  • : Hello (edited this post since its just sitting here)
    :
    : I need to compare content from clipboard.
    :
    : In my program when a trade is opened there are only 2 names in this
    : room, mine and an unknown.
    :
    : I will click in an area to send name to clipboard. I want to
    : comapare this name to the name of mine.
    : If it IS mine then click the second name and send to clipboard.
    : If it is NOT mine then goto another part of code.
    :
    : How can I compare the name in clipboard to see if it is mine or not??
    :
    : Thank you.
    changed post from delete me to usable post. thank you
  • : : Hello (edited this post since its just sitting here)
    : :
    : : I need to compare content from clipboard.
    : :
    : : In my program when a trade is opened there are only 2 names in this
    : : room, mine and an unknown.
    : :
    : : I will click in an area to send name to clipboard. I want to
    : : comapare this name to the name of mine.
    : : If it IS mine then click the second name and send to clipboard.
    : : If it is NOT mine then goto another part of code.
    : :
    : : How can I compare the name in clipboard to see if it is mine or not??
    : :
    : : Thank you.
    : changed post from delete me to usable post. thank you
    :
    Anyone, this is bugging the hell out of me :(
  • : : : Hello (edited this post since its just sitting here)
    : : :
    : : : I need to compare content from clipboard.
    : : :
    : : : In my program when a trade is opened there are only 2 names in this
    : : : room, mine and an unknown.
    : : :
    : : : I will click in an area to send name to clipboard. I want to
    : : : comapare this name to the name of mine.
    : : : If it IS mine then click the second name and send to clipboard.
    : : : If it is NOT mine then goto another part of code.
    : : :
    : : : How can I compare the name in clipboard to see if it is mine or not??
    : : :
    : : : Thank you.
    : : changed post from delete me to usable post. thank you
    : :
    : Anyone, this is bugging the hell out of me :(
    :
    With the TClipboard object you can get the string from the clipboard. Then you can use whichever method you like to compare those two strings.
  • : With the TClipboard object you can get the string from the
    : clipboard. Then you can use whichever method you like to compare
    : those two strings.

    Thank you, however I am using Turbo Delphi 2006 and I do not have a TClipboard in my tool palette.

    my code now:
    [code]procedure Tcontrol_panel.Trade();
    begin
    TimerTrd.Enabled:=False;
    inifile:=Tinifile.Create('./OH_BOT.ini');
    accountname:=inifile.ReadString('UserInfo','Accountname','');
    trdmessage:=inifile.ReadString('Messages','Welcome','');
    trdtime:=inifile.ReadString('Trade','MaxTime','');
    AU3_MousEClick ('left', 835,645,1,5);
    AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    tradename:=Clipboard.Astext;
    if tradename<>accountname then
    begin
    AU3_MouseClick ('left',297,711,1,5);
    AU3_Send ('Welcome {CTRLDOWN}v{CTRLUP} ' + ' you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    end
    else if tradename=accountname then
    begin
    AU3_MousEClick ('left', 835,660,1,5);
    AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    AU3_MouseClick ('left',297,711,1,5);
    AU3_Send ('Welcome {CTRLDOWN}v{CTRLUP} ' + ' you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    end;
    end;[/code]
    however with this code it is selecting first name and going to next step, it is not comparing them to see if it IS the name in ini file or not.
  • : : With the TClipboard object you can get the string from the
    : : clipboard. Then you can use whichever method you like to compare
    : : those two strings.
    :
    : Thank you, however I am using Turbo Delphi 2006 and I do not have a
    : TClipboard in my tool palette.
    :
    : my code now:
    : [code]: procedure Tcontrol_panel.Trade();
    : begin
    : TimerTrd.Enabled:=False;
    : inifile:=Tinifile.Create('./OH_BOT.ini');
    : accountname:=inifile.ReadString('UserInfo','Accountname','');
    : trdmessage:=inifile.ReadString('Messages','Welcome','');
    : trdtime:=inifile.ReadString('Trade','MaxTime','');
    : AU3_MousEClick ('left', 835,645,1,5);
    : AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    : tradename:=Clipboard.Astext;
    : if tradename<>accountname then
    : begin
    : AU3_MouseClick ('left',297,711,1,5);
    : AU3_Send ('Welcome {CTRLDOWN}v{CTRLUP} ' + ' you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    : end
    : else [red]if tradename=accountname then[/red]
    : begin
    : AU3_MousEClick ('left', 835,660,1,5);
    : AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    : AU3_MouseClick ('left',297,711,1,5);
    : AU3_Send ('Welcome {CTRLDOWN}v{CTRLUP} ' + ' you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    : end;
    : end;[/code]:
    : however with this code it is selecting first name and going to next
    : step, it is not comparing them to see if it IS the name in ini file
    : or not.

    The red part is not necessary because the else already takes care of that. The TClipboard is not a component but an object (see help files for more info on the difference). I see you already use the TClipboard object, since you're using the Clipboard() function.
    You might want to check the value of tradename and accountname by either using the debugger, or placing a MessageDialog() just before the if-then statement.
    Also remember that the <>-operator and =-operator will check string case sensitive, thus "Hello world!" is not equal to "hello world!". If you want to compare them without case sensitivity, use the CompareText() function instead.
  • : The red part is not necessary because the else already takes care of
    : that. The TClipboard is not a component but an object (see help
    : files for more info on the difference). I see you already use the
    : TClipboard object, since you're using the Clipboard() function.
    : You might want to check the value of tradename and accountname by
    : either using the debugger, or placing a MessageDialog() just before
    : the if-then statement.
    : Also remember that the <>-operator and =-operator will check string
    : case sensitive, thus "Hello world!" is not equal to "hello world!".
    : If you want to compare them without case sensitivity, use the
    : CompareText() function instead.

    I removed what you selected as red.
    It still selects the first name which is the bot name. it selects it and send the message.
    ie:
    bot name= captain
    trader name= casper
    the names are placed in the box alphabetically therefore placing captain as the first name.
    [code]procedure Tcontrol_panel.Trade();
    begin
    TimerTrd.Enabled:=False;
    inifile:=Tinifile.Create('./OH_BOT.ini');
    accountname:=inifile.ReadString('UserInfo','Accountname','');
    trdmessage:=inifile.ReadString('Messages','Welcome','');
    trdtime:=inifile.ReadString('Trade','MaxTime','');
    AU3_MousEClick ('left', 835,645,1,5);
    AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    tradename:=Clipboard.Astext;
    if tradename<>accountname then
    begin
    AU3_MouseClick ('left',297,711,1,5);
    AU3_Send ('Welcome {CTRLDOWN}v{CTRLUP} ' + ' you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    end
    else
    begin
    AU3_MousEClick ('left', 835,660,1,5);
    AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    AU3_MouseClick ('left',297,711,1,5);
    AU3_Send ('Welcome {CTRLDOWN}v{CTRLUP} ' + ' you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    end;
    end;
    [/code]
  • : : The red part is not necessary because the else already takes care of
    : : that. The TClipboard is not a component but an object (see help
    : : files for more info on the difference). I see you already use the
    : : TClipboard object, since you're using the Clipboard() function.
    : : You might want to check the value of tradename and accountname by
    : : either using the debugger, or placing a MessageDialog() just before
    : : the if-then statement.
    : : Also remember that the <>-operator and =-operator will check string
    : : case sensitive, thus "Hello world!" is not equal to "hello world!".
    : : If you want to compare them without case sensitivity, use the
    : : CompareText() function instead.
    :
    : I removed what you selected as red.
    : It still selects the first name which is the bot name. it selects it
    : and send the message.
    : ie:
    : bot name= captain
    : trader name= casper
    : the names are placed in the box alphabetically therefore placing
    : captain as the first name.
    : [code]: procedure Tcontrol_panel.Trade();
    : begin
    : TimerTrd.Enabled:=False;
    : inifile:=Tinifile.Create('./OH_BOT.ini');
    : accountname:=inifile.ReadString('UserInfo','Accountname','');
    : trdmessage:=inifile.ReadString('Messages','Welcome','');
    : trdtime:=inifile.ReadString('Trade','MaxTime','');
    : AU3_MousEClick ('left', 835,645,1,5);
    : AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    : tradename:=Clipboard.Astext;
    : if tradename<>accountname then
    : begin
    : AU3_MouseClick ('left',297,711,1,5);
    : AU3_Send ('Welcome {CTRLDOWN}v{CTRLUP} ' + ' you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    : end
    : else
    : begin
    : AU3_MousEClick ('left', 835,660,1,5);
    : AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    : AU3_MouseClick ('left',297,711,1,5);
    : AU3_Send ('Welcome {CTRLDOWN}v{CTRLUP} ' + ' you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    : end;
    : end;
    : [/code]:
    :
    If the accountname is the bot name, then the then-part of the if-then-else is executed. What exactly are you trying to do?
  • I got IT... Thank you for pointing me in the right direction:

    [code]begin
    TimerTrd.Enabled:=False;
    inifile:=Tinifile.Create('./OH_BOT.ini');
    trdmessage:=inifile.ReadString('Messages','Welcome','');
    trdtime:=inifile.ReadString('Trade','MaxTime','');
    AU3_MousEClick ('left', 835,645,1,5);
    AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    tradename:=Clipboard.Astext;
    accountname:=inifile.ReadString('UserInfo','Accountname','');
    [color=Red]result:=AnsiCompareText(accountname,tradename);[/color]
    if result=-1 then [color=Red]{this number MUST be -1 I thought it would be 0}[/color]
    begin
    AU3_MousEClick ('left', 835,660,1,5);
    AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    AU3_MouseClick ('left',297,711,1,5);
    AU3_Send ('Welcome {CTRLDOWN}v{CTRLUP} ' + ' you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    end
    else if result<>0 then
    begin
    AU3_MouseClick ('left',297,711,1,5);
    AU3_Send ('Welcome {CTRLDOWN}v{CTRLUP} ' + ' you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    end;[/code]
  • : : If the accountname is the bot name, then the then-part of the
    : : if-then-else is executed. What exactly are you trying to do?
    :
    : well the first name IS the bot name and it is going to the else and
    : NOT the then part of this line.
    :
    :[red] If accountname=tradename it should do the then which is select the
    : 2nd name, save it to clipboard and post msg.[/red]
    :
    : but it is not doing it, it is skipping the = and going to else.
    :
    : I am trying to compare the 2 names in the window.
    : 1 is a known name (the bot name from the ini file)
    : 2 is unknown name (any other person who enters trade)..only one
    : person can trade with me at a time.
    :
    : if the first name is bot name then select 2nd name and send msg.
    : if first name is NOT the bot name then just send msg.
    :
    :
    I see 2 string variables: accountname and tradename. Since accountname is the first name variable in the code and read from the inifile, I assume that's the bot name. Tradename is therefor the unknown name. If I'm incorrect please use unambiguous terms and make sure that your variable identifiers reflect those terms. It makes it much easier to communicate your intentions to other programmers.
    Since the if-then test for an inequality (<>-operator) the else part means that the accountname is the same as the tradename. Thus the code is doing what you describe in the read part.
    Here's your code, but then written a bit easier to understand:
    [code]
    procedure Tcontrol_panel.Trade();
    begin
    TimerTrd.Enabled := False;
    inifile := Tinifile.Create('./OH_BOT.ini');
    BotName := inifile.ReadString('UserInfo','Accountname','');
    trdmessage := inifile.ReadString('Messages','Welcome','');
    trdtime : =inifile.ReadString('Trade','MaxTime','');
    AU3_MousEClick ('left', 835,645,1,5);
    AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    tradename := Clipboard.Astext;
    if tradename = BotName then
    begin
    AU3_MouseClick ('left', 835,660,1,5);
    AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    tradename := Clipboard.Astext;
    end;
    AU3_MouseClick ('left',297,711,1,5);
    AU3_Send ('Welcome '+tradename+' you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    end;
    end;
    [/code]
    I removed the {CTRLDOWN}v{CTRLUP} because tradename is the clipboard value, and because the clipboard contents might change during the execution of this code.
    I've also changed the inequality into an equality check because multiple negatives can be confusing.
    If you want to copy the unknown name if the tradename is not equal to the BotName, you can simply change the equality back to an inequality.
    I've also moved the message-send code from the if-then statement to avoid code duplication.
  • : I see 2 string variables: accountname and tradename. Since
    : accountname is the first name variable in the code and read from the
    : inifile, I assume that's the bot name. Tradename is therefor the
    : unknown name. If I'm incorrect please use unambiguous terms and make
    : sure that your variable identifiers reflect those terms. It makes it
    : much easier to communicate your intentions to other programmers.
    : Since the if-then test for an inequality (<>-operator) the else part
    : means that the accountname is the same as the tradename. Thus the
    : code is doing what you describe in the read part.
    : Here's your code, but then written a bit easier to understand:
    : [code]:
    : procedure Tcontrol_panel.Trade();
    : begin
    : TimerTrd.Enabled := False;
    : inifile := Tinifile.Create('./OH_BOT.ini');
    : BotName := inifile.ReadString('UserInfo','Accountname','');
    : trdmessage := inifile.ReadString('Messages','Welcome','');
    : trdtime : =inifile.ReadString('Trade','MaxTime','');
    : AU3_MousEClick ('left', 835,645,1,5);
    : AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    : tradename := Clipboard.Astext;
    : if tradename = BotName then
    : begin
    : AU3_MouseClick ('left', 835,660,1,5);
    : AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    : tradename := Clipboard.Astext;
    : end;
    : AU3_MouseClick ('left',297,711,1,5);
    : AU3_Send ('Welcome '+tradename+' you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    : end;
    : end;
    : [/code]:
    : I removed the {CTRLDOWN}v{CTRLUP} because tradename is the clipboard
    : value, and because the clipboard contents might change during the
    : execution of this code.
    : I've also changed the inequality into an equality check because
    : multiple negatives can be confusing.
    : If you want to copy the unknown name if the tradename is not equal
    : to the BotName, you can simply change the equality back to an
    : inequality.
    : I've also moved the message-send code from the if-then statement to
    : avoid code duplication.

    Hello, I tried to use your code but it is still only selecting the first choice and not comparing them.
    I am now using this code:
    [code]procedure Tcontrol_panel.Trade();
    begin
    TimerFindTrd.Enabled:=False;
    inifile:=Tinifile.Create('./OH_BOT.ini');
    trdtime:=inifile.ReadString('Trade','TradeTime','');
    trdmessage:=inifile.ReadString('Messages','Welcome','');
    repeat AU3_MousEClick ('left', 1009,658,1,5);
    coord:=AU3_pixelgetcolor (1009,658);
    sleep (1000);
    until
    (coord=8224125);
    sleep (1000);
    AU3_MousEClick ('left', 835,645,1,5);
    AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    Sleep (500);
    tradename:=Clipboard.Astext;
    accountname:=inifile.ReadString('UserInfo','Accountname','');
    result:=AnsiCompareText(accountname,tradename);
    if result=-1 then
    begin
    AU3_MousEClick ('left', 835,660,1,5);
    AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    AU3_MouseClick ('left',297,711,1,5);
    AU3_Send ('Welcome {CTRLDOWN}v{CTRLUP} ' + ' to MTGO Trade Bot you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    welcome:=inifile.ReadString('Messages','Welcome','');
    AU3_ClipPut (welcome);
    Au3_Send ('{CTRLDOWN}v{CTRLUP}'+ '{ENTER}',0);
    Sleep (1000);
    end
    else
    begin
    AU3_MouseClick ('left',297,711,1,5);
    AU3_Send ('Welcome {CTRLDOWN}v{CTRLUP} ' + ' to MTGO Trade Bot you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    welcome:=inifile.ReadString('Messages','Welcome','');
    AU3_ClipPut (welcome);
    Au3_Send ('{CTRLDOWN}v{CTRLUP}'+ '{ENTER}',0);
    Sleep (1000);
    end;
    //trade timer 10 min, 15 min, 20 min, and 30 min timers
    InTrd();
    //add new procedure for trades to moniter give and take area
    end;[/code]
    it works perfect going into a trade, HOWEVER:
    When I exit the trade and then re-enter a trade I get the foolowing error:
    [code]---------------------------
    Debugger Exception Notification
    ---------------------------
    Project MTGOTradeBot.exe raised exception class Exception with message 'Cannot open clipboard'.
    ---------------------------
    Break Continue Help
    ---------------------------
    [/code]
  • : : I see 2 string variables: accountname and tradename. Since
    : : accountname is the first name variable in the code and read from the
    : : inifile, I assume that's the bot name. Tradename is therefor the
    : : unknown name. If I'm incorrect please use unambiguous terms and make
    : : sure that your variable identifiers reflect those terms. It makes it
    : : much easier to communicate your intentions to other programmers.
    : : Since the if-then test for an inequality (<>-operator) the else part
    : : means that the accountname is the same as the tradename. Thus the
    : : code is doing what you describe in the read part.
    : : Here's your code, but then written a bit easier to understand:
    : : [code]: :
    : : procedure Tcontrol_panel.Trade();
    : : begin
    : : TimerTrd.Enabled := False;
    : : inifile := Tinifile.Create('./OH_BOT.ini');
    : : BotName := inifile.ReadString('UserInfo','Accountname','');
    : : trdmessage := inifile.ReadString('Messages','Welcome','');
    : : trdtime : =inifile.ReadString('Trade','MaxTime','');
    : : AU3_MousEClick ('left', 835,645,1,5);
    : : AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    : : tradename := Clipboard.Astext;
    : : if tradename = BotName then
    : : begin
    : : AU3_MouseClick ('left', 835,660,1,5);
    : : AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    : : tradename := Clipboard.Astext;
    : : end;
    : : AU3_MouseClick ('left',297,711,1,5);
    : : AU3_Send ('Welcome '+tradename+' you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    : : end;
    : : end;
    : : [/code]: :
    : : I removed the {CTRLDOWN}v{CTRLUP} because tradename is the clipboard
    : : value, and because the clipboard contents might change during the
    : : execution of this code.
    : : I've also changed the inequality into an equality check because
    : : multiple negatives can be confusing.
    : : If you want to copy the unknown name if the tradename is not equal
    : : to the BotName, you can simply change the equality back to an
    : : inequality.
    : : I've also moved the message-send code from the if-then statement to
    : : avoid code duplication.
    :
    : Hello, I tried to use your code but it is still only selecting the
    : first choice and not comparing them.
    : I am now using this code:
    : [code]: procedure Tcontrol_panel.Trade();
    : begin
    : TimerFindTrd.Enabled:=False;
    : inifile:=Tinifile.Create('./OH_BOT.ini');
    : trdtime:=inifile.ReadString('Trade','TradeTime','');
    : trdmessage:=inifile.ReadString('Messages','Welcome','');
    : repeat AU3_MousEClick ('left', 1009,658,1,5);
    : coord:=AU3_pixelgetcolor (1009,658);
    : sleep (1000);
    : until
    : (coord=8224125);
    : sleep (1000);
    : AU3_MousEClick ('left', 835,645,1,5);
    : AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    : Sleep (500);
    : tradename:=Clipboard.Astext;
    : accountname:=inifile.ReadString('UserInfo','Accountname','');
    : result:=AnsiCompareText(accountname,tradename);
    : if result=-1 then
    : begin
    : AU3_MousEClick ('left', 835,660,1,5);
    : AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    : AU3_MouseClick ('left',297,711,1,5);
    : AU3_Send ('Welcome {CTRLDOWN}v{CTRLUP} ' + ' to MTGO Trade Bot you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    : welcome:=inifile.ReadString('Messages','Welcome','');
    : AU3_ClipPut (welcome);
    : Au3_Send ('{CTRLDOWN}v{CTRLUP}'+ '{ENTER}',0);
    : Sleep (1000);
    : end
    : else
    : begin
    : AU3_MouseClick ('left',297,711,1,5);
    : AU3_Send ('Welcome {CTRLDOWN}v{CTRLUP} ' + ' to MTGO Trade Bot you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    : welcome:=inifile.ReadString('Messages','Welcome','');
    : AU3_ClipPut (welcome);
    : Au3_Send ('{CTRLDOWN}v{CTRLUP}'+ '{ENTER}',0);
    : Sleep (1000);
    : end;
    : //trade timer 10 min, 15 min, 20 min, and 30 min timers
    : InTrd();
    : //add new procedure for trades to moniter give and take area
    : end;[/code]:
    : it works perfect going into a trade, HOWEVER:
    : When I exit the trade and then re-enter a trade I get the foolowing
    : error:
    : [code]: ---------------------------
    : Debugger Exception Notification
    : ---------------------------
    : Project MTGOTradeBot.exe raised exception class Exception with message 'Cannot open clipboard'.
    : ---------------------------
    : Break Continue Help
    : ---------------------------
    : [/code]:
    :
    The solution is to use the Clipboard function to fill a global variable with the clipboard object at the application startup. Then use that to interface with the clipboard. Appearently the Turbo Delphi doesn't implement the Clipboard function incorrectly.
  • : : it works perfect going into a trade, HOWEVER:
    : : When I exit the trade and then re-enter a trade I get the foolowing
    : : error:
    : : [code]: : ---------------------------
    : : Debugger Exception Notification
    : : ---------------------------
    : : Project MTGOTradeBot.exe raised exception class Exception with message 'Cannot open clipboard'.
    : : ---------------------------
    : : Break Continue Help
    : : ---------------------------
    : : [/code]: :
    : :
    : The solution is to use the Clipboard function to fill a global
    : variable with the clipboard object at the application startup. Then
    : use that to interface with the clipboard. Appearently the Turbo
    : Delphi doesn't implement the Clipboard function incorrectly.

    Could you explain this in a little more detail please Z?
    at form create I need to create a clipboard object?? would this be:
    ClipBoard.Open; ??
    do I need to add ClipBoard.Close; anywhere??
    OR
    ClipBoard.Clear;... or have I completly missed your point?
  • : : : it works perfect going into a trade, HOWEVER:
    : : : When I exit the trade and then re-enter a trade I get the foolowing
    : : : error:
    : : : [code]: : : ---------------------------
    : : : Debugger Exception Notification
    : : : ---------------------------
    : : : Project MTGOTradeBot.exe raised exception class Exception with message 'Cannot open clipboard'.
    : : : ---------------------------
    : : : Break Continue Help
    : : : ---------------------------
    : : : [/code]: : :
    : : :
    : : The solution is to use the Clipboard function to fill a global
    : : variable with the clipboard object at the application startup. Then
    : : use that to interface with the clipboard. Appearently the Turbo
    : : Delphi doesn't implement the Clipboard function incorrectly.
    :
    : Could you explain this in a little more detail please Z?
    : at form create I need to create a clipboard object?? would this be:
    : ClipBoard.Open; ??
    : do I need to add ClipBoard.Close; anywhere??
    : OR
    : ClipBoard.Clear;... or have I completly missed your point?
    :
    In Borland Delphi the Clipboard() function returns a TClipboard object. When I needed to use the clipboard a lot I did something like this:
    [code]
    unit MainWindow;

    interface

    type
    TMainForm = class;
    ...
    end;

    var
    MainForm: TMainForm;
    ClpBrd: TClipboard;

    implementation

    procedure TMainForm.FormCreate();
    begin
    ClpBrd := Clipboard();
    end;

    procedure TMainForm.Button1Click();
    begin
    ClpBrd.AsText := 'Hello World';
    end;

    procedure TMainForm.Button2Click();
    begin
    Memo1.Text := ClpBrd.AsText;
    end;
    [/code]
    This example shows how to make a global variable and use it. As you can see the ClipBoard() function is only called once.
    I've never needed to use the TClipboard.Open(), or TClipboard.Close(). In Borland Delphi the Clipboard() function makes 1 clipboard object the first time its called and returns it every other time.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories