//==================================================================
// 1.IsIdInList function
// Check if a unit id(integer ui) in a list(string list).The list is string full of id's turned
// into string.For example string list = I2S('ugho')+I2S('ocat')+I2S('hfoo')
// The function checks if the id (integer ui ; 'hfoo' for instance) is in the list and if it is then returns true
// 2.CountIdsInList function
// Counts the number of ids in a list.The list is string full of id's turned
// into string.For example string list = I2S('ugho')+I2S('ocat')+I2S('hfoo')
// Returns the exact number of ids wich in the upper list are three('ugho','ocat','hfoo').Returns 0 if there isn't a list
// 3.GetIdFromListByCount function
// Gets an id integer from a list(string list) by a number(integer c).The list is string full of id's turned
// into string.For example string list = I2S('ugho')+I2S('ocat')+I2S('hfoo')
// If c=2 then the function returns 'ocat'.If the number is bigger than the count in the list it will return the last id.
// If the id doesn't exist the function returns nothing
//
//==================================================================
function IsIdInList takes integer ui,string list returns boolean
local string s2
local integer i=10
local boolean b=false
loop
set s2=SubString(list,i-10,i)
set i=i+10
if s2==I2S(ui) then
set b=true
else
set b=false
endif
exitwhen s2=="" or s2==I2S(ui)
endloop
return b
endfunction
function CountIdsInList takes string list returns integer
local string s2
local integer i=10
local integer b=0
loop
set s2=SubString(list,i-10,i)
set i=i+10
if s2!="" then
set b=b+1
endif
exitwhen s2==""
endloop
return b
endfunction
function GetIdFromListByCount takes string list,integer c returns integer
local string s2
local integer i=10
local integer b=0
local integer id
if c>CountIdsInList(list) then
set c=CountIdsInList(list)
endif
loop
set s2=SubString(list,i-10,i)
set i=i+10
if s2!="" then
set b=b+1
endif
exitwhen s2==""
if b==c then
set id=S2I(s2)
endif
endloop
return id
endfunction