• My Pages
  • Comments
  • Add Link
  • Subscribe
  • Subscribe User
  • Edit (GUI)
  • Edit (Text)
  • Rename Page
  • Copy Page
  • Load Page
  • Save Page
  • Delete Page
  • Attachments
  • Check Spelling
  • Diffs
  • Info
  • Revert to this revision
  • XML
  • Render as Docbook
  • Print View
  • Raw Text
  • Delete Cache
  • Like Pages
  • Local Site Map
  • Remove Spam
  • Package Pages
  • Sync Pages

    You are not allowed to perform this action.

    Clear message

    This is an example of how to convert CSV output ("members" command in this case) to an array of objects. It also shows how you can process numeric/string/date fields differently and easily sort them.

    command "members"
    execute "members = [ " + $result.replace(/^(".*?"),(".*?"),"(.*?)","(.*?)",(".*?"),"(.*?)","(.*?)".*?$/gm, "\{ lord:$1, position:$2,prestige:$3,honor:$4,lastlogin:date($5),cities:$6,population:$7 \}").split("\n").splice(1).join(",\n") + " ]"
    
    top = members.sortOn("prestige", 18)[0]
    echo "Highest prestige member is " + top.lord + ", prestige=" + FormatNumber(top.prestige)
    
    last = members.sortOn("lastlogin", 18)[0]
    echo "Most recent login is " + last.lord + ", login=" + last.lastlogin


    ScriptExamples