#!lua --{{{ history --[[ 17/10/23 CRJ Created --]] --}}} --{{{ TEMPLATE:AddMachines,AddMachines,Add Machines --[[ --{{{ DESCRIPTION: . BE CAREFUL - DO NOT RUN UNLESS ABSOLUTELY SURE!!!!! . --}}} --]] --}}} --{{{ requires require('debugger') m = require('match_it') --}}} --{{{ Variables --Useful stuff VoidValue = m.void() TrueFlag = m.flag(true) FalseFlag = m.flag(false) ZeroRecNo = m.RecNo() ResourceRecType = m.Str(m.mcOpItem) CandidateResource = m.ResTyp() --}}} --{{{ Physical Files mcb = m.file(m.mcb) --}}} --{{{ functions function removeLastWord(inputString) -- Split the input string into words local words = {} for word in inputString:gmatch("%S+") do table.insert(words, word) end -- Check if there are words to remove if #words > 0 then -- Remove the last word table.remove(words) -- Reconstruct the string without the last word local resultString = table.concat(words, " ") return resultString else -- If the input string is empty or contains only whitespace, return it as is return inputString end end --}}} --{{{ open files m.open(mcb) --}}} --{{{ Setup transaction m.TransPrepare('Setup time Increase Processor') m.TransInclude(mcb) m.TransBegin() --}}} --{{{ Process the resource MCBs m.MonitorStart('Process each candidate resource') --{{{ process candidates MCBRecordsProcessed = 0 mcb.RecType = 'O' mcb.Assembly = VoidValue mcb.Process = VoidValue mcb.ItemName = VoidValue m.set(mcb,m.mcbRecTypeAssemblyProcessItemNameKey,m.mcbRecType) while m.next(mcb) ~= VoidValue do --{{{ process the resource mcb m.MonitorStep('resource MCB is ... ' .. mcb.Resource) Res = 0 GroupStr = m.String(mcb.ResGroup) if mcb.Resource == VoidValue and string.find(GroupStr,'Operators') then ResStr = removeLastWord(GroupStr) Res = m.ResTyp(ResStr) if (Res == VoidValue) then m.message('problem finding resource for ' .. GroupStr) break end setup = mcb.StepSetupTime cycle = mcb.IterationTime --newMCB = m.mcInsertInMethod(m.rst,Res,mcb.Assembly,mcb.Process,mcb.RecNo,junk,junk,'') --m.Load(mcb,newMCB) --mcb.StepSetupTime = setup --mcb.IterationTime = cycle --m.Update(mcb) end --}}} end --}}} m.MonitorStop() --}}} --{{{ End transaction m.TransEnd() --}}} --{{{ close files m.close(mcb) --}}} m.message('Done') return false