source: git/Tst/Short/branchTo.tst @ ee8cdb

spielwiese
Last change on this file since ee8cdb was ee8cdb, checked in by Hans Schoenemann <hannes@…>, 7 years ago
fix: branchTo can return results (via _)
  • Property mode set to 100644
File size: 902 bytes
Line 
1LIB "tst.lib";
2tst_init();
3
4  proc p1(int i) { "int:",i; }
5  proc p21(string s) { "string:",s; }
6  proc p22(string s1, string s2) { "two strings:",s1,s2; }
7  proc p()
8  { branchTo("int",p1);
9    branchTo("string","string",p22);
10    branchTo("string",p21);
11    ERROR("not defined for these argument types");
12  }
13  p(1);
14  p("hu");
15  p("ha","ha");
16// returning stuff:
17proc square(int i){return(i^2);};
18proc tst(){branchTo("int",square); ERROR("No method found");}
19tst(2);
20//---------------------------------------------------------------
21newstruct("Net","list rows");
22
23proc printNet(Net N)
24{
25  list L = N.rows;
26  for (int j=1; j<=size(L); j++)
27  {
28    print(L[j]);
29  }
30}
31
32system("install","Net","print",printNet,1);
33
34proc netString(string M)
35{
36  Net N;
37  list L;
38  L[1]=M;
39  N.rows=L;
40  return(N);
41}
42
43proc net() {branchTo("string",netString);}
44
45typeof(net("abc"));
46Net N = net("abc");
47
48tst_status(1);$;
49
Note: See TracBrowser for help on using the repository browser.