PtokaX forum

Archive => HOW-TO's => Archived 5.1 boards => Old HOW-TO's => Topic started by: Mardeg on 04 September, 2005, 01:39:31

Title: Neatest way to iterate through a CSV string?
Post by: Mardeg on 04 September, 2005, 01:39:31
Example: "1stString,2ndString,3rdString,4thString," etc..

..so the code allows us to, for example, check if the string is a user currently in the hub..

if GetItemByName(xString) then
.... do stuff with xString ....
end

for some reason I haven't been able to get string.gfind to work in a for loop for me. Might be due to lack of sleep
Title:
Post by: bastya_elvtars on 06 September, 2005, 20:27:49
for w in string.gfind(data,"([^,]+)") do
  if GetItemByName(xString) then
    -- .... do stuff with xString ....
  end
end

Also take a look at this (http://ptxwiki.psycho-chihuahua.net/doku.php/scriptinghelp/strings)  page.
Title:
Post by: Mardeg on 07 September, 2005, 22:26:26
Thanks a million for that bastya_elvtars :)

It turns out the code I had tried wasn't even being run because of an unrelated script bug, but your example was neater anyway.