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

24
LINES

< > BotCompany Repo | #534 // Parse questionnaire

Lua code

1  
get("#515") -- splitLines
2  
3  
-- sets masterBridgeID and verdicts
4  
function parseQuestionnaire(questionnaireID)
5  
  local text = getSnippet(questionnaireID)
6  
  local lines = splitLines(text)
7  
8  
  masterBridgeID = nil
9  
  verdicts = {}
10  
  
11  
  for i=1, #lines do
12  
    line = lines[i]
13  
    
14  
    local _, _, _needBridgeID, _sourceID, _masterBridgeID = line:find("^(#%d+) %- Need bridge from (#%d+) following master bridge (#%d+)")
15  
    if _needBridgeID then
16  
      needBridgeID, sourceID, masterBridgeID = _needBridgeID, _sourceID, _masterBridgeID
17  
    end
18  
  
19  
    local _, _, verdict = line:find("^ *Your verdict: *(.*)")
20  
    if verdict then
21  
      verdicts[sourceID] = verdict
22  
    end
23  
  end
24  
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: 699 / 192
Referenced in: [show references]