Since your string contains "MSH, PID, PV1, EVN"
, you'd have to use a hash-table or a lookup table. The program would be something like this:
S = "MSH, PID, PV1, EVN"
tLookup = {
MSH = "Message",
EVN = "Event",
PID = "Patient",
PV1 = "Visit",
}
for u in S:gmatch "([^,%s]+)" do
sNameOfFunction = tLoopup[u]
_G[ "Map"..sNameOfFunction ] ( Process["ks."..u][1], MsgIn, mg )
k=k+1
end
Or even something like this:
S = "MSH, PID, PV1, EVN"
tLookup = {
MSH = _G.MapMessage,
EVN = _G.MapEvent,
PID = _G.MapPatient,
PV1 = _G.MapVisit,
}
for u in S:gmatch "([^,%s]+)" do
tLoopup[u] ( Process["ks."..u][1], MsgIn, mg )
k = k+1
end