string_copy

Returns all or part of another string.

Syntax:

string_copy(str, index, count);


Argument Description
str The string to copy from.
index The position of the first character in the string to copy from (numbered from 1)
count The number of characters, starting from the position of the first, to copy


Returns: string


Description

With this function you can easily select a number of characters from within a string to be copied to another one. The first character in a string is always numbered as "1", so to copy (for example) the first five characters of string you would have string_copy(str, 1, 5). A further example is provided below.

Example:

name = keyboard_string;
if string_length(name) > 15 )
      {
      keyboard_string = string_copy(name, 1, 15 );
      }

The above code will allow the player to input a string through the keyboard which is then stored in the variable "name". This variable is then checked to see if it exceeds the maximum length of 15 characters and if it does, the keyboard_string is replaced by a 15 character copy of the "name" string. This effectively limits the player input to 15 characters.


Back: Strings
Next: string_count
© Copyright YoYo Games Ltd. 2018 All Rights Reserved