<.
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
endforeach
'---------------------------------'
'Tables Filter by Name.Length < 10'
'---------------------------------'
foreach(table = schema.Tables | table.Name.Length <10)
table.Name
endforeach
endfunction
.>
生成文件
<.function File_Demo()
\r\n ~'--Read file and Output here--'
file('codeexamples.nuvaproj')endfile
// Read file and write to 'Target', overwrite it if exist
file('codeexamples.nuvaproj',true)
Target ='temp.target'
endfile
\r\n ~'--Read file dynamically and Output here--'
file('')
Filename = System.Path.ProjectPath ~'output\temp.target'
endfile
// Delete file
System.File.Delete(System.Path.ProjectPath ~'output\temp.target')
endfunction
.>
捕获输出
<.function Assign_Demo()
// 'Result' assigned from the output in the assign statement
assign(Result).]
GenerateText...@[.=System.Now.]...
<.endassign
endfunction
.>
函数 | 递归调用
<.
/*========================================================
Factorial
========================================================*/
function Factorial ( N )
if(N <=1)
Result =1;
else
Result = N * Factorial(N -1);// Recursion Call
endif;
endfunction;
.>
类 | 多态性
<.
function Class_Demo()
class ClassA()
function Do()
this.DynDo()
endfunction
function DynDo()
'ClassA'
endfunction
endclass
class ClassB = ClassA()
function DynDo()
'ClassB'
endfunction
endclass
var c1 = ClassA()
var c2 = ClassB()
c1.Do()
c2.Do()
endfunction
.>