Advertisement
mruno

!theatre Script 29NOV2014

May 24th, 2014
507
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 17.84 KB | None | 0 0
  1. ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. ;script !theater Script
  3. ;version 29NOV2014
  4. ;author mruno
  5. ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  6. ;
  7. ;total rewrite!
  8. ;uses rittebtinaties.com api
  9. ;no box office gross details in api :(
  10. ;
  11. ;uses JSON for MIRC By SReject http://hawkee.com/snippet/10194/
  12. ;
  13. on *:TEXT:*:#: {
  14.   if ($chr(36) isin $2-) return
  15.   if ($1 == !Theater) || ($1 == !cinema) || ($1 == !theatre) {
  16.     if ($timer(Theater.msg)) {
  17.       .timertheatre.wait 1 3 .notice $nick Please try again in 1 minute.
  18.       return
  19.     }
  20.     else .timerTheater.msg 1 60 noop
  21.  
  22.     if (m isin $chan(#).mode) .timerTheater.off 1 5 .notice $nick Script is OFF due to channel being moderated (+m).
  23.     else {
  24.       .notice $nick Gathering $1 data...
  25.       .timer 1 1 Theater.start $2 $nick $chan
  26.     }
  27.   }
  28. }
  29. alias Theater.start {
  30.   var %chan $3
  31.   var %nick $2
  32.   if ($1 == new) || ($1 == coming) || ($1 == upcoming) {
  33.     var %name Theater.new
  34.     if (!%Theater.num) $iif(%chan,msg %chan,iecho) 12!Theater Coming Soon:
  35.     set %Theater.num 1
  36.     jsonopen -u %name http://api.rottentomatoes.com/api/public/v1.0/lists/movies/opening.json?limit=10&country=us&apikey=ujhxx5s4uaekxyfj3e3etdj7
  37.     .timerTheater.complete 0 1 Theater.complete $1-
  38.   }
  39.   elseif ($1 == top) {
  40.     var %name Theater.top
  41.     if (!%Theater.num) $iif(%chan,msg %chan,iecho) 12!Theater Top Ten - In Theaters Now:
  42.     set %Theater.num 1
  43.     jsonopen -u %name http://api.rottentomatoes.com/api/public/v1.0/lists/movies/box_office.json?limit=10&country=us&apikey=ujhxx5s4uaekxyfj3e3etdj7
  44.     .timerTheater.complete 0 1 Theater.complete $1-
  45.   }
  46.   else {
  47.     $iif(%chan,.notice %nick,iecho) !Theater by mruno. Usage: !Theater [options]
  48.     $iif(%chan,.notice %nick,iecho)   Results types: Top or New - Top will list top grossing movies, New will list newest movies
  49.     $iif(%chan,.notice %nick,iecho) Example: !Theater new or !Theater top
  50.   }
  51. }
  52. alias Theater.complete {
  53.   if (!%Theater.num) set %Theater.num 1
  54.   else inc %Theater.num
  55.   if (%Theater.num > 3) {
  56.     unset %Theater.num
  57.     .timerTheater.repeat 1 1 Theater.start $1-
  58.   }
  59.  
  60.   var %chan $3
  61.   var %nick $2
  62.  
  63.   if ($1 == new) || ($1 == coming) || ($1 == upcoming) {
  64.     var %name Theater.new
  65.     if ($json(%name)) .timerTheater.complete off
  66.  
  67.     var %loop 0
  68.     while (%loop < 10) {
  69.       var %title $json(%name,movies,%loop,title)
  70.       var %year $json(%name,movies,%loop,year)
  71.       var %date $json(%name,movies,%loop,release_dates,theater)
  72.       var %rating $json(%name,movies,%loop,mpaa_rating)
  73.       var %critics $json(%name,movies,%loop,ratings,critics_score)
  74.       var %users $json(%name,movies,%loop,ratings,audience_score)
  75.       var %critics_meter $json(%name,movies,%loop,ratings,critics_rating)
  76.       var %user_meter $json(%name,movies,%loop,ratings,audience_rating)
  77.       var %meter $iif(%critics_meter,%critics_meter,None) / $iif(%user_meter,%user_meter,None)
  78.       var %score $calc($calc(%critics + %users) / 2)
  79.       var %imdb $json(%name,movies,%loop,alternate_ids,imdb)
  80.  
  81.       if (%title) {
  82.         .timerTheater.complete off
  83.         .timerTheater.off 1 3 unset %Theater.*
  84.         $iif(%chan,msg %chan,iecho)  $calc(%loop + 1) $+ . %title $+  $paren(%rating) - Release Date: %date - Score: %score $+ $chr(37) - Tomato Rating: %meter
  85.       }
  86.       inc %loop
  87.     }
  88.     jsonclose %name
  89.   }
  90.   elseif ($1 == top) {
  91.     var %name Theater.top
  92.     if ($json(%name)) .timerTheater.complete off
  93.  
  94.     var %loop 0
  95.     while (%loop < 10) {
  96.       var %title $json(%name,movies,%loop,title)
  97.       var %year $json(%name,movies,%loop,year)
  98.       var %rating $json(%name,movies,%loop,mpaa_rating)
  99.       var %critics $json(%name,movies,%loop,ratings,critics_score)
  100.       var %users $json(%name,movies,%loop,ratings,audience_score)
  101.       var %critics_meter $json(%name,movies,%loop,ratings,critics_rating)
  102.       var %user_meter $json(%name,movies,%loop,ratings,audience_rating)
  103.       var %meter $iif(%critics_meter,%critics_meter,None) / $iif(%user_meter,%user_meter,None)
  104.       var %score $calc($calc(%critics + %users) / 2)
  105.       var %imdb $json(%name,movies,%loop,alternate_ids,imdb)
  106.  
  107.       if (%title) {
  108.         .timerTheater.complete off
  109.         .timerTheater.off 1 3 unset %Theater.*
  110.         $iif(%chan,msg %chan,iecho)  $calc(%loop + 1) $+ . %title $+  $paren(%rating) - Score: %score $+ $chr(37) - Tomato Rating: %meter
  111.       }
  112.       inc %loop
  113.     }
  114.     jsonclose %name
  115.   }
  116. }
  117. alias -l paren {
  118.   if ($3) return $2 $+ $1 $+ $3
  119.   elseif ($2) return $2 $+ $1 $+ $2
  120.   elseif ($1 != $null) return ( $+ $1- $+ )
  121. }
  122. ;http://hawkee.com/snippet/10194/
  123. alias -l JSONOpen {
  124.   var %switches = -
  125.   if (-* iswm $1) {
  126.     %switches = $1
  127.     tokenize 32 $2-
  128.   }
  129.   var %com = JSONHandler:: $+ $1, %error, %file, %rem
  130.   var %init = function init(a,b){errortext="";data="";url=b ? b : "";method="GET";headers=[];parsedJSON={};status=a;fso=new ActiveXObject("Scripting.FileSystemObject")}
  131.   var %read = function readFile(filename){var ado=new ActiveXObject("ADODB.Stream");ado.CharSet="utf-8";ado.Open();ado.LoadFromFile(filename);if(!ado.EOF){data=ado.ReadText();}ado.close()}
  132.   var %json = "object"!==typeof JSON&&(JSON={});(function(){function m(a){return 10>a?"0"+a:a}function t(a){p.lastIndex=0;return p.test(a)?'"'+a.replace(p,function(a){var c=u[a];return"string"===typeof c?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function q(a,l){var c,d,h,r,g=e,f,b=l[a];b&&"object"===typeof b&&"function"===typeof b.toJSON&&(b=b.toJSON(a));"function"===typeof k&&(b=k.call(l,a,b));switch(typeof b){case "string":return t(b);case "number":return isFinite(b)?String(b):"null";case "boolean":case "null":return String(b);case "object":if(!b)return"null";e+=n;f=[];if("[object Array]"===Object.prototype.toString.apply(b)){r=b.length;for(c=0;c<r;c+=1)f[c]=q(c,b)||"null";h=0===f.length?"[]":e?"[\n"+e+f.join(",\n"+e)+"\n"+g+"]":"["+f.join(",")+"]";e=g;return h}if(k&&"object"===typeof k)for(r=k.length,c=0;c<r;c+=1)"string"===typeof k[c]&&(d=k[c],(h=q(d,b))&&f.push(t(d)+(e?": ":":")+h));else for(d in b)Object.prototype.hasOwnProperty.call(b,d)&&(h=q(d,b))&&f.push(t(d)+(e?": ":":")+h);h=0===f.length?"{}":e?"{\n"+e+f.join(",\n"+e)+"\n"+g+"}":"{"+f.join(",")+"}";e=g;return h}}"function"!==typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+m(this.getUTCMonth()+1)+"-"+m(this.getUTCDate())+"T"+m(this.getUTCHours())+":"+m(this.getUTCMinutes())+":"+m(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var s,p,e,n,u,k;"function"!==typeof JSON.stringify&&(p=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,u={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},JSON.stringify=function(a,l,c){var d;n=e="";if("number"===typeof c)for(d=0;d<c;d+=1)n+=" ";else"string"===typeof c&&(n=c);if((k=l)&&"function"!==typeof l&&("object"!==typeof l||"number"!==typeof l.length))throw Error("JSON.stringify");return q("",{"":a})});"function"!==typeof JSON.parse&&(s=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,JSON.parse=function(a,e){function c(a,d){var g,f,b=a[d];if(b&&"object"===typeof b)for(g in b)Object.prototype.hasOwnProperty.call(b,g)&&(f=c(b,g),void 0!==f?b[g]=f:delete b[g]);return e.call(a,d,b)}var d;a=String(a);s.lastIndex=0;s.test(a)&&(a=a.replace(s,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return d=eval("("+a+")"),"function"===typeof e?c({"":d},""):d;throw new SyntaxError("JSON.parse");})})();
  133.   var %xhr = function xhr(){var a,b=['MSXML2.XMLHTTP.6.0','MSXML2.XMLHTTP.3.0','Microsoft.XMLHTTP'],c;for(a=0;a<b.length;a++){try{c=new ActiveXObject(b[a]);break}catch(e){}}if(typeof c==="undefined"){errortext = "Unable to locate an XMLHTTP object for use"}else{c.open(method,url,false);for(a=0;a<headers.length;a++){c.setRequestHeader(headers[a][0],headers[a][1])}c.send(data);if(c.status!==200){errortext="Unable to retrieve data - Server Error: " + c.status}else{status="Parsed";try{parsedJSON=JSON.parse(c.responseText)}catch(ee){errortext="Unable to parse Retrieved Data"}}}}
  134.   if (!$regex(%switches, /^-[ufbwd]*$/)) {
  135.     %error = Invalid switches specified
  136.   }
  137.   elseif ($regex(%switches, /([ufbwd])\1/)) {
  138.     %error = Duplicate switch specified ( $+ $regml(1) $+ )
  139.   }
  140.   elseif ($regex(%switches, /([ufb])/g) > 1) {
  141.     %error = Conflicting switches specified (- $+ $regml(1) $+ , - $+ $regml(2) $+ $iif($regml(3), $chr(44) - $+ $v1) $+ )
  142.   }
  143.   elseif (w isin %switches && u !isin %switches) {
  144.     %error = Invalid switch (-w is only for use with -u)
  145.   }
  146.   elseif ($0 < 2) {
  147.     %error = Required parameters missing
  148.   }
  149.   elseif (!$regex($1,/^[a-z\d_.-]+$/i)) {
  150.     %error = Invalid name specified (Can only contant letters, numbers, _, ., and -)
  151.   }
  152.   elseif ($com(%com)) {
  153.     %error = Specified name in use
  154.   }
  155.   elseif (u isin %switches && $0 > 2) {
  156.     %error = Invalid URL specified. (Contains Spaces: $2-)
  157.   }
  158.   elseif (f isin %switches && !$isfile($2-)) {
  159.     %error = File not found: $2-
  160.   }
  161.   elseif (b isin %switches && &* !iswm $2) {
  162.     %error = Invalid binary variable specified (No '&' Prefix)
  163.   }
  164.   elseif (b isin %switches && $0 > 2) {
  165.     %error = Invalid binary variable specified (Contains Spaces: $2-)
  166.   }
  167.   elseif (b isin %switches && $bvar($2, 0) < 1) {
  168.     %error = Invalid binary variable specified (No content)
  169.   }
  170.   elseif (!$JSON::ComOpen(%com, MSScriptControl.ScriptControl) || $comerr) {
  171.     %error = Unable to create an instance of MSScriptControl.ScriptControl
  172.   }
  173.   elseif (!$com(%com, language, 4, bstr, jscript) || $comerr) {
  174.     %error = Unable to set ScriptControl's language to Javascript
  175.   }
  176.   elseif (!$com(%com, addcode, 1, bstr, %init) || $comerr) {
  177.     %error = Unable to add init() to ScriptControl
  178.   }
  179.   elseif (!$com(%com, addcode, 1, bstr, %xhr) || $comerr) {
  180.     %error = Unable to add xhr() to ScriptControl
  181.   }
  182.   elseif (!$com(%com, addcode, 1, bstr, %read) || $comerr) {
  183.     %error = Unable to add readFile() to ScriptControl
  184.   }
  185.   elseif (!$com(%com, ExecuteStatement, 1, bstr, %JSON) || $comerr) {
  186.     %error = Unable to Initalize the JSON parser object
  187.   }
  188.   elseif (!$com(%com, ExecuteStatement, 1, bstr, $iif(u isin %switches, $+(init,$chr(40), "XHR", $chr(44), $qt($JSON::Escape($2)),$chr(41)), $+(init,$chr(40), "Parsed", $chr(44), "", $chr(41)))) || $comerr) {
  189.     %error = Unable to initalize variables for ScriptControl
  190.   }
  191.   else {
  192.     if (u isin %switches) {
  193.       if (w !isin %switches) {
  194.         var %i = $com(%com, ExecuteStatement, 1, bstr, $+(xhr,$chr(40),$chr(41)))
  195.         if (!%i || $comerr) {
  196.           %error = Unable to retrieve data from $2 :: $com(%com).error :: $com(%com).errortext
  197.         }
  198.         elseif (!$com(%com, eval, 1, bstr, errortext) || $com(%com).result) {
  199.           %error = Unable to retrieve data $+ $iif($v1,: $v1,)
  200.         }
  201.       }
  202.     }
  203.     else {
  204.       %file = $JSON::File($1)
  205.       if (f isin %switches) {
  206.         %file = $longfn($2)
  207.       }
  208.       elseif (b isin %switches) {
  209.         bwrite $qt(%file) 0 -1 $2
  210.         %rem = $true
  211.       }
  212.       else {
  213.         write -n $qt(%file) $2-
  214.         %rem = $true
  215.       }
  216.       if (!$com(%com, ExecuteStatement, 1, bstr, $JSON::Funct(readFile, $qt($JSON::Escape(%file)))) || $comerr) {
  217.         %error = Unable to read contents of data-passing file
  218.       }
  219.       elseif (!$com(%com, ExecuteStatement, 1, bstr, $JSON::Funct(parsedJSON=JSON.parse,data)) || $comerr) {
  220.         %error = Unable to parse data into valid JSON
  221.       }
  222.     }
  223.     if (d isin %switches) {
  224.       $+(.timer,%com) 1 0 JSONClose $1
  225.     }
  226.   }
  227.   :error
  228.   %error = $iif($error, $v1, %error)
  229.   if (%rem && %file && $isfile(%file)) {
  230.     .remove $qt(%file)
  231.   }
  232.   if (%error) {
  233.     if ($timer(%com)) { $+(.timer,%com) off }
  234.     if ($com(%com)) {
  235.       set -eu0 $+(%,%com,::error) %error
  236.       .comclose $v1
  237.     }
  238.     else {
  239.       set -eu0 %JSONError %error
  240.     }
  241.   }
  242. }
  243. alias -l JSONURLOption {
  244.   var %com = JSONHandler:: $+ $1, %error, %head, %value, %x = 2
  245.  
  246.   if (!$com(%com)) {
  247.     return
  248.   }
  249.   unset % [ $+ [ %com ] $+ ] ::error
  250.   if ($0 < 3) {
  251.     %error = Missing parameters
  252.   }
  253.   elseif (!$com(%com, eval, 1, bstr, status) || $com(%com).result != XHR) {
  254.     %error = HTTP Request already completed or wasn't specified
  255.   }
  256.   elseif ($2 == method) {
  257.     if (!$regex($3-, /^(?:GET|POST|PUT|DELETE)$/i)) {
  258.       %error = Invalid HTTP Request method Specified: $3-
  259.     }
  260.     elseif (!$com(%com, ExecuteStatement, 1, bstr, method=" $+ $3 $+ ") || $comerr) {
  261.       %error = Unable to set HTTP Request method
  262.     }
  263.   }
  264.   else {
  265.     if (!$com(%com, ExecuteStatement, 1, bstr, $JSON::Funct(headers.push,[ $+ $qt($JSON::Escape($2)), $qt($JSON::Escape($3-)) $+ ])) || $comerr) {
  266.       %error = Unable to set HTTP Header: %head $+ : $+ %value
  267.     }
  268.   }
  269.   :error
  270.   %error = $iif($error, $v1, %error)
  271.   if (%error) {
  272.     reseterror
  273.     set -e $+(%,%com,::Error) %error
  274.   }
  275. }
  276. alias -l JSONGet {
  277.   var %switches -
  278.   if (-* iswm $1) {
  279.     %switches = $1
  280.     tokenize 32 $2-
  281.   }
  282.   var %com = JSONHandler:: $+ $1
  283.   var %file = $JSON::File($1)
  284.   var %error
  285.   var %rem
  286.   if ($com(%com)) {
  287.     if ($com(%com, eval, 1, bstr, status) && $com(%com).result !== XHR) {
  288.       %error = HTTP Request already completed or wasn't specified
  289.     }
  290.     elseif (!$regex(%switches, /^-[bf]*$/)) {
  291.       %error = Invalid switches specified
  292.     }
  293.     elseif ($regex(%switches, /([bf])\1/)) {
  294.       %error = Duplicate switch specified ( $+ $regml(1) $+ )
  295.     }
  296.     elseif ($regex(%switches, /([bf])/g) > 1) {
  297.       %error = Conflicting switches specified (- $+ $regml(1) $+ , - $+ $regml(2) $+ )
  298.     }
  299.     elseif (b isin %switches && &* !iswm $2) {
  300.       %error = Invalid binary variable specified (No '&' Prefix)
  301.     }
  302.     elseif (b isin %switches && $0 > 2) {
  303.       %error = Invalid binary variable specified (Contains Spaces: $2-)
  304.     }
  305.     elseif (f isin %switches && !$isfile($2-)) {
  306.       %error = File not found: $2-
  307.     }
  308.     else {
  309.       if (b isin %switches && $bvar($2,0)) {
  310.         bwrite $qt(%file) 0 -1 $2
  311.         %rem = $true
  312.       }
  313.       elseif (f isin %switches) {
  314.         %file = $2-
  315.       }      
  316.       elseif ($2-) {
  317.         write -n $qt(%file) $2-
  318.         %rem = $true
  319.       }
  320.       %file = $longfn(%file)
  321.       if ($isfile(%file) && (!$com(%com, ExecuteStatement, 1, bstr, $JSON::Funct(readFile,$qt($JSON::Escape(%file)))) || $comerr)) {
  322.         %error = Unable to pass data to JSON Handler
  323.       }
  324.       elseif (!$com(%com, ExecuteStatement, 1, bstr, xhr $+ $chr(40) $+ $chr(41)) || $comerr) {
  325.         %error = Unable to retrieve data from specified URL :: $com(%com).error :: $com(%com).errortext    
  326.       }
  327.       elseif (!$com(%com, eval, 1, bstr, errortext) || $com(%com).result) {
  328.         %error = $v1
  329.       }
  330.       if (%rem && $isfile(%file)) { .remove %file }
  331.     }
  332.   }
  333.   :error
  334.   %error = $iif($error, $v1, %error)
  335.   if (%error) {
  336.     reseterror
  337.     set -eu0 $+(%,%com,::Error) %error
  338.   }
  339. }
  340. alias -l JSON {
  341.   var %com, %x = 1, %i = 0, %get = parsedJSON, %tok, %res
  342.   if ($regex($1,/^\d+$/) && $0 === 1) {
  343.     while ($com(%x)) {
  344.       if (JSONHandler::* iswm $v1) {
  345.         %com = $v2
  346.         inc %i
  347.         if (%i === $1) { return %com }
  348.       }
  349.       inc %x
  350.     }
  351.     return $iif($1 == 0, %i)
  352.   }
  353.   elseif ($regex($1, /^JSONHandler::CHILD::([^:]+)::(.*)$/)) {
  354.     %com = $regml(1)
  355.     %get = $regml(2)
  356.   }
  357.   else {
  358.     %com = JSONHandler:: $+ $1
  359.   }
  360.   if ($com(%com)) {
  361.     if ($0 == 1) {
  362.       if ($prop == isChild) {
  363.         return $iif($regex($1, /^JSONHandler::CHILD::([^:]+)::(.*)$/), $true, $false)
  364.       }
  365.       elseif ($prop == error) {
  366.         return $iif($(,$+(%,%com,::error)), $true,$false)
  367.       }
  368.       elseif ($prop == errortext) {
  369.         return $(,$+(%,%com,::error))
  370.       }
  371.       elseif ($com($1)) {
  372.         return $1
  373.       }
  374.     }
  375.     elseif (!$com(%com, eval, 1, bstr, status) || $com(%com).result != parsed) {
  376.       set -eu0 $+(%,%com,::error) JSON Handler waiting for HTTP Request
  377.     }
  378.     else {
  379.       %x = 2
  380.       while (%x <= $0) {
  381.         %tok = $(,$ $+ %x)
  382.         if (!$regex(%tok, /^\d+$/)) {
  383.           %tok = $qt($replace(%tok,\,\\,",\"))
  384.         }
  385.         %get = $+(%get,[,%tok,])
  386.         inc %x
  387.       }
  388.       if (!$com(%com, eval, 1, bstr, %get) || $comerr) {
  389.         set -e $+(%,%com,::error) Invalid Item|index specified
  390.       }
  391.       else {
  392.         %res = $com(%com).result
  393.         if (%res == [object]) {
  394.           return JSONHandler::CHILD:: $+ $1 $+ :: $+ %get
  395.         }
  396.         else {
  397.           return %res
  398.         }
  399.       }
  400.     }
  401.   }
  402. }
  403. alias -l JSONClose {
  404.   var %com = JSONHandler:: $+ $1
  405.   unset % [ $+ [ %com ] $+ ] ::*
  406.   if ($com(%com)) { .comclose $v1 }
  407.   if ($timer(%com)) { $+(.timer,%com) off }
  408. }
  409. alias -l JSONList {
  410.   var %x = 1, %i = 0
  411.   while ($com(%x)) {
  412.     if (JSONHandler::* iswm $v1) {
  413.       inc %i
  414.       echo $color(info text) -a * # $+ %i : $regsubex($v2, /^JSONHandler::/,)
  415.     }
  416.     inc %x
  417.   }
  418.   if (!%i) {
  419.     echo $color(info text) -a * No active JSON handlers
  420.   }  
  421. }
  422. on *:Start: unset %JSONHandler::*
  423. alias -l JSON::ComOpen { .comopen $1- | if ($com($1) && !$comerr) { return $true } | :error | reseterror | if ($com($1)) { .comclose $1 } }
  424. alias -l JSON::Escape { return $replace($1,\,\\,",\") }
  425. alias -l JSON::File { var %a = 1 | while ($isfile(JSON $+ $1 $+ %a $+ .json)) { inc %a } | return $+(JSON, $1, %a, .json) }
  426. alias -l JSON::Funct { var %a = $1 $+ $chr(40), %i = 1 | while (%i < $0) { inc %i | %a = $+(%a,$iif(%i > 2,$chr(44)),$(, $ $+ %i)) } | return %a $+ $chr(41) }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement