<< Prev        Next >>

ID : 117

#Ifndef ... #Endif

Function

To determine whether the designated macro is not defined and select a source code to compile.

Syntax

#Ifndef macro name
	Code 1
#Elif Defined(macro name)
	Code 2
#Else
	Code 3
#Endif

Guaranteed entry

Macro name
Designate a macro name.
Code n
Designate a source code.

Description

To determine whether the designated macro is not defined and select a source code to compile.

If the macro name is not defined, code 1, but no code 2 and code 3, is compiled.

If the macro name is defined, the condition is judged and either of code 2 or code 3 is compiled.

The same as #If Not(Defined(macro name)) ...

Related Terms

Attention

-

Example

'!TITLE "Condition Compile"
' Judge whether a macro is not defined and add a value to aaa

#Define TEST 10

Sub Sample_IfndefEndif

  Dim aaa As Integer

  aaa = 10

' If a macro name TEST is not defined
#Ifndef TEST

  aaa = aaa + 10

  ' Display a value of aaa on the message output window
  PrintDbg "aaa = " & aaa

' If a macro name TEST2 is defined
#Elif defined( TEST2 )

  aaa = aaa + 20

  ' Display a value of aaa on the message output window
  PrintDbg "aaa = " & aaa

' If both of a macro name TEST1 and TEST2 are not defined
#Else

  aaa = aaa + 30

  ' Display a value of aaa on the message output window
  PrintDbg "aaa = " & aaa

#Endif

End Sub

ID : 117

<< Prev        Next >>