×
Euphoria教程Euphoria教程首页Euphoria 算术运算符Euphoria关系运算符Euphoria介绍Euphoria环境设置(安装)Euphoria基本语法Euphoria变量Euphoria常量Euphoria数据类型Euphoria运算符Euphoria逻辑运算符Euphoria 赋值运算符Euphoria分支语句Euphoria if...elsif...else...endif 语句Euphoria Switch语句ifdef...elsifdef...elsedef...endifdef 语句Euphoria 循环类型Euphoria while循环Euphoria loop until 语法Euphoria for循环Euphoria流程控制Euphoria短路计算Euphoria序列Euphoria日期/时间Euphoria 过程Euphoria 函数Euphoria 文件I/O

ifdef...elsifdef...elsedef...endifdef 语句


ifdef 语句:

ifdef 语句执行在分析时不运行。这可以让你改变了你的程序运行在一个非常有效的方式。

ifdef语句在分析时,运行时的值不能被选中,而不是特殊的定义可以设置或取消设置以及在分析时。

语法:

 ifdef 语句的语法是:

ifdef macro then
   -- Statements will execute if the macro is defined.
end if

if 布尔表达式的值为true,那么里面的代码块,如果语句会被执行。如果没有ifdef 语句结束后第一套代码将被执行。 

ifdef 检查用定义关键字定义的宏。像WIN32_CONSOLE,WIN32或LINUX的宏定义有很多,你可以定义自己的宏如:

with define    MY_WORD    -- defines

你可以未定义已定义的词如下:

without define OTHER_WORD -- undefines

例子:

#!/home/euphoria-4.0b2/bin/eui

with define DEBUG

integer a = 10
integer b = 20

ifdef DEBUG then
   puts(1, "Hello, I am a debug message onen")
end ifdef

if (a + b) < 40 then
   printf(1, "%sn", {"This is true if statement!"})
end if

if (a + b) > 40 then
   printf(1, "%sn", {"This is not true if statement!"})
end if

这将产生以下结果:

Hello, I am a debug message one
This is true if statement!

ifdef...elsedef 语句:

如果宏定义,否则可以采取其他操作的情况下给宏没有定义,可以把一个动作。

语法:

 ifdef...elsedef 语法如下:

ifdef macro then
   -- Statements will execute if the macro is defined.
elsedef
   -- Statements will execute if the macro is not defined.
end if

例子:

#!/home/euphoria-4.0b2/bin/eui

ifdef WIN32 then
   puts(1, "This is windows 32 platformn")
elsedef
   puts(1, "This is not windows 32 platformn")
end ifdef

当在我的Linux机器上运行此程序,它会产生以下结果:

This is not windows 32 platform

ifdef...elsifdef 语句:

您可以选中多个宏使用 ifdef...elsifdef 语句。

语法:

 ifdef...elsifdef 语句的语法是:

ifdef macro1 then
   -- Statements will execute if the macro1 is defined.
elsifdef macro2 then
   -- Statements will execute if the macro2 is defined.
elsifdef macro3 then
   -- Statements will execute if the macro3 is defined.
.......................
elsedef
   -- Statements will execute if the macro is not defined.
end if

示例:

#!/home/euphoria-4.0b2/bin/eui

ifdef WIN32 then
   puts(1, "This is windows 32 platformn")
elsifdef LINUX then
   puts(1, "This is LINUX platformn")
elsedef
   puts(1, "This is neither Unix nor Windowsn")
end ifdef

当在Linux机器上运行此程序,它会产生以下结果:

This is LINUX platform


分类导航

关注微信下载离线手册

bootwiki移动版 bootwiki
(群号:472910771)