Split: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 15: Line 15:
       outputChatBox ( "key: " .. splitKey .. " val: " .. splitVal ) -- output the index and token
       outputChatBox ( "key: " .. splitKey .. " val: " .. splitVal ) -- output the index and token
     end
     end
  end
end
end
</syntaxhighlight>
</syntaxhighlight>

Revision as of 02:36, 27 June 2006

This function splits a string into sub-strings. You specify a character that will act as a separating character; this will determine where to split the sub-strings.

Returns

Returns a table of the sub-strings.

Syntax

table split ( string, separatingchar )

Example

function onConsole ( player, text )
  splittext = split ( text, 32 ) -- Grab the table of tokens
    for splitKey, splitVal in splittext do -- for each token there..
      outputChatBox ( "key: " .. splitKey .. " val: " .. splitVal ) -- output the index and token
    end
end

See Also