• My Pages
  • Comments
  • Add Link
  • Subscribe
  • Subscribe User
  • 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

    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

    SortingMemberList (last edited 2015-02-16 14:43:16 by tech)