wasCSharpSQLite – Blame information for rev 3

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /*
2 * JoinCmd.java
3 *
4 * Copyright (c) 1997 Cornell University.
5 * Copyright (c) 1997 Sun Microsystems, Inc.
6 *
7 * See the file "license.terms" for information on usage and
8 * redistribution of this file, and for a DISCLAIMER OF ALL
9 * WARRANTIES.
10 *
11 * Included in SQLite3 port to C# for use in testharness only; 2008 Noah B Hart
12 *
13 * RCS @(#) $Id: JoinCmd.java,v 1.1.1.1 1998/10/14 21:09:18 cvsadmin Exp $
14 *
15 */
16 using System.Text;
17 namespace tcl.lang
18 {
19  
20 /// <summary> This class implements the built-in "join" command in Tcl.</summary>
21 class JoinCmd : Command
22 {
23  
24 /// <summary> See Tcl user documentation for details.</summary>
25 public TCL.CompletionCode cmdProc( Interp interp, TclObject[] argv )
26 {
27 string sep = null;
28  
29 if ( argv.Length == 2 )
30 {
31 sep = null;
32 }
33 else if ( argv.Length == 3 )
34 {
35  
36 sep = argv[2].ToString();
37 }
38 else
39 {
40 throw new TclNumArgsException( interp, 1, argv, "list ?joinString?" );
41 }
42 TclObject list = argv[1];
43 int size = TclList.getLength( interp, list );
44  
45 if ( size == 0 )
46 {
47 interp.resetResult();
48 return TCL.CompletionCode.RETURN;
49 }
50  
51  
52 StringBuilder sbuf = new StringBuilder( TclList.index( interp, list, 0 ).ToString() );
53  
54 for ( int i = 1; i < size; i++ )
55 {
56 if ( (System.Object)sep == null )
57 {
58 sbuf.Append( ' ' );
59 }
60 else
61 {
62 sbuf.Append( sep );
63 }
64  
65 sbuf.Append( TclList.index( interp, list, i ).ToString() );
66 }
67 interp.setResult( sbuf.ToString() );
68 return TCL.CompletionCode.RETURN;
69 }
70 }
71 }