GLOBAL SITES
 首页 > 产品 > Nuva (女娲) 语言 > 代码示例

foreach | O/R Mapping

<.
function Foreach_Demo()
  // Load Schema from a Xml file
  var schema = System.Data.LoadSchema(
      System.Path.ProjectPath ~ '..\Northwind\Northwind.xobject'
    );

   '--------------------'
   'Tables Order by Name'
   '--------------------'
  foreach(table = schema.Tables.OrderbyName)
     table.Name
  end foreach

   '---------------------------------'
   'Tables Filter by Name.Length < 10'
   '---------------------------------'
  foreach(table = schema.Tables | table.Name.Length < 10)
     table.Name
  end foreach
end function
.>

生成文件

<.  
function File_Demo()
   \r\n ~ '--Read file and Output here--'
  file('codeexamples.nuvaproj') end file

  // Read file and write to 'Target', overwrite it if exist
  file('codeexamples.nuvaproj', true)
    Target = 'temp.target'
  end file
  
   \r\n ~ '--Read file dynamically and Output here--'
  file('')
    Filename = System.Path.ProjectPath ~ 'output\temp.target'
  end file
  
  // Delete file
  System.File.Delete(System.Path.ProjectPath ~ 'output\temp.target')
end function
.>

捕获输出

<.  
function Assign_Demo()
  // 'Result' assigned from the output in the assign statement
  assign(Result).]
    Generate Text ... @[.=System.Now.] ...
<.end assign
end function
.>

函数 | 递归调用

<.
/*========================================================
	Factorial
========================================================*/
function Factorial ( N )
  if (N <= 1)
    Result = 1;
  else
    Result = N * Factorial(N - 1); // Recursion Call
  end if;
end function;
.>

类 | 多态性

<.
function Class_Demo()
  class ClassA()
    function Do()
      this.DynDo()
    end function
    
    function DynDo()
       'ClassA'
    end function
  end class
  
  class ClassB = ClassA()
    function DynDo()
       'ClassB'
    end function
  end class

  var c1 = ClassA()
  var c2 = ClassB()
  c1.Do()
  c2.Do()
end function
.>

概述
特点
下载
代码示例
在线文档
Word to HTML help Word to Web help CHM to Web help CHM to Word CHM to HTML/MHTML .NET assembly Obfuscator