當前位置: 首頁>>代碼示例>>C#>>正文


C# Interp.evalFile方法代碼示例

本文整理匯總了C#中tcl.lang.Interp.evalFile方法的典型用法代碼示例。如果您正苦於以下問題:C# Interp.evalFile方法的具體用法?C# Interp.evalFile怎麽用?C# Interp.evalFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tcl.lang.Interp的用法示例。


在下文中一共展示了Interp.evalFile方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: cmdProc

		public TCL.CompletionCode cmdProc(Interp interp, TclObject[] argv)
		{
			string fileName = null;
			bool url = false;
			
			if (argv.Length == 2)
			{
				
				fileName = argv[1].ToString();
			}
			else if (argv.Length == 3)
			{
				
				if (argv[1].ToString().Equals("-url"))
				{
					url = true;
					
					fileName = argv[2].ToString();
				}
			}
			
			if ((System.Object) fileName == null)
			{
				throw new TclNumArgsException(interp, 1, argv, "?-url? fileName");
			}
			
			try
			{
				if (url)
				{
					if (fileName.StartsWith("resource:/"))
					{
						interp.evalResource(fileName.Substring(9));
					}
					else
					{
						interp.evalURL(null, fileName);
					}
				}
				else
				{
					interp.evalFile(fileName);
				}
			}
			catch (TclException e)
			{
				TCL.CompletionCode code = e.getCompletionCode();
				
				if (code == TCL.CompletionCode.RETURN)
				{
					TCL.CompletionCode realCode = interp.updateReturnInfo();
					if (realCode != TCL.CompletionCode.OK)
					{
						e.setCompletionCode(realCode);
						throw ;
					}
				}
				else if (code == TCL.CompletionCode.ERROR)
				{
					/*
					* Record information telling where the error occurred.
					*/
					
					interp.addErrorInfo("\n    (file line " + interp.errorLine + ")");
					throw ;
				}
				else
				{
					throw ;
				}
			}
      return TCL.CompletionCode.RETURN;
    }
開發者ID:Belxjander,項目名稱:Asuna,代碼行數:73,代碼來源:SourceCmd.cs

示例2: Main

  /*
  ** 2009 July 17
  **
  ** The author disclaims copyright to this source code.  In place of
  ** a legal notice, here is a blessing:
  **
  **    May you do good and not evil.
  **    May you find forgiveness for yourself and forgive others.
  **    May you share freely, never taking more than you give.
  **
  *************************************************************************
  ** This file contains code to implement the "sqlite" test harness
  ** which runs TCL commands for testing the C#-SQLite port.
  **
  ** $Header$
  */
  public static void Main(string[] args)
  {
    // Array of command-line argument strings.
    {
      string fileName = null;

      // Create the interpreter. This will also create the built-in
      // Tcl commands.

      Interp interp = new Interp();

      // Make command-line arguments available in the Tcl variables "argc"
      // and "argv".  If the first argument doesn't start with a "-" then
      // strip it off and use it as the name of a script file to process.
      // We also set the argv0 and TCL.Tcl_interactive vars here.

      if ((args.Length > 0) && !(args[0].StartsWith("-")))
      {
        fileName = args[0];
      }

      TclObject argv = TclList.newInstance();
      argv.preserve();
      try
      {
        int i = 0;
        int argc = args.Length;
        if ((System.Object)fileName == null)
        {
          interp.setVar("argv0", "tcl.lang.Shell", TCL.VarFlag.GLOBAL_ONLY);
          interp.setVar("tcl_interactive", "1", TCL.VarFlag.GLOBAL_ONLY);
        }
        else
        {
          interp.setVar("argv0", fileName, TCL.VarFlag.GLOBAL_ONLY);
          interp.setVar("tcl_interactive", "0", TCL.VarFlag.GLOBAL_ONLY);
          i++;
          argc--;
        }
        for (; i < args.Length; i++)
        {
          TclList.append(interp, argv, TclString.newInstance(args[i]));
        }
        interp.setVar("argv", argv, TCL.VarFlag.GLOBAL_ONLY);
        interp.setVar("argc", System.Convert.ToString(argc), TCL.VarFlag.GLOBAL_ONLY);
      }
      catch (TclException e)
      {
        throw new TclRuntimeError("unexpected TclException: " + e.Message);
      }
      finally
      {
        argv.release();
      }

      // Normally we would do application specific initialization here.
      // However, that feature is not currently supported.
      // If a script file was specified then just source that file
      // and quit.

      Console.WriteLine("C#-TCL version " + Assembly.GetExecutingAssembly().GetName().Version.ToString());
      Console.WriteLine("==============================================================");
      Console.WriteLine("");

      if ((System.Object)fileName != null)
      {
        try
        {
          interp.evalFile(fileName);
        }
        catch (TclException e)
        {
          TCL.CompletionCode code = e.getCompletionCode();
          if (code == TCL.CompletionCode.RETURN)
          {
            code = interp.updateReturnInfo();
            if (code != TCL.CompletionCode.OK)
            {
              System.Console.Error.WriteLine("command returned bad code: " + code);
              if (tcl.lang.ConsoleThread.debug) System.Diagnostics.Debug.WriteLine("command returned bad code: " + code);
            }
          }
          else if (code == TCL.CompletionCode.ERROR)
          {
//.........這裏部分代碼省略.........
開發者ID:Jaden-J,項目名稱:csharp-sqlite,代碼行數:101,代碼來源:csTCL.cs


注:本文中的tcl.lang.Interp.evalFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。