cfad47cfa3/t3compiler/tads3/test/data/vec_pre.t

4b825dc642cb6eb9a060e54bf8d69288fbee4904cfad47cfa334b206c65f22086bcc5d63e6f70944
1
#include <tads.h>
2
#include <t3.h>
3
#include <vector.h>
4
5
main(args)
6
{
7
    "initial: obj1.v = <<sayVec(obj1.v)>>\n";
8
9
    obj1.v += 'd';
10
    obj1.v += 'e';
11
    obj1.v += 'f';
12
    obj1.v += 'g';
13
    obj1.v += 'h';
14
15
    "after changes: obj1.v = <<sayVec(obj1.v)>>\n";
16
17
    "restarting...\n";
18
    restartGame();
19
    restarter(1, args);
20
}
21
22
restarter(ctx, args)
23
{
24
    /* perform post-load initialization again, now that we're reloaded */
25
    initAfterLoad();
26
27
    "restarted!\n";
28
29
    "obj1.v = <<sayVec(obj1.v)>>\n";
30
31
    obj1.v += 'x';
32
    "more changes: <<sayVec(obj1.v)>>\n";
33
}
34
35
sayVec(v)
36
{
37
    local first;
38
    
39
    "[";
40
    first = true;
41
    foreach (local x in v)
42
    {
43
        if (!first)
44
        {
45
            ", ";
46
            first = nil;
47
        }
48
        "<<x>>";
49
    }
50
    "]";
51
}
52
53
obj1: object
54
    v = nil
55
;
56
57
myPreiniter: PreinitObject
58
    execute()
59
    {
60
        obj1.v = new Vector(5);
61
        obj1.v += 'a';
62
        obj1.v += 'b';
63
        obj1.v += 'c';
64
    }
65
;
66