! Inform file created from 20_parser.t ! Version-specific constants - Ifdef these to test only certain versions Iftrue #version_number >= 4; Constant V4PLUS = 1; Endif; Iftrue #version_number >= 5; Constant V5PLUS = 1; Endif; Release 1; Serial "314159"; Global G0; Global G1; Array arr -> 512; Array arr2 -> 512; ! Object stuff ! First objects are qw(Class Object Routine String) ! It appears that the first declared property (propa) is #4 ! First declared attr is 0 Attribute attr1; Attribute attr2; Attribute attr3; Attribute attr4; Property propa 11; Property propb 12; Property propc 13; Property propd 14; Property prope 15; Object Obj1 "Test Object #1" has attr1 attr2 with propa 1, propb 2, propd 4 5 6; Object Obj2 "Test Object #2" Obj1 has attr3 attr4 with propa 2, propd 4; Object Obj3 "Test Object #3" Obj1 with propa 3, propd 4; Object Obj4 "Test Object #4" Obj3 with propa 4, propd 4; #Ifdef V4PLUS; ! limit of 4-byte properties ! This object is only valid on standard 1.0 interpreters because of ! the 64 byte property. Object Obj5 "" with propa 1, propb 1 2 3, propc 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29, prope 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32; #Endif; [ Main i j; ! Math @add 3 2 -> i; @sub 3 2 -> G0; @mul 3 2 -> sp; @div 12 i -> sp; @mod 9 sp -> i; @random 3 -> i; ! TODO indirect ! Binary math @or 4 3 -> j; @and 4 3 -> j; @not 1 -> i; @art_shift 4 1 -> i; @log_shift 4 65535 -> i; ! Prints @print_num G0; @print_char 'A'; @new_line; ! Input @read_char 1 -> i; ! Note aread won't work for v4 @aread arr arr2 -> i; @tokenise arr arr2; ! Fancy I/O #Ifdef V4PLUS; @buffer_mode 1; #Endif; #Ifdef V5PLUS; @output_stream 3 arr; #Ifnot; @output_stream 4; #Endif; @input_stream 0; ! no effect ! Memory @loadw $0c 0 -> G1; @loadb G1 1 -> j; ! g00 @storeb i 1 3; ! change g00 @store i arr; @storew i 0 $11aa; ! 4 13 10: Shift-He @storew i 1 $4634; ! 17 17 20: llo @print_addr i; @store i "This is a long string that Inform will put in high memory."; @print_paddr i; ! Variables @inc i; .b0; @inc_chk i 5 ?b1; @dec [i]; .b1; @dec_chk j (-10) ?~b0; @store i 17; @load i -> j; ! Calls @call_1s sub1 -> sp; @call_1n sub1; @call_2s sub1 sp -> i; @call_2n sub1 j; @call_vs sub1 j 2 G0 -> i; @call_vn sub1; @call_vs2 sub1 1 2 3 4 5 6 7 -> i; @call_vn2 sub1 1 2 3 4 5 6 7; @store j sub1; @call_1n j; ! Objects @print_obj Obj1; @insert_obj Obj3 Obj2; @jin Obj4 Obj2 ?b2; @remove_obj Obj4; .b2; @get_sibling Obj1 -> i ?b3; @get_child Obj1 -> i ?b3; @get_parent Obj2 -> i; .b3; @get_prop Obj1 propa -> i; @get_next_prop Obj1 propa -> i; @get_prop_addr Obj1 propd -> i; @get_prop_len i -> j; @put_prop Obj1 propa 17; @test_attr Obj1 attr1 ?b4; @set_attr Obj1 attr3; .b4; @clear_attr Obj2 attr3; ! GUI @split_window 10; @set_window 1; @erase_window -1; @get_cursor arr; @set_cursor 3 4; @erase_line 5; @set_text_style 0; ! Game state @save_undo -> i; @restore_undo -> i; @save -> i; @restore -> i; quit; ]; [ sub1 a b c; ! Jumps / branches / returns .j0; @jl 1 2 ?~j2; @push 3; #Ifdef V5PLUS; @piracy ?~j4; @check_arg_count 3 ?~j4; #Endif; @ret_popped; .j4; @jz 1 ?rfalse; @je 1 1 ?~rtrue; @je 1 2 3 ?j3; @jg a 5 ?j1; jump j0; ! using @jump seems to break Inform .j1; @nop; @ret c; .j2; @test 7 3 ?j5; @rtrue; .j3; @verify ?j5; @pull b; @print "Hello, "; @print_ret "world!^"; .j5; @rfalse; ];