home *** CD-ROM | disk | FTP | other *** search
/ Champak 48 / cdrom_image.iso / Games / alex_trax.swf / scripts / __Packages / com / neodelight / flanix / Bin.as next >
Encoding:
Text File  |  2007-10-01  |  15.1 KB  |  433 lines

  1. class com.neodelight.flanix.Bin
  2. {
  3.    function Bin()
  4.    {
  5.       if(!_global.bin)
  6.       {
  7.          _global.bin = new Object();
  8.          _global.bin.dump = com.neodelight.std.XString.dump;
  9.          _global.bin.ls = function()
  10.          {
  11.             var _loc13_ = _global.console;
  12.             var _loc14_ = _loc13_.parameters;
  13.             var _loc4_ = _loc13_.flags;
  14.             var _loc8_ = "";
  15.             var _loc11_ = "";
  16.             var _loc6_ = 0;
  17.             while(_loc6_ < arguments.length)
  18.             {
  19.                if(String(arguments[_loc6_]).charAt(0) != "-")
  20.                {
  21.                   _loc11_ = arguments[_loc6_];
  22.                   break;
  23.                }
  24.                _loc6_ = _loc6_ + 1;
  25.             }
  26.             var _loc7_ = _loc13_.getObjectAtPath(_loc11_);
  27.             if(_loc4_.help)
  28.             {
  29.                _loc8_ += "Usage: ls [OPTIONS]\n";
  30.                _loc8_ += "List information about the current object\n";
  31.                _loc8_ += "  -a  display all items\n";
  32.                _loc8_ += "  -d  dump values of non-objects\n";
  33.                _loc8_ += "  -l  long format\n";
  34.                _loc8_ += "  -1  display only one item per line\n";
  35.                return _loc8_;
  36.             }
  37.             if(_loc4_.a)
  38.             {
  39.                _global.ASSetPropFlags(_loc7_.__proto__,null,6,true);
  40.                _global.ASSetPropFlags(_loc7_,null,6,true);
  41.             }
  42.             var _loc3_ = new Array();
  43.             for(_loc6_ in _loc7_)
  44.             {
  45.                switch(typeof _loc7_[_loc6_])
  46.                {
  47.                   case "movieclip":
  48.                      _loc3_.push("/" + _loc6_ + (!_loc4_.l ? " " : " [m] "));
  49.                      break;
  50.                   case "object":
  51.                      _loc3_.push("/" + _loc6_ + (!_loc4_.l ? " " : " [o] "));
  52.                      break;
  53.                   case "function":
  54.                      _loc3_.push(_loc6_ + (!_loc4_.l ? " " : " [f] "));
  55.                      break;
  56.                   case "string":
  57.                      _loc3_.push(_loc6_ + (!_loc4_.l ? " " : " [s] ") + (!_loc4_.d ? "" : "=\"" + _loc7_[_loc6_] + "\" "));
  58.                      break;
  59.                   case "undefined":
  60.                      _loc3_.push(_loc6_ + (!_loc4_.l ? " " : " [u] ") + (!_loc4_.d ? "" : "=undefined "));
  61.                      break;
  62.                   case "null":
  63.                      _loc3_.push(_loc6_ + (!_loc4_.l ? " " : " [0] ") + (!_loc4_.d ? "" : "=null "));
  64.                      break;
  65.                   case "boolean":
  66.                      _loc3_.push(_loc6_ + (!_loc4_.l ? " " : " [b] ") + (!_loc4_.d ? "" : "=" + _loc7_[_loc6_] + " "));
  67.                      break;
  68.                   case "number":
  69.                      _loc3_.push(_loc6_ + (!_loc4_.l ? " " : " [n] ") + (!_loc4_.d ? "" : "=" + _loc7_[_loc6_] + " "));
  70.                      break;
  71.                   default:
  72.                      _loc3_.push(_loc6_ + "_" + typeof _loc7_[_loc6_] + "_");
  73.                }
  74.             }
  75.             var _loc9_ = 0;
  76.             _loc6_ = 0;
  77.             while(_loc6_ < _loc3_.length)
  78.             {
  79.                _loc9_ = Math.max(_loc3_[_loc6_].length,_loc9_);
  80.                _loc6_ = _loc6_ + 1;
  81.             }
  82.             _loc3_.sort();
  83.             var _loc12_ = !(_loc4_["1"] || _loc4_.d) ? Math.floor(_loc13_.cols / (_loc9_ + 2)) : 1;
  84.             var _loc10_ = 0;
  85.             _loc8_ = "";
  86.             _loc6_ = 0;
  87.             while(_loc6_ < _loc3_.length)
  88.             {
  89.                _loc8_ += _loc3_[_loc6_];
  90.                var _loc5_ = 0;
  91.                while(_loc5_ < _loc9_ - _loc3_[_loc6_].length + 2)
  92.                {
  93.                   _loc8_ += " ";
  94.                   _loc5_ = _loc5_ + 1;
  95.                }
  96.                _loc10_ = _loc10_ + 1;
  97.                _loc10_ %= _loc12_;
  98.                if(_loc10_ == 0)
  99.                {
  100.                   _loc8_ += "\n";
  101.                }
  102.                _loc6_ = _loc6_ + 1;
  103.             }
  104.             return _loc8_;
  105.          };
  106.          _global.bin.cat = function()
  107.          {
  108.             var _loc3_ = "";
  109.             if(arguments.length == 0 || _global.console.flags.help)
  110.             {
  111.                _loc3_ = "Usage: cat [FILE]\nPrint contents of FILE or standard input";
  112.                _global.console.setExitCode(0);
  113.                return _loc3_;
  114.             }
  115.             var _loc5_ = _global.console.parameters;
  116.             var _loc6_ = _global.console;
  117.             if(!_loc5_[0] || _loc5_[0] == "/")
  118.             {
  119.                _loc6_.ram.CWD = "";
  120.                _loc5_[0] = "";
  121.             }
  122.             var _loc7_ = (_loc5_[0].substr(0,1) != "/" ? _loc6_.ram.CWD + "/" : "") + _loc5_[0];
  123.             var _loc4_ = _loc6_.getObjectAtPath(_loc7_);
  124.             if(_loc4_)
  125.             {
  126.                switch(typeof _loc4_)
  127.                {
  128.                   case "string":
  129.                   case "number":
  130.                   case "boolean":
  131.                      _loc3_ += String(_loc4_);
  132.                      break;
  133.                   case "object":
  134.                   case "function":
  135.                      _loc3_ += _global.bin.dump(_loc4_);
  136.                      break;
  137.                   default:
  138.                      _global.console.setExitCode(1);
  139.                      _loc3_ += "cat: bad type (" + typeof _loc4_ + ")";
  140.                }
  141.             }
  142.             else
  143.             {
  144.                _global.console.setExitCode(3);
  145.                _loc3_ = "cat: file not found";
  146.             }
  147.             return _loc3_;
  148.          };
  149.          _global.bin.clipcp = function()
  150.          {
  151.             var _loc2_ = "";
  152.             if(_global.console.flags.help)
  153.             {
  154.                _loc2_ = "Usage: clipcp ARG\nConverts ARG to a String and copies it to the clipboard.";
  155.             }
  156.             _global.console.setExitCode(0);
  157.             return _loc2_;
  158.          };
  159.          _global.bin.cls = function()
  160.          {
  161.             var _loc2_ = "";
  162.             if(_global.console.flags.help)
  163.             {
  164.                _loc2_ = "Usage: cls\nClear the console output window.";
  165.             }
  166.             else
  167.             {
  168.                _global.console.cls();
  169.             }
  170.             _global.console.setExitCode(0);
  171.             return _loc2_;
  172.          };
  173.          _global.bin.cd = function()
  174.          {
  175.             var _loc2_ = _global.console.parameters;
  176.             var _loc3_ = _global.console;
  177.             var _loc5_ = "";
  178.             if(_loc2_[0] == undefined || _loc2_[0] == "/")
  179.             {
  180.                _loc3_.ram.CWD = "";
  181.                _loc2_[0] = "";
  182.             }
  183.             var _loc6_ = (_loc2_[0].substr(0,1) != "/" ? _loc3_.ram.CWD + "/" : "") + _loc2_[0];
  184.             var _loc4_ = _loc3_.getObjectAtPath(_loc6_);
  185.             if(_loc4_)
  186.             {
  187.                switch(typeof _loc4_)
  188.                {
  189.                   case "object":
  190.                   case "array":
  191.                   case "movieclip":
  192.                   case "function":
  193.                      _global.console.setExitCode(0);
  194.                      _loc3_.ram.CWD = _loc6_;
  195.                      break;
  196.                   default:
  197.                      _global.console.setExitCode(1);
  198.                      _loc5_ += "not an object (" + typeof _loc4_ + ")";
  199.                }
  200.             }
  201.             else
  202.             {
  203.                _global.console.setExitCode(3);
  204.                _loc5_ += "path not found";
  205.             }
  206.             return _loc5_;
  207.          };
  208.          _global.bin.echo = function()
  209.          {
  210.             var _loc4_ = "";
  211.             var _loc3_ = 0;
  212.             while(_loc3_ < arguments.length)
  213.             {
  214.                if(_loc4_ != "")
  215.                {
  216.                   _loc4_ += " ";
  217.                }
  218.                _loc4_ += String(arguments[_loc3_]);
  219.                _loc3_ = _loc3_ + 1;
  220.             }
  221.             _global.console.setExitCode(0);
  222.             return _loc4_;
  223.          };
  224.          _global.bin.exit = function()
  225.          {
  226.             fscommand("quit");
  227.             _global.mdm.exit();
  228.          };
  229.          _global.bin["false"] = function()
  230.          {
  231.             return false;
  232.          };
  233.          _global.bin.fscommand = function()
  234.          {
  235.             getURL("FSCommand:" add arguments[0],arguments[1]);
  236.          };
  237.          _global.bin["get"] = function(path)
  238.          {
  239.             return _global.console.getObjectAtPath(path);
  240.          };
  241.          _global.bin.grep = function(needle, haystack)
  242.          {
  243.             var _loc4_ = "";
  244.             if(arguments.length < 1 || _global.console.flags.help)
  245.             {
  246.                _loc4_ = "Usage: grep [OPTION] .. PATTERN [FILE] ..\nSearch each line FILE or the standard input and output only lines containing PATTERN";
  247.                _global.console.setExitCode(0);
  248.                return _loc4_;
  249.             }
  250.             var _loc5_ = haystack.split("\n");
  251.             var _loc3_ = 0;
  252.             while(_loc3_ < _loc5_.length)
  253.             {
  254.                if(_loc5_[_loc3_].indexOf(needle) != -1)
  255.                {
  256.                   if(_loc4_ != "")
  257.                   {
  258.                      _loc4_ += "\n";
  259.                   }
  260.                   _loc4_ += _loc5_[_loc3_];
  261.                }
  262.                _loc3_ = _loc3_ + 1;
  263.             }
  264.             _global.console.setExitCode(0);
  265.             return _loc4_;
  266.          };
  267.          _global.bin.load = function(url, loadPoint)
  268.          {
  269.             var _loc7_ = "";
  270.             if(arguments.length != 2 && arguments.length != 1 || _global.console.flags.help)
  271.             {
  272.                _loc7_ += "Usage: load SOURCE [TARGET]\nLoads the external swf file SOURCE into TARGET.\nIf TARGET is not specified, a new movie clip will be created in the _root and used as TARGET.";
  273.                _global.console.setExitCode(0);
  274.                return _loc7_;
  275.             }
  276.             var _loc5_ = undefined;
  277.             if(loadPoint)
  278.             {
  279.                var _loc4_ = _global.console.getObjectAtPath(loadPoint);
  280.                if(!_loc4_)
  281.                {
  282.                   _global.console.stderr("load: object not found: " + loadPoint);
  283.                   _global.console.setExitCode(3);
  284.                   return undefined;
  285.                }
  286.                if(typeof _loc4_ != "movieclip")
  287.                {
  288.                   _global.console.stderr("load: target is not a movieclip (" + typeof _loc4_ + ")");
  289.                   _global.console.setExitCode(1);
  290.                   return undefined;
  291.                }
  292.                _loc5_ = MovieClip(_loc4_);
  293.             }
  294.             else
  295.             {
  296.                _loc5_ = _root.createEmptyMovieClip(com.neodelight.std.Unique.getKey(),_root.getNextHighestDepth());
  297.                loadPoint = "/_root" + _loc5_._target;
  298.             }
  299.             loadMovie(url,_loc5_);
  300.             _loc7_ += "load: loading " + url + " to " + loadPoint;
  301.             _global.console.setExitCode(0);
  302.          };
  303.          _global.bin.number = function()
  304.          {
  305.             return Number(arguments[0]);
  306.          };
  307.          _global.bin["set"] = function()
  308.          {
  309.             var _loc3_ = "";
  310.             if(_global.console.flags.help)
  311.             {
  312.                _loc3_ = "Usage: set [VAR = VALUE]\nWithout parameters: shows list of Flash-Console system variables. With parameters: set the value of a system variable.";
  313.                _global.console.setExitCode(0);
  314.                return _loc3_;
  315.             }
  316.             if(arguments.length == 0)
  317.             {
  318.                for(var _loc4_ in _global.console.ram)
  319.                {
  320.                   if(_loc3_ != "")
  321.                   {
  322.                      _loc3_ += "\n";
  323.                   }
  324.                   _loc3_ += _loc4_ + "=" + _global.console.ram[_loc4_];
  325.                }
  326.                return _loc3_;
  327.             }
  328.             if(arguments.length < 2 || arguments[1] != "=")
  329.             {
  330.                _global.console.stderr("set: syntax error\n");
  331.                _global.console.setExitCode(1);
  332.                return undefined;
  333.             }
  334.             _loc4_ = 2;
  335.             while(_loc4_ < arguments.length)
  336.             {
  337.                if(_loc3_ != "")
  338.                {
  339.                   _loc3_ += " ";
  340.                }
  341.                _loc3_ += String(arguments[_loc4_]);
  342.                _loc4_ = _loc4_ + 1;
  343.             }
  344.             var _loc5_ = String(arguments[0]);
  345.             _global.console.ram[_loc5_] = _loc3_;
  346.             return undefined;
  347.          };
  348.          _global.bin.sh = function(file)
  349.          {
  350.             if(!file)
  351.             {
  352.                return "";
  353.             }
  354.             var _loc2_ = _global.console.getObjectAtPath(file);
  355.             if(typeof _loc2_ != "string")
  356.             {
  357.                return "sh: not a script: " + file;
  358.             }
  359.             return _global.console.executeCommand(_loc2_);
  360.          };
  361.          _global.bin.syslog = function(id, log, errlvl)
  362.          {
  363.             var _loc5_ = "";
  364.             if(arguments.length == 0 || _global.console.flags.help)
  365.             {
  366.                _global.console.setExitCode(0);
  367.                _loc5_ = "Usage: syslog FACILITY MESSAGE [ERRORLEVEL]\nSend a message to the system logger. Messages are stored in /var/log/FACILITY.\nErrorlevels:\n1 - Normal log entry\n2 - Warning\n3 - Critical Error";
  368.                return _loc5_;
  369.             }
  370.             if(!_global["var"].log[id])
  371.             {
  372.                _global["var"].log[id] = log + "\n";
  373.             }
  374.             else
  375.             {
  376.                _global["var"].log[id] += log + "\n";
  377.             }
  378.             switch(errlvl)
  379.             {
  380.                case 1:
  381.                   _global.console.stdout("#INFO:" + id + ":" + log);
  382.                   break;
  383.                case 2:
  384.                   _global.bin.syslog("WARNING",id + ": " + log);
  385.                   _global.console.stderr("#WARNING:" + id + ":" + log);
  386.                   break;
  387.                case 3:
  388.                   _global.bin.syslog("ERROR",id + ": " + log);
  389.                   _global.console.stderr("#ERROR:" + id + ":" + log);
  390.             }
  391.             _global.console.setExitCode(0);
  392.             return _loc5_;
  393.          };
  394.          _global.bin.test = function()
  395.          {
  396.             trace("detect: " + _global.id + " / " + _root.id + " / " + _level0.id + " / " + _level1.id);
  397.          };
  398.          _global.bin["true"] = function()
  399.          {
  400.             return true;
  401.          };
  402.       }
  403.    }
  404.    static function mtascTrace(msg, cls, fil, lin)
  405.    {
  406.       var _loc4_ = 0;
  407.       if(msg.substr(0,3) == "!!!")
  408.       {
  409.          _loc4_ = 3;
  410.       }
  411.       else if(msg.substr(0,2) == "!!")
  412.       {
  413.          _loc4_ = 2;
  414.       }
  415.       else if(msg.substr(0,1) == "!")
  416.       {
  417.          _loc4_ = 1;
  418.       }
  419.       else if(msg.substr(0,1) == "&")
  420.       {
  421.          _global.console.stdout(msg);
  422.          return undefined;
  423.       }
  424.       var _loc2_ = String(cls.split("::")[0]).split(".");
  425.       while(_loc2_.length > 2)
  426.       {
  427.          _loc2_.shift();
  428.       }
  429.       var _loc5_ = getTimer();
  430.       _global.bin.syslog(_loc2_.join("."),"[" + _loc5_ + ":" + cls.split("::")[1] + ":" + lin + "] " + msg,_loc4_);
  431.    }
  432. }
  433.