Found strange code snippet in sample

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

ebbiTeam
User
Posts: 17
Joined: Fri May 27, 2011 7:20 am

Found strange code snippet in sample

Post by ebbiTeam »

Hello,

I'm using your sample applications as a base for our own implementation right now.
Along the way I have found some useless lines:

Dim bCheckChanged As Boolean = bFromVDataOut ^ e.Item.Checked
If bCheckChanged Then

If e.Item.Checked Then
vDataIn = 1
Else
vDataIn = 0
End If
Try
AxCoPDFXCview1.SetProperty(sVerb, vDataIn)
Catch ex As Exception
ShowErrorMessage(System.Runtime.InteropServices.Marshal.GetHRForException(ex))
End Try
End If

Obvisiously the marked query doesn't make any sense. It's always true and furthermore the syntax is a bit circular.
I'm wondering now how this lines end up in this sample? Did you use some kind of converter which build this up?

Thanks and regards
Tobias Herold
EbbinghausTeam
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19885
Joined: Mon Jan 12, 2009 8:07 am

Re: Found strange code snippet in sample

Post by Stefan - PDF-XChange »

Thanks Tobias,

I have asked one of the guys working on the code samples to check this and we will advise later on how the investigation on this is going.

Best,
Stefan
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: Found strange code snippet in sample

Post by Corwin - Tracker Sup »

Hello Tobias,
ebbiTeam wrote: Dim bCheckChanged As Boolean = bFromVDataOut ^ e.Item.Checked
If bCheckChanged Then
Actually this code filters unnecessary call to ActiveX SetProperty function. It will work only when old value of property is unequal to the new value from checkbox. However all indeed will work fine without this code.
ebbiTeam
User
Posts: 17
Joined: Fri May 27, 2011 7:20 am

Re: Found strange code snippet in sample

Post by ebbiTeam »

Yes, I see.
Though in every case bCheckChanged will have
a "true" value. It doesn't matter if one of both
variables on the right side have a "false" value.
Is this a .net behaviour?
Corwin - Tracker Sup wrote:Hello Tobias,
ebbiTeam wrote: Dim bCheckChanged As Boolean = bFromVDataOut ^ e.Item.Checked
If bCheckChanged Then
Actually this code filters unnecessary call to ActiveX SetProperty function. It will work only when old value of property is unequal to the new value from checkbox. However all indeed will work fine without this code.
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: Found strange code snippet in sample

Post by Corwin - Tracker Sup »

ebbiTeam wrote:Yes, I see.
Though in every case bCheckChanged will have
a "true" value. It doesn't matter if one of both
variables on the right side have a "false" value.
Is this a .net behaviour?
You are right. That was bad code conversion form C#. In VB.Net environment should be used "xor" operator:

Code: Select all

Dim bCheckChanged As Boolean = bFromVDataOut Xor e.Item.Checked
Thanks for the report. We will fix this issue.