上一個主題: 指令檔範例下一個主題: 樣本指令檔


樣本表頭

檔案名稱:  SampleHeader.hdr

/* 設定全域變數 */
function SharedFunction( strFunctionName )
{
     var strPrint;

     strPrint = "SharedFunction::" + strFunctionName;
     Print( strPrint, DETAILED );
}

function RecursionTest( strRecursionCount )
{
     Print( "enter RecursionTest = " + strRecursionCount );

     if (strRecursionCount != "xxxx")
     {
          var strIfScope = strRecursionCount + "x";

          RecursionTest( strIfScope );
     }
     else
     {
          return;
     }

     Print( "leave RecursionTest = " + strRecursionCount );
}

function ReturnTest( strParameter )
{
     if ((strParameter == 1) || (strParameter == 2))
     {
          return (strParameter + strParameter);
     }

     {
          var     result1 = ReturnTest( 1 ),
                    result2 = ReturnTest( 2 );

          return result1 + result2;
     }
}

function ScopeTest()
{
     strScope = "not in scope test";
     Print( strScope );
     {
          var strScope = "in scope test";

          Print( strScope );

          var strScopeList = EnumKey(  "HKLM\\Software", true );
          for (var strScopeIdx in strScopeList)
          {
               var strScope = strScopeList[strScopeIdx];

               Print( "key = " + strScope );
          }
     }
     Print( strScope );

     if (strScope == "not in scope test")
     {
          Print( "scope test was good" );
     }
     else
     {
          Print( "scope test was bad" );
     }

     {
     var     strUnused     = "pointless local variable creation should",
                    strUnused2     = "generate only temporary nodes if no statements";
     }

     {
          /* 空範圍應該完全不會產生節點 */
     }
}

function BreakTest()
{
     x = false;

     while (true)
     {
          Print( "in loop" );
          if (x) break;
          x = true;
     }

     Print( "broke loop" );
}