Page 3 of 3 FirstFirst 123
Results 21 to 22 of 22

Thread: tstringlist (help plz, im a noob)

  1. #21

    tstringlist (help plz, im a noob)

    I'm currently having troubles with arrays and the scripting language stuff.
    I'm trying to create a command split into 3 parts. the first part is the type of command, the second is to which object, and the last is the variable that relates to the speed of the object. Can someone explain how arrays work, and to show how i can split a command into three parts?

  2. #22
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    tstringlist (help plz, im a noob)

    An array is declared as follows:

    [pascal]Var
    MyArray : Array[0..2] of String;[/pascal]

    To access (set or get) a value in the array
    MyArray[0]

    So to set a value do
    MyArray[0] := 'William';
    MyArray[1] := 'Morgan';
    MyArray[2] := 'Cairns';

    Now to split a string into the array. There are a number of methods the easiest one (and the one I use all the time - which is why I consider it the easiest) is similar to how we split the command before

    [pascal]MyName := 'William Morgan Cairns';
    MyArray[0] := Copy(MyName,1,Pos(' ',MyName)-1);
    MyName := Copy(MyName,Pos(' ',MyName)+1,Length(MyName));
    MyArray[1] := Copy(MyName,1,Pos(' ',MyName)-1);
    MyName := Copy(MyName,Pos(' ',MyName)+1,Length(MyName));
    MyArray[2] := MyName;[/pascal]
    William Cairns
    My Games: http://www.cairnsgames.co.za (Currently very inactive)
    MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)

Page 3 of 3 FirstFirst 123

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •