01-26-2009 02:56 PM
Hi,
I see this variable "NETFX2_0" used in some of the example projects iwth MS2005?
What is it?
Just wondering!
Curt
01-27-2009 09:34 AM
Hi Curt,
What were a couple of the examples you fould the variable in?
01-27-2009 09:45 AM
Hi Corbin,
Project 'PlotWaveforms.2005' for example.
Here's a snippet of code
#If NETFX2_0 Then
Private Function GenerateAnalogWaveform() As AnalogWaveform(Of Double)#Else
Private Function GenerateAnalogWaveform() As AnalogWaveform#End If
Dim freq As Integer = 2
Dim amplitude As Integer = 30
Dim data() As Double = New Double((SampleCount) - 1) {}Dim i As Integer = 0
For i = 0 To (data.Length - 1)data(i) = (amplitude * Math.Sin((2 * i * Math.PI * freq) / SampleCount))
Next i
#If NETFX2_0 Then
Dim waveform As AnalogWaveform(Of Double) = AnalogWaveform(Of Double).FromArray1D(data)#Else
Dim waveform As AnalogWaveform = AnalogWaveform.FromArray1D(data)#End If
I poked around in the project properties page and found the variable listed in Compile\Advanced Compile Options
as a trace variable.
Curt
01-27-2009 10:23 AM - edited 01-27-2009 10:27 AM
01-27-2009 10:32 AM
Something else I forgot to add is that using a conditional compilation symbol is how we modularize our examples to take advantage of generics and other features in the .NET 2.0 framework that are not supported in the 1.1 version.
01-19-2012 03:30 PM
Hi,
I am also trying to understand the conditional compilation code. I am looking at the Visual Basic example "AcqVoltageSamples_ExtClk," and I see the same block of conditional compilation code.
This is probably more of a Visual Basic question, but how does the compiler "know" which branch to take when it comes to the conditional compilation block? I see that the constants NETFX2_0 and NETFX3_5 are defined in the advanced compiler settings for the project (under project properties). If I understand correctly what I've read in Microsoft's documentation, these are Boolean constants, and to define as true they are set to be set to -1. So, does that mean if I am targeting the .NET 3.5 framework, I would put -1 next to the NETFX3_5 (i.e. NETFX3_5 = -1) in the custom constants text box in the advanced compiler options menu?
Thanks for your help.
Jason
01-19-2012 06:23 PM
echemist,
These constants just need to be defined to be true. So if they exist in the Custom constants field, then they are defined and thus that code will be included during compilation. You do not need to set them to any value. You can see that if you remove one from the Custom constatns list, the code in those blocks will be grayed out. You can also look at our examples for other versions of .NET and see that the list will only include the current version and those prior. So the .NET 2.0 example only defines NETFX2_0.
01-20-2012 11:12 AM
Thanks for your help. I wasn't able to get the code to grey out by removing the constants, but that is probably a problem with my Visual Basic IDE (Visual Basic 2008 express). I posted to the MSDN forum to find out if maybe there is an incorrect setting or something else that I need to change in the Visual Basic IDE.