spielwiese
Last change
on this file since fdda546 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 | |
---|
1 | LIB "tst.lib"; |
---|
2 | tst_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: |
---|
17 | proc square(int i){return(i^2);}; |
---|
18 | proc tst(){branchTo("int",square); ERROR("No method found");} |
---|
19 | tst(2); |
---|
20 | //--------------------------------------------------------------- |
---|
21 | newstruct("Net","list rows"); |
---|
22 | |
---|
23 | proc 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 | |
---|
32 | system("install","Net","print",printNet,1); |
---|
33 | |
---|
34 | proc netString(string M) |
---|
35 | { |
---|
36 | Net N; |
---|
37 | list L; |
---|
38 | L[1]=M; |
---|
39 | N.rows=L; |
---|
40 | return(N); |
---|
41 | } |
---|
42 | |
---|
43 | proc net() {branchTo("string",netString);} |
---|
44 | |
---|
45 | typeof(net("abc")); |
---|
46 | Net N = net("abc"); |
---|
47 | |
---|
48 | tst_status(1);$; |
---|
49 | |
---|
Note: See
TracBrowser
for help on using the repository browser.