2012-03-01から1ヶ月間の記事一覧

JScript ユーザーズ ガイド、オブジェクトの作成にプロトタイプを使う

まんま function Circle(xPoint, yPoint, radius) { this.x = xPoint; this.y = yPoint; this.r = radius; } var aCircle = new Circle(5, 11, 99); Circle.prototype.pi = Math.PI; function ACirclesArea () { return this.pi * this.r * this.r; } Circle…

JScript ユーザーズ ガイド、高度なオブジェクト作成

まんま var myObject = new Object(); var myBirthday = new Date(1961, 5, 10); まんま function Circle (xPoint, yPoint, radius) { this.x = xPoint; this.y = yPoint; this.r = radius; } var aCircle = new Circle(5, 11, 99);

JScript ユーザーズ ガイド、定義にメソッドを含める

まんま function pasta(grain, width, shape, hasEgg) { this.grain = grain; this.width = width; this.shape = shape; this.hasEgg = hasEgg; this.toString = pastaToString; } function pastaToString() { return "穀類: " + this.grain + "\n" + "幅: "…

JScript ユーザーズ ガイド、独自のオブジェクトの作成

まんま function pasta(grain, width, shape, hasEgg) { this.grain = grain; this.width = width; this.shape = shape; this.hasEgg = hasEgg; } var spaghetti = new pasta("wheat", 0.2, "circle", true); var linguine = new pasta("wheat", 0.3, "oval"…

JScript ユーザーズ ガイド、JScript のオブジェクト、多次元配列のようなこと

ary = []; ary[0] = []; ary[0][0] = []; ary[0][0][0] = 1; ary[0][0][1] = 2; ary[0][1] = []; ary[0][1][0] = 10; ary[0][1][1] = 20; ary[0][1][2] = 30; ary[1] = []; ary[1][0] = 100; for (x in ary) { if (ary[x] instanceof Array) { for (xx in ar…

JScript ユーザーズ ガイド、JScript のオブジェクト、配列はオブジェクトでもある

ほぼ、まんま var myArray = new Array(3); myArray[0] = "Hello"; myArray[1] = 42; myArray[2] = new Date(2000, 1, 1); WScript.Echo(myArray.length); myArray.expando = "JScript!"; myArray["another Expando"] = "Windows"; WScript.Echo(myArray.len…

JScript ユーザーズ ガイド、JScript のオブジェクトの拡張プロパティ

かなり、まんま var myObj = new Object(); myObj.name = "Fred"; myObj.age = 42; WScript.Echo(myObj); for (x in myObj) { WScript.Echo(x); } WScript.Echo(myObj["name"]); WScript.Echo(myObj["age"]); myObj["name"] = "FRED"; WScript.Echo(myObj["n…

JScript ユーザーズ ガイド、配列としてのオブジェクト

length の値を変更すると、縮小 ary = [1, 2, 3]; WScript.Echo(ary.length); ary.length = 2; for (x in ary) { WScript.Echo(ary[x]); } ary.length = 3; for (x in ary) { WScript.Echo(ary[x]); } 範囲外に代入すると、伸張 ary = [1, 2, 3]; WScript.Ec…

JScript ユーザーズ ガイド、JScript の関数

function foo() { WScript.Echo("foo"); } function foo(x, y) { WScript.Echo("FOO"); } foo(); 定義の括弧は必須のようだ 呼び出し側の括弧もないと関数呼び出しだと認識されないようだ 重複定義は、後で定義したものが有効っぽい 呼び出し側と定義側で関…

JScript ユーザーズ ガイド、JScript の関数、eval

WScript.Echo(eval("x = 1 + 2 * 3;")); WScript.Echo("x : " + x); なぜここで、eval の説明が出てくるんだろう?

JScript ユーザーズ ガイド、条件コンパイル変数

/*@cc_on @*/ WScript.Echo("@_win32 : " + @_win32); WScript.Echo("@_win16 : " + @_win16); WScript.Echo("@_mac : " + @_mac); WScript.Echo("@_alpha : " + @_alpha); WScript.Echo("@_x86 : " + @_x86); WScript.Echo("@_mc680x0 : " + @_mc680x0); WS…

JScript ユーザーズ ガイド、条件コンパイル

まんま /*@cc_on @*/ /*@if (@_jscript_version >= 4) WScript.Echo("JScript バージョン 4 以降です。"); @else @*/ WScript.Echo("最新のスクリプト エンジンが必要です。"); /*@end @*/ 「@set ステートメント」不明

JScript ユーザーズ ガイド、break ステートメントと continue ステートメント

i = 0 while (true) { i++; if (i == 1) continue; WScript.Echo(i); if (i == 2) break; }

JScript ユーザーズ ガイド、do...while ループ

i = 0 do { WScript.Echo(i); i++; } while (i < 3);

JScript ユーザーズ ガイド、while ループ

i = 0 while (i < 3) { WScript.Echo(i); i++; }

JScript ユーザーズ ガイド、for...in ループ

ary = [10, 20, 30]; for (x in ary) { WScript.Echo(x + " : " + ary[x]); } まんま var myObject = new Object(); myObject.name = "James"; myObject.age = "22"; myObject.phone = "555 1234"; for (prop in myObject) { WScript.Echo("プロパティ '" + …

JScript ユーザーズ ガイド、for ループ

for (i = 0; i < 2; i++) { WScript.Echo(i); }

JScript ユーザーズ ガイド、条件演算子

WScript.Echo(true ? "then" : "else"); WScript.Echo(false ? "then" : "else");

JScript ユーザーズ ガイド、条件ステートメント

if (true) { WScript.Echo("then"); } else { WScript.Echo("else"); }

JScript ユーザーズ ガイド、等価

まんま var string1 = "Hello"; var string2 = "Hello"; var StringObject1 = new String(string1); var StringObject2 = new String(string2); WScript.Echo(string1 == string2); // -1 WScript.Echo(StringObject1 == StringObject2); // 0 WScript.Echo(…

JScript ユーザーズ ガイド、new 演算子

WScript.Echo(new Object); WScript.Echo(new Object()); WScript.Echo(new Array()); WScript.Echo(new Date()); WScript.Echo(new Date("Jan 5 1996"));

JScript ユーザーズ ガイド、instanceof 演算子

WScript.Echo(new Array() instanceof Array); // -1 WScript.Echo(new Array() instanceof Object); // -1 WScript.Echo(new Array() instanceof Date); // 0 WScript.Echo(new Array() instanceof String); // 0

JScript ユーザーズ ガイド、void 演算子

WScript.Echo(void 1); WScript.Echo(typeof(void 1)); // undefined

JScript ユーザーズ ガイド、typeof 演算子

WScript.Echo(typeof 1); WScript.Echo(typeof(1)); WScript.Echo(typeof "1"); WScript.Echo(typeof true); WScript.Echo(typeof new String()); WScript.Echo(typeof function() {}); WScript.Echo(typeof x);

JScript ユーザーズ ガイド、delete 演算子

ary = [1,2,3] WScript.Echo(ary[0]); WScript.Echo(ary[1]); WScript.Echo(ary[2]); delete(ary[2]); WScript.Echo(ary[2]);

JScript ユーザーズ ガイド、右シフト

WScript.Echo(-1 >> 1); WScript.Echo(-1 >>> 1); // 符号なし

JScript ユーザーズ ガイド、識別演算子

WScript.Echo(1 == "1"); // -1 WScript.Echo(1 === "1"); // 0 WScript.Echo(1 != "1"); // 0 WScript.Echo(1 !== "1"); // -1 WScript.Echo(1 == "1"); // 0

JScript ユーザーズ ガイド、未定義(Undefined) 型

// WScript.Echo(x == undefined); WScript.Echo(typeof(x) == undefined); // 0 WScript.Echo(typeof(x) == "undefined"); // -1 WScript.Echo(String.prop); WScript.Echo(String.prop == null); // -1 WScript.Echo("prop" in String); // 0

JScript ユーザーズ ガイド、ブール型

var x; WScript.Echo(true); // -1 WScript.Echo(false); // 0 if (0) { WScript.Echo("0 then"); } else { WScript.Echo("0 else"); } if (null) { WScript.Echo("null then"); } else { WScript.Echo("null else"); } if (x) { WScript.Echo("undefined th…

JScript ユーザーズ ガイド、数値型

WScript.Echo(010); WScript.Echo(0x10); WScript.Echo(0xf); WScript.Echo(0xF); WScript.Echo(0.0001); WScript.Echo(.0001); WScript.Echo(1e-4); WScript.Echo(0378); // 378 WScript.Echo(0377); // 255 //WScript.Echo(00.0001); 「正の 0 および負の …