Changeset 2843 -- 2012-01-02 17:55:59
- Author
よや
- Comment
- getUIBits と setUIBits のサンプルスクリプト
Diffs
IO_Bit/trunk/sample/iobit_put.php
@@ -0,0 +1,19 @@
+<?php
+
+require_once 'IO/Bit.php';
+
+if ($argc < 2) {
+ echo "Usage: php iobit_put.php <width>:<value> [<width2>:<value2> [...]]".PHP_EOL;
+ echo "ex) php iobit_put.php 1:0 2:1 3:7 4:0 5:31 6:46 7:6 8:135".PHP_EOL;
+ exit(1);
+}
+
+$iobit = new IO_Bit();
+foreach (array_slice($argv, 1) as $arg) {
+ list($width, $value) = explode(':', $arg);
+ $value = $iobit->putUIBits($value, $width);
+}
+echo $iobit->output();
+
+
+
属性に変更があったパス: IO_Bit/trunk/sample/iobit_put.php
___________________________________________________________________
追加: svn:keywords
+ Id
追加: svn:eol-style
+ native
IO_Bit/trunk/sample/iobit_get.php
@@ -0,0 +1,32 @@
+<?php
+
+require_once 'IO/Bit.php';
+
+function usage() {
+ echo "Usage: php iobit_get.php <filename> <width> [<width2> [...]]".PHP_EOL;
+ echo "ex) php iobit_get.php iobit_get.php 1 2 3 4 5 6 7 8".PHP_EOL;
+
+}
+if ($argc < 2) {
+ usage();
+ exit(1);
+}
+
+$filename = $argv[1];
+if ($filename === '-') {
+ $filename = 'php://stdin';
+} else {
+ if (is_readable($filename) === false) {
+ usage();
+ exit(1);
+ }
+}
+
+$iobit = new IO_Bit();
+$filedata = file_get_contents($filename);
+$iobit->input($filedata);
+foreach (array_slice($argv, 2) as $arg) {
+ $value = $iobit->getUIBits($arg);
+ echo "$arg:$value ";
+}
+echo PHP_EOL;
属性に変更があったパス: IO_Bit/trunk/sample/iobit_get.php
___________________________________________________________________
追加: svn:keywords
+ Id
追加: svn:eol-style
+ native