File: test_script_string_as_array.kscript

package info (click to toggle)
castle-game-engine 6.4%2Bdfsg1-7
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 195,044 kB
  • sloc: pascal: 364,622; ansic: 8,606; java: 2,851; objc: 2,601; cpp: 1,412; xml: 851; makefile: 723; sh: 563; php: 26
file content (21 lines) | stat: -rw-r--r-- 816 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function main()
  array_set_count(my_string, 10);
  for (my_int, 0, 9, array_set(my_string, my_int, 'b'));
  { now my_string should be 'bbbbbbbbbb' }
  my_string := my_string + array_get(my_string, 5) + array_get(my_string, 5) +
    character_from_code(123);
  { now my_string should be 'bbbbbbbbbbbb' + #123 }
  my_string := my_string + string(array_get_count(my_string))
  { now my_string should be 'bbbbbbbbbbbb' + #123 + '13' }

function error1()
  my_string := '';
  array_set(my_string, 0 { incorrect - index outside string length }, 'b')

function error2()
  my_string := 'sdfulwehruhwurhui23h4uioh2uio34';
  array_set(my_string, 10, 'blah' { incorrect - this must be 1 single character })

function error3()
  my_string := '';
  my_string := array_get('blah', 10 { incorrect - index outside string length })