AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

another clipboard all bug ? clipboardall failure byref
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
Joy2DWorld



Joined: 04 Dec 2006
Posts: 404
Location: Galil, Israel

PostPosted: Sun Oct 28, 2007 3:22 am    Post subject: another clipboard all bug ? clipboardall failure byref Reply with quote

Code:
loop 2 {
text = hello yes ??
clipboard := text
c := clipboardall
clipboard =
sleep 20
if a_index > 1
   clipboard := c
else
   fun1(c)
msgbox % clipboard
}
exitapp

fun1(byref  z ) {

;ie. when clipboard is set byref to cliboardall .... we get blank..
;same exact code... but if set directly... we get clipboardall...
;
;eh?


clipboard := z

}

_________________
Joyce Jamce
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 3943
Location: Pittsburgh

PostPosted: Sun Oct 28, 2007 7:30 am    Post subject: Reply with quote

Where is the bug? ClipBoardAll is not a normal variable, it is blank except when it is assigned to a variable or saved to disk. It is explained in the manual.
Back to top
View user's profile Send private message
Joy2DWorld



Joined: 04 Dec 2006
Posts: 404
Location: Galil, Israel

PostPosted: Sun Oct 28, 2007 9:45 am    Post subject: Reply with quote

@Lazlo,

C is set to clipboard All

right ?


Then will fill clipboardAll Via:

C directly
C via byref



then we check clipboard.


result should be same, no ?

it is not.


actually worked this up as a demo of the problem.

if you try to assign clipboard from clipboardall variable (ie. clipboard all saved to variable) via byref... it not work...

as this demo should demonstrate....


ps: hey, what happened ? you normally disect code with an eagle's eye....


here,
Code:
if a_index > 1
   clipboard := c
else
   fun1(c)


we take 2 passes to set clipboard with C contents...

once directly, once as byref.

RESULT IS NOT THE SAME.
_________________
Joyce Jamce
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 3943
Location: Pittsburgh

PostPosted: Sun Oct 28, 2007 4:21 pm    Post subject: Reply with quote

Code:
c := clipboardall
clipboard =
clipboard := c
In this example “c” contains binary info, which cannot be handled by AHK, except assigning it to the ClipBoard, or save it to a file. The first one is done here, so you get, what is expected.
Code:
c := clipboardall
clipboard =
fun1(c)
Here the variable “c” is used as a function parameter. This is not in the list of the supported operations. If you mean, it was helpful, I agree. It should be posted to the Wish List section.

It is another issue finding out what happens and why. I also would have expected your function call example to work. If a variable carries a flag telling that it was assigned from the clipboard, this flag was expected to be preserved when this variable is used as a ByRef parameter. It does not change the fact that the documentation explicitly says that only very specific operations are supported.
Back to top
View user's profile Send private message
Joy2DWorld



Joined: 04 Dec 2006
Posts: 404
Location: Galil, Israel

PostPosted: Sun Oct 28, 2007 4:43 pm    Post subject: Reply with quote

oh,


and this ??? :



Code:
fun1(byref  z ) {

;ie. when clipboard is set byref to cliboardall .... we get blank..
;same exact code... but if set directly... we get clipboardall...
;
;eh?

q := z
tooltip % strlen(q) " - " strlen(z)
clipboard := q

}

_________________
Joyce Jamce
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 3943
Location: Pittsburgh

PostPosted: Sun Oct 28, 2007 5:24 pm    Post subject: Reply with quote

You found a workaround:
Code:
fun1(byref  z) {
   q := z
   clipboard := q
}
Nice, but it relies on an undocumented feature. It does not make the original issue a bug. It is still a wish: could Byref parameters of saved ClipBoardAll data be made to work?
Back to top
View user's profile Send private message
Joy2DWorld



Joined: 04 Dec 2006
Posts: 404
Location: Galil, Israel

PostPosted: Sun Oct 28, 2007 5:53 pm    Post subject: Reply with quote

Laszlo wrote:
It does not make the original issue a bug. It is still a wish: could Byref parameters of saved ClipBoardAll data be made to work?


Likely you see something in the Doc that I have overlooked.

Quote:
the use of ByRef causes each parameter to become an alias for the variable passed in from the caller. In other words, the parameter and the caller's variable both refer to the same contents in memory. This allows the Swap function to alter the caller's variables by moving Left's contents into Right and vice versa.


and
Quote:
Variables to which ClipboardAll has been assigned are in binary format and thus will appear as gibberish when displayed with MsgBox or similar. Also, altering a binary variable (by means such as StringReplace) will revert it to a normal variable, resulting in the loss of its clipboard data. In v1.0.46+, binary variables may be passed to functions by value (formerly they only worked ByRef).



which seems 100% the opposite of what you're saying the doc says...



but again, likely i've missed something....
_________________
Joyce Jamce
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 3943
Location: Pittsburgh

PostPosted: Sun Oct 28, 2007 6:07 pm    Post subject: Reply with quote

Help wrote:
ClipboardAll...is most commonly used to save the clipboard's contents so that the script can temporarily use the clipboard for an operation...
ClipboardAll may also be saved to a file...

Notes
ClipboardAll is blank when used in ways other than those described above. In addition, ClipboardAll is not supported inside comma-separated expressions; that is, it should be assigned on a line by itself
The two supported operations are assignment and save to a file. Not using ClipbBoardAll (or its copies) as function parameter. The restriction that even an assignment is only allowed as a single instruction in a line hints that something could go wrong in function parameters.

But I agree, the documentation is not entirely clear.
Back to top
View user's profile Send private message
Joy2DWorld



Joined: 04 Dec 2006
Posts: 404
Location: Galil, Israel

PostPosted: Sun Oct 28, 2007 6:16 pm    Post subject: Reply with quote

well,

1. the 1st quote deals with the special ClipboardAll. We are within this rule, as we used the special var only as described: saving the contents to another vary.

2. Nothing in your listed quote mentions COPIES of CBA. (you've added that yourself... it seems.. ?)


3. The quote from doc in (humbly) my post above, is quite clear and explicit:
Quote:
Variables to which ClipboardAll has been assigned are in binary format and thus will appear as gibberish when displayed with MsgBox or similar. Also, altering a binary variable (by means such as StringReplace) will revert it to a normal variable, resulting in the loss of its clipboard data. In v1.0.46+, binary variables may be passed to functions by value (formerly they only worked ByRef).



it seems to say.. clear as day... Vars to which CBA is assigned are binary format vars... which "may be passed to functions by value (formerly they only worked ByRef"...


ie..


BUG.
_________________
Joyce Jamce
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 3943
Location: Pittsburgh

PostPosted: Sun Oct 28, 2007 6:29 pm    Post subject: Reply with quote

Binary variables may be passed to functions, but the information about them being ClipBoardAll copies may not be retained (nothing in the Help says it would have). AHK should check this, to prevent crashes, when something inappropriate is attempted to be assigned to the ClipBoard.

However, your workaround shows that this flag is actually retained (although not documented). Sometimes, AHK does not seem to check this flag, sometimes it does. It is not consistent, not nice, but still not a bug.
Back to top
View user's profile Send private message
Joy2DWorld



Joined: 04 Dec 2006
Posts: 404
Location: Galil, Israel

PostPosted: Sun Oct 28, 2007 7:27 pm    Post subject: Reply with quote

@Laszlo,

you're not up to form Shocked


Quote:
Variables to which ClipboardAll has been assigned are in binary format and thus will appear as gibberish when displayed with MsgBox or similar. Also, altering a binary variable (by means such as StringReplace) will revert it to a normal variable, resulting in the loss of its clipboard data. In v1.0.46+, binary variables may be passed to functions by value (formerly they only worked ByRef).


this is from the ClipboardAll doc. ie. it says explicit like, CBA assignments result in a binary format var.... *AND* that not only can those 'binary variables' "be passed to functions" byRef ... but... since ver 1.0.46, they can passed by value!

ie. what place does the helpful "binary variables may be passed to functions by value (formerly they only worked ByRef" have in the ClipboardAll documentation section, unless it applies to CBA ?!


i think you confused the limits on CBA as a special global var... (2 limited operations allowed) and the resulting VAR capture of the CBA.



for goodness sakes,



it's a bug...
_________________
Joyce Jamce
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 3943
Location: Pittsburgh

PostPosted: Sun Oct 28, 2007 7:33 pm    Post subject: Reply with quote

Laszlo wrote:
Binary variables may be passed to functions, but the information about them being ClipBoardAll copies may not be retained
It is an extra flag.
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2472
Location: Australia, Qld

PostPosted: Mon Oct 29, 2007 3:31 am    Post subject: Reply with quote

Var::AssignBinaryClip() seems to handle ByRef variables:
Code:
Var &source_var = (aSourceVar.mType == VAR_ALIAS) ? *aSourceVar.mAliasFor : aSourceVar;
source_var is then the var which the ByRef parameter is an alias for.

It does use source_var when assigning to a normal var:
Code:
memcpy(mContents, source_var.mContents, source_var.mLength + 1);
but then forgets about source_var and uses aSourceVar when assigning to ClipboardAll:
Code:
LPVOID next, binary_contents = aSourceVar.mContents;
LPVOID binary_contents_max = (char *)binary_contents + aSourceVar.mLength + 1;
Changing those two references from aSourceVar -> source_var fixes it. Cool
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 3943
Location: Pittsburgh

PostPosted: Mon Oct 29, 2007 3:59 am    Post subject: Reply with quote

Cool
Back to top
View user's profile Send private message
Joy2DWorld



Joined: 04 Dec 2006
Posts: 404
Location: Galil, Israel

PostPosted: Mon Oct 29, 2007 6:41 am    Post subject: Reply with quote

@lexikos, nice.



ps: notices something 'odd' when playing with debug, numget seems to destroy the clipboardall holding var.
_________________
Joyce Jamce
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group