Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

24
LINES

< > BotCompany Repo | #534 // Parse questionnaire

Lua code

get("#515") -- splitLines

-- sets masterBridgeID and verdicts
function parseQuestionnaire(questionnaireID)
  local text = getSnippet(questionnaireID)
  local lines = splitLines(text)

  masterBridgeID = nil
  verdicts = {}
  
  for i=1, #lines do
    line = lines[i]
    
    local _, _, _needBridgeID, _sourceID, _masterBridgeID = line:find("^(#%d+) %- Need bridge from (#%d+) following master bridge (#%d+)")
    if _needBridgeID then
      needBridgeID, sourceID, masterBridgeID = _needBridgeID, _sourceID, _masterBridgeID
    end
  
    local _, _, verdict = line:find("^ *Your verdict: *(.*)")
    if verdict then
      verdicts[sourceID] = verdict
    end
  end
end

Author comment

Began life as a copy of #531

test run  test run with input  download  show line numbers   

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #534
Snippet name: Parse questionnaire
Eternal ID of this version: #534/1
Text MD5: 6993b04ad76c481ad578233fbfb2e065
Author: stefan
Category:
Type: Lua code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-03-15 03:59:10
Source code size: 695 bytes / 24 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 626 / 171
Referenced in: [show references]