Módulo:Directory: mudanças entre as edições

sem sumário de edição
imported>Jaideraf
m (uma edição)
imported>Jaideraf
Sem resumo de edição
local p = {}
function p.makeDirectory ( frame )
if not mw.smw then
return "mw.smw module not found"
end
local fieldLengths = frame:preprocess(
[=[{{#ask: [[-Has subobject::{{{1|{{#urldecode:{{#urlget:fullpagename|{{FULLPAGENAME}}}}}}}}}]]
[[Control field data::+]]
|?Control field data
|format=plainlist
|link=none
|order=asc
|headers=hide
|outro=,|propsep=,|valuesep=&&&&|sep=,|template=ISO2709/ControlFieldDirectoryBuilder
}}{{#ask: [[-Has subobject::{{{1|{{#urldecode:{{#urlget:fullpagename|{{FULLPAGENAME}}}}}}}}}]]
[[Field data::+]]
|?Field data
|format=plainlist
|limit=100
|link=none
|order=asc
|headers=hide
|propsep=,|valuesep=&&&&|sep=,|template=ISO2709/DataFieldDirectoryBuilder
}}]=]):gsub( '%[%[SMW::...?%]%]', '' ) or '0'
local sum = 0
local directory = ''
for index, tagAndLenght in ipairs(
mw.text.split ( frame.args[1]:gsub( '%[%[SMW::...?%]%]', '' )fieldLengths, ',' , true )
) do
-- frame.args[1] captura o primeiro e único argumento da chamada
-- armazenados na variável 'sum'.
end
local baseAddressOfData = string.format("%05d", #directory + 25)
return directory
-- retornaCálculo odo diretório"Record completolength":
-- "Field length" + "Base address of data" + 1 caractere de "Record terminator"
-- '001000700000003000900007005001700016008004100033'
local recordLength = string.format("%05d", sum + baseAddressOfData + 1)
 
local dataStore = {
'Directory=' .. directory,
'Base address of data=' .. baseAddressOfData,
'Record length=' .. recordLength
}
 
local result = mw.smw.subobject( dataStore, '000' )
if result == true then
-- everything ok
else
return 'An error occurred during the subobject storage process. Message reads ' .. result.error
end
end
return p
Usuário anônimo