GLOBAL SITES
 Home > Products > Nuva Language > Code Examples

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
.>

file generation

<.  
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
.>

assign | capture output

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

function | recursion

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

class | polymorphism

<.
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
.>

Overview
Features
Download
Code Examples
Online Documents
Word to HTML help Word to Web help CHM to Web help CHM to Word CHM to HTML/MHTML .NET assembly Obfuscator