وحدة:ملعب/Mr. Ibrahem/find

من أرابيكا، الموسوعة الحرة
اذهب إلى التنقل اذهب إلى البحث
local str = {}

function Findd( source_str , target )
	local result
    if source_str == '' or target == "" then
        result = 0
    end  
    if target ~= '' then
	    local result = mw.ustring.find( source_str, target, 1 )
	    if result == nil then
	        result = 0
	    end
    end
    return result
end

function str.find( frame )
	local list = {s='source' , t='target' , y='yes'}
	local no = frame.args["no"] or '';
	ii = 1
	done = 0
	local source = frame.args[list.s .. ii] or '';
	while done < 1 do
	    local source_str = frame.args[list.s .. ii] or source;
	    local target = frame.args[list.t .. ii] or '';
	    local target2 = frame.args[list.t .. ii .. "a"] or '';
	    local yes = frame.args[list.y .. ii] or '';
	    --if target ~= "" and yes ~= "" then
		    local result = Findd( source_str , target )
		    if result ~= 0 and result ~= nil then 
    			--mw.log(result)
		    	mw.log(list.t .. ii)
		    	return yes
		    else
			    local result = Findd( source_str , target2 )
			    if result ~= 0 and result ~= nil then 
			    	mw.log(list.t .. ii)
			    	return yes
		    	end
		    end
		 --else
	    	--return no
	    --end
	   if target == "" and yes == "" then done = 1 end
    ii = ii + 1
    end
	mw.log("no")
    return no
end
return str