Skip to content

Commit

Permalink
*explode return array size.
Browse files Browse the repository at this point in the history
http://herc.ws/board/topic/7489-explode-to-push-arraysize/

Closes #700 as merged

Signed-off-by: Haru <haru@dotalux.com>
  • Loading branch information
Emistry authored and MishimaHaruna committed Dec 20, 2015
1 parent 851e97a commit 6a0093b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions doc/script_commands.txt
Expand Up @@ -8007,17 +8007,19 @@ Breaks a string up into substrings based on the specified delimiter.
Substrings will be stored within the specified string array. Only the 1st
char of the delimiter parameter will be used. If an empty string is passed
as a delimiter, the string will be placed in the array in its original
form, without any changes.
form, without any changes. Return the number of elements written to
<dest_array>.

Example:

explode(.@my_array$, "Explode:Test:1965:red:PIE", ":");
.@num_elements = explode(.@my_array$, "Explode:Test:1965:red:PIE", ":");
//.@my_array$ contents will be...
//.@my_array$[0]: "Explode"
//.@my_array$[1]: "Test"
//.@my_array$[2]: "1965"
//.@my_array$[3]: "red"
//.@my_array$[4]: "PIE"
//.@num_elements: 5

---------------------------------------

Expand Down
2 changes: 2 additions & 0 deletions src/map/script.c
Expand Up @@ -14967,6 +14967,8 @@ BUILDIN(explode)
script->set_reg(st, sd, reference_uid(id, start + k), name, (void*)temp, reference_getref(data));

aFree(temp);

script_pushint(st, k + 1);
return true;
}

Expand Down

0 comments on commit 6a0093b

Please sign in to comment.