FUNCTION altClick(IE, alt, num = 1, fullMatchFlg = FALSE) DIM cnt = 0 IMG_LST = IE.document.Images IFB num = -1 THEN FOR n = 0 TO IMG_LST.length - 1 SELECT fullMatchFlg CASE TRUE IF IMG_LST.Item(n).Alt = alt THEN cnt = cnt + 1 CASE FALSE IF POS(alt, IMG_LST.Item(n).Alt) <> 0 THEN cnt = cnt + 1 SELEND NEXT RESULT = cnt ELSE DIM flg = FALSE FOR n = 0 TO IMG_LST.length - 1 SELECT fullMatchFlg CASE TRUE IFB IMG_LST.Item(n).Alt = alt THEN cnt = cnt + 1 IFB cnt = num THEN IMG_LST.Item(n).Click() flg = TRUE BREAK ENDIF ENDIF CASE FALSE IFB POS(alt, IMG_LST.Item(n).Alt) <> 0 THEN cnt = cnt + 1 IFB cnt = num THEN IMG_LST.Item(n).Click() flg = TRUE BREAK ENDIF ENDIF SELEND NEXT RESULT = flg ENDIF FEND FUNCTION ARABIC(str) DIM arr[][1] = "IV", "IIII", + _ "IX", "VIIII", + _ "XL", "XXXX", + _ "XC", "LXXXX", + _ "CD", "CCCC", + _ "CM", "DCCCC" DIM Roman[] = "I", "V", "X", "L", "C", "D", "M" DIM Arbic[] = 1, 5, 10, 50, 100, 500, 1000 FOR n = 0 TO UBound(arr) str = REPLACE(str, arr[n][0], arr[n][1]) NEXT DIM res = 0 FOR s = 1 TO LENGTH(str) FOR ss = UBound(Arbic) TO 0 STEP -1 IFB COPY(str, s, 1) = Roman[ss] THEN res = res + Arbic[ss] ENDIF NEXT NEXT IF res <= 0 OR res >= 4000 THEN res = -1 RESULT = res FEND FUNCTION arrayDiff(array1[], array2[]) DIM array[-1] FOR item1 IN array1 FOR item2 IN array2 IF item1 = item2 THEN CONTINUE 2 NEXT arrayPush(array, item1) NEXT RESULT = SLICE(array) FEND PROCEDURE arrayFilter(var array[], callback) DIM n = 0 DIM tmp[-1] FOR %val% IN array IFB EVAL(callback) THEN RESIZE(tmp, n) tmp[n] = %val% n = n + 1 ENDIF NEXT RESIZE(array, RESIZE(tmp)) FOR n = 0 TO RESIZE(tmp) array[n] = tmp[n] NEXT FEND PROCEDURE arrayFlip(Var associative[]) HASHTBL tmp FOR i = 0 TO LENGTH(associative)-1 tmp[associative[i, HASH_VAL]] = associative[i, HASH_KEY] NEXT associative = HASH_REMOVEALL FOR i = 0 TO LENGTH(tmp)-1 associative[tmp[i, HASH_KEY]] = tmp[i, HASH_VAL] NEXT FEND PROCEDURE arrayIntersect(var array1[], array2[]) DIM tmp[-1] FOR item1 IN array1 IF inArray(item1, array2) THEN arrayPush(tmp, item1) NEXT RESIZE(array1, UBound(tmp)) SETCLEAR(array1, EMPTY) FOR i = 0 TO UBound(tmp) array1[i] = tmp[i] NEXT FEND PROCEDURE arrayMap(callback, var array[]) DIM tmp[RESIZE(array)] DIM n = 0 FOR %val% IN array tmp[n] = EVAL(callback) n = n + 1 NEXT RESIZE(array, RESIZE(tmp)) FOR n = 0 TO RESIZE(tmp) array[n] = tmp[n] NEXT FEND FUNCTION arrayMerge(Var arr[], tmp[]) FOR n = 0 TO UBound(tmp) arrayPush(arr, tmp[n]) NEXT RESULT = UBound(arr) FEND PROCEDURE arrayPad(Var array[], size, value) DIM tmp[ABS(size) - (UBound(array) + 2)] SETCLEAR(tmp, value) IFB size > 0 THEN arrayMerge(array, tmp) ELSE arrayMerge(tmp, array) RESIZE(array, UBound(tmp)) SETCLEAR(array, EMPTY) FOR i = 0 TO UBound(tmp) array[i] = tmp[i] NEXT ENDIF FEND FUNCTION arrayPop(Var array[]) DIM n = UBound(array) DIM res = array[n] RESIZE(array, n-1) RESULT = res FEND FUNCTION arrayProduct(array[]) DIM res = 1 FOR item IN array res = res * item NEXT RESULT = res FEND FUNCTION arrayPush(var arr[], str) DIM res = RESIZE(arr, UBound(arr) + 1) arr[res] = str RESULT = res + 1 FEND FUNCTION arrayRand(array[]) RESULT = array[RANDOM(LENGTH(array))] FEND PROCEDURE arrayReverse(Var array[]) DIM cnt = LENGTH(array) FOR i = 0 TO INT(cnt / 2) - 1 swap(array[i], array[cnt-(i+1)]) NEXT FEND FUNCTION arrayRotate(array[], shift) IF shift < 0 THEN shift = LENGTH(array) + shift DIM array1 = arraySlice(array, shift) DIM array2 = arraySlice(array, 0, shift) arrayMerge(array1, array2) RESULT = array1 FEND FUNCTION arraySearch(needle, haystack[]) DIM i = 0 FOR item IN haystack IFB item = needle THEN RESULT = i EXIT ENDIF i = i + 1 NEXT FEND FUNCTION arrayShift(Var array[]) DIM res = array[0] SHIFTARRAY(array, -1) RESIZE(array, UBound(array) - 1) RESULT = res FEND FUNCTION arraySlice(array[], offset, length = NULL) SELECT TRUE CASE offset > 0 SHIFTARRAY(array, -1 * offset) IF length = NULL THEN length = LENGTH(array) - offset RESIZE(array, length - 1) CASE offset < 0 SHIFTARRAY(array, ABS(offset) - LENGTH(array)) RESIZE(array, LENGTH(array) - ABS(offset)) arrayFilter(array, "%val% <> EMPTY") IF length < 0 THEN RESIZE(array, RESIZE(array) + length) CASE offset = 0 IF length = NULL THEN length = LENGTH(array) RESIZE(array, length - 1) SELEND RESULT = SLICE(array) FEND FUNCTION arraySplice(Var array[], offset, len = NULL) DIM tmp[-1] IF len = NULL THEN len = UBound(array) IF len < 0 THEN len = len + UBound(array) FOR i = offset - 1 TO len - 1 arrayPush(tmp, array[i]) NEXT DIM tmp1[-1] FOR i = 0 TO offset - 1 arrayPush(tmp1, array[i]) NEXT DIM tmp2[-1] FOR i = offset + len TO UBound(array) arrayPush(tmp2, array[i]) NEXT arrayMerge(tmp1, tmp2) SETCLEAR(array) RESIZE(array, UBound(tmp1)) FOR i = 0 TO UBound(tmp1) array[i] = tmp1[i] NEXT RESULT = SLICE(tmp) FEND PROCEDURE arrayUnique(var arr[]) HASHTBL array FOR n = 0 TO UBound(arr) IF array[arr[n]] = TRUE THEN arr[n] = EMPTY ELSE array[arr[n]] = TRUE ENDIF NEXT FEND PROCEDURE arrayUnshift(var array[], value1 = EMPTY, value2 = EMPTY, value3 = EMPTY, value4 = EMPTY, value5 = EMPTY, value6 = EMPTY, value7 = EMPTY, value8 = EMPTY, value9 = EMPTY, value10 = EMPTY, value11 = EMPTY, value12 = EMPTY, value13 = EMPTY, value14 = EMPTY, value15 = EMPTY, value16 = EMPTY) DIM tmp[-1] FOR i = 1 TO 16 IF EVAL("value" + i) = EMPTY THEN BREAK arrayPush(tmp, EVAL("value" + i)) NEXT arrayMerge(tmp, array) RESIZE(array, UBound(tmp)) SETCLEAR(array, EMPTY) FOR i = 0 TO UBound(tmp) array[i] = tmp[i] NEXT FEND MODULE BABIGO HASHTBL babigo PROCEDURE BABIGO() DIM array[][1] = "あ,か,さ,た,な,は,ま,や,ら,わ,が,ざ,だ,ば,ぱ,ゃ,ぁ", "ば", _ "い,き,し,ち,に,ひ,み,り,ぎ,じ,ぢ,び,ぴ,ぃ", "び", _ "う,く,す,つ,ぬ,ふ,む,ゆ,る,ん,ぐ,ず,づ,ぶ,ぷ,ゅ,ぅ", "ぶ", _ "え,け,せ,て,ね,へ,め,れ,げ,ぜ,で,べ,ぺ,ぇ", "べ", _ "お,こ,そ,と,の,ほ,も,よ,ろ,ご,ぞ,ど,ぼ,ぽ,ょ,ぉ", "ぼ", _ "ア,カ,サ,タ,ナ,ハ,マ,ヤ,ラ,ワ,ガ,ザ,ダ,バ,パ,ャ,ァ", "バ", _ "イ,キ,シ,チ,ニ,ヒ,ミ,リ,ギ,ジ,ヂ,ビ,ピ,ィ", "ビ", _ "ウ,ク,ス,ツ,ヌ,フ,ム,ユ,ル,ン,グ,ズ,ヅ,ブ,プ,ュ,ゥ", "ブ", _ "エ,ケ,セ,テ,ネ,ヘ,メ,レ,ゲ,ゼ,デ,ベ,ペ,ェ", "ベ", _ "オ,コ,ソ,ト,ノ,ホ,モ,ヨ,ロ,ゴ,ゾ,ド,ボ,ポ,ョ,ォ", "ボ" FOR i = 0 TO RESIZE(array) FOR item IN SPLIT(array[i][0], ",") babigo[item] = item + array[i][1] NEXT NEXT FEND FUNCTION encode(str) DIM boin[] = "ぁ", "ぃ", "ぅ", "ぇ", "ぉ", "ァ", "ィ", "ゥ", "ェ", "ォ" DIM yoon[] = "ゃ", "ゅ", "ょ", "ャ", "ュ", "ョ" DIM sokuon[] = "っ", "ッ" DIM b[] = "ば", "び", "ぶ", "べ", "ぼ", "バ", "ビ", "ブ", "ベ", "ボ" DIM res = "" DIM tmp = "" WHILE str <> "" s = COPY(str, 2, 1) len = IIF(inArray(s, boin) OR inArray(s, yoon), 2, 1) tmp = COPY(str, 1, len) IFB LENGTH(tmp) = 1 THEN res = res + IIF(babigo[tmp, HASH_EXISTS], babigo[tmp], tmp) ELSE res = res + COPY(tmp, 1, 1) + babigo[COPY(tmp, 2, 1)] ENDIF IF COPY(res, LENGTH(res)) = "ー" THEN res = res + COPY(res, LENGTH(res)-1, 1) str = COPY(str, len + 1) WEND RESULT = res FEND FUNCTION decode(str) DIM boin[] = "ぁ", "ぃ", "ぅ", "ぇ", "ぉ", "ァ", "ィ", "ゥ", "ェ", "ォ" DIM yoon[] = "ゃ", "ゅ", "ょ", "ャ", "ュ", "ョ" DIM sokuon[] = "っ", "ッ" DIM b[] = "ば", "び", "ぶ", "べ", "ぼ", "バ", "ビ", "ブ", "ベ", "ボ" DIM res = "" WHILE str <> "" DIM tmp = COPY(str, 1, 1) DIM s = COPY(str, 2, 1) IFB inArray(s, b) THEN start = 3 ELSEIF inArray(s, boin) OR inArray(s, yoon) THEN start = 4 ELSEIF inArray(tmp, sokuon) THEN start = 2 ELSE start = 2 ENDIF res = res + tmp + IIF(inArray(s, boin) OR inArray(s, yoon), s, "") str = COPY(str, start) WEND RESULT = res FEND ENDMODULE MODULE Base64 DIM obj, element PROCEDURE Base64() obj = CREATEOLEOBJ("Microsoft.XMLDOM") element = obj.createElement("node") element.dataType = "bin.base64" FEND FUNCTION encodestr(str) element.nodeTypedValue = ENCODE(str, CODE_BYTEARRAY) RESULT = element.text FEND FUNCTION decodestr(str) element.text = str RESULT = DECODE(element.nodeTypedValue, CODE_BYTEARRAY) FEND ENDMODULE FUNCTION BGRToColor(b, g, r) RESULT = b * 65536 + g * 256 + r FEND FUNCTION binToDec(bin, signFlg = TRUE) DIM dec = 0 DIM decimalFlg = IIF(POS(".", bin), TRUE, FALSE) IFB COPY(bin, 1, 1) = "1" AND signFlg THEN // 負数 // ビット反転用の値 // 最上位ビット DIM msb = IIF(decimalFlg, POS(".", bin) - 1, LENGTH(bin)) // 最下位ビット DIM lsb = IIF(decimalFlg, POS(".", bin) - LENGTH(bin), 0) // 整数部 DIM dec2 = POWER(2, msb) - 1 // 小数部 FOR i = -1 TO lsb STEP -1 dec2 = dec2 + POWER(2, i) NEXT DIM a = binToDec(bin, FALSE) DIM b = dec2 dec = -1 * (bitXor(a, b) + POWER(2, lsb)) ELSE // 正数(先頭ビットが0、もしくは、signFlgがFalse) IFB decimalFlg THEN // 小数部分 DIM integer = COPY(bin, 1, POS(".", bin) - 1) DIM decimal = COPY(bin, POS(".", bin) + 1) FOR i = 1 TO LENGTH(decimal) dec = dec + COPY(decimal, i, 1) * POWER(2, -1 * i) NEXT ELSE integer = bin ENDIF // 整数部分 FOR i = 1 TO LENGTH(integer) dec = dec + COPY(integer, i, 1) * POWER(2, LENGTH(integer) - i) NEXT ENDIF RESULT = dec FEND FUNCTION binToHex(bin) HASHTBL bh bh["0000"] = "0"; bh["0001"] = "1"; bh["0010"] = "2"; bh["0011"] = "3"; bh["0100"] = "4"; bh["0101"] = "5"; bh["0110"] = "6"; bh["0111"] = "7"; bh["1000"] = "8"; bh["1001"] = "9"; bh["1010"] = "A"; bh["1011"] = "B"; bh["1100"] = "C"; bh["1101"] = "D"; bh["1110"] = "E"; bh["1111"] = "F"; // 小数ならば IFB POS(".", bin) <> 0 THEN DIM num = COPY(bin, 1, POS(".", bin) - 1) DIM frac = COPY(bin, POS(".", bin) + 1) num = strPad(num, CEIL(LENGTH(num) / 4) * 4, "0", LEFT) frac = strPad(frac, CEIL(LENGTH(frac) / 4) * 4, "0", RIGHT) DIM hex = "" FOR i = 1 TO LENGTH(num) STEP 4 hex = hex + bh[COPY(num, i, 4)] NEXT hex = hex + "." FOR i = 1 TO LENGTH(frac) STEP 4 hex = hex + bh[COPY(frac, i, 4)] NEXT RESULT = hex ELSE len = CEIL(LENGTH(bin) / 4) * 4 FOR i = 1 TO len - LENGTH(bin) bin = "0" + bin NEXT bin = REPLACE(FORMAT(bin, len), " ", "0") hex = "" FOR i = 1 TO LENGTH(bin) / 4 str = COPY(bin, i * 4 - 3, 4) hex = hex + bh[str] NEXT RESULT = hex ENDIF FEND FUNCTION bitAnd(arg1, arg2) DIM args[1] = arg1, arg2 DIM bins[1] DIM decimals[1] DIM integers[1] DIM keta[1] IFB ABS(arg1) <> arg1 OR ABS(arg2) <> arg2 THEN RESULT = ERR_VALUE EXIT ENDIF FOR i = 0 TO 1 bins[i] = decToBin(args[i]) decimals[i] = 0 IFB POS(".", bins[i]) <> 0 THEN integers[i] = COPY(bins[i], 1, POS(".", bins[i]) - 1) decimals[i] = COPY(bins[i], POS(".", bins[i]) + 1) ELSE integers[i] = bins[i] ENDIF NEXT keta[0] = IIF(LENGTH(integers[0]) > LENGTH(integers[1]), LENGTH(integers[0]), LENGTH(integers[1])) integers[0] = strPad(integers[0], keta[0], "0", LEFT) integers[1] = strPad(integers[1], keta[0], "0", LEFT) keta[1] = IIF(LENGTH(decimals[0]) > LENGTH(decimals[1]), LENGTH(decimals[0]), LENGTH(decimals[1])) decimals[0] = strPad(decimals[0], keta[1], "0", RIGHT) decimals[1] = strPad(decimals[1], keta[1], "0", RIGHT) DIM bin = "" FOR i = 1 TO keta[0] bin = bin + (VAL(COPY(integers[0], i, 1)) AND VAL(COPY(integers[1], i, 1))) NEXT bin = bin + "." FOR i = 1 TO keta[1] bin = bin + (VAL(COPY(decimals[0], i, 1)) AND VAL(COPY(decimals[1], i, 1))) NEXT RESULT = binToDec(bin) FEND FUNCTION bitOr(arg1, arg2) DIM args[1] = arg1, arg2 DIM bins[1] DIM decimals[1] DIM integers[1] DIM keta[1] IFB ABS(arg1) <> arg1 OR ABS(arg2) <> arg2 THEN RESULT = ERR_VALUE EXIT ENDIF FOR i = 0 TO 1 bins[i] = decToBin(args[i]) decimals[i] = 0 IFB POS(".", bins[i]) <> 0 THEN integers[i] = COPY(bins[i], 1, POS(".", bins[i]) - 1) decimals[i] = COPY(bins[i], POS(".", bins[i]) + 1) ELSE integers[i] = bins[i] ENDIF NEXT keta[0] = IIF(LENGTH(integers[0]) > LENGTH(integers[1]), LENGTH(integers[0]), LENGTH(integers[1])) integers[0] = strPad(integers[0], keta[0], "0", LEFT) integers[1] = strPad(integers[1], keta[0], "0", LEFT) keta[1] = IIF(LENGTH(decimals[0]) > LENGTH(decimals[1]), LENGTH(decimals[0]), LENGTH(decimals[1])) decimals[0] = strPad(decimals[0], keta[1], "0", RIGHT) decimals[1] = strPad(decimals[1], keta[1], "0", RIGHT) DIM bin = "" FOR i = 1 TO keta[0] bin = bin + (VAL(COPY(integers[0], i, 1)) OR VAL(COPY(integers[1], i, 1))) NEXT bin = bin + "." FOR i = 1 TO keta[1] bin = bin + (VAL(COPY(decimals[0], i, 1)) OR VAL(COPY(decimals[1], i, 1))) NEXT RESULT = binToDec(bin) FEND FUNCTION bitXor(arg1, arg2) DIM args[1] = arg1, arg2 DIM bins[1] DIM decimals[1] DIM integers[1] DIM keta[1] IFB ABS(arg1) <> arg1 OR ABS(arg2) <> arg2 THEN RESULT = ERR_VALUE EXIT ENDIF FOR i = 0 TO 1 bins[i] = decToBin(args[i]) decimals[i] = 0 IFB POS(".", bins[i]) <> 0 THEN integers[i] = COPY(bins[i], 1, POS(".", bins[i]) - 1) decimals[i] = COPY(bins[i], POS(".", bins[i]) + 1) ELSE integers[i] = bins[i] ENDIF NEXT keta[0] = IIF(LENGTH(integers[0]) > LENGTH(integers[1]), LENGTH(integers[0]), LENGTH(integers[1])) integers[0] = strPad(integers[0], keta[0], "0", LEFT) integers[1] = strPad(integers[1], keta[0], "0", LEFT) keta[1] = IIF(LENGTH(decimals[0]) > LENGTH(decimals[1]), LENGTH(decimals[0]), LENGTH(decimals[1])) decimals[0] = strPad(decimals[0], keta[1], "0", RIGHT) decimals[1] = strPad(decimals[1], keta[1], "0", RIGHT) DIM bin = "" FOR i = 1 TO keta[0] bin = bin + (VAL(COPY(integers[0], i, 1)) XOR VAL(COPY(integers[1], i, 1))) NEXT bin = bin + "." FOR i = 1 TO keta[1] bin = bin + (VAL(COPY(decimals[0], i, 1)) XOR VAL(COPY(decimals[1], i, 1))) NEXT RESULT = binToDec(bin) FEND PROCEDURE bogoSort(Var array[]) DIM num = UBound(array) REPEAT DIM flg = FALSE FisherYates(array) FOR n = 0 TO num - 1 IF array[n] > array[n+1] THEN flg = TRUE BREAK ENDIF NEXT SLEEP(0.001) UNTIL !flg FEND PROCEDURE bubbleSort(Var array[]) REPEAT DIM flg = FALSE FOR n = 0 TO UBound(array) - 1 IFB array[n] > array[n+1] THEN swap(array[n], array[n+1]) flg = TRUE ENDIF NEXT UNTIL !flg FEND PROCEDURE BusyWait(Var IE) SLEEP(0.500) DIM t = GETTIME() TRY REPEAT DIM tm = GETTIME() - t FUKIDASI("BusyWait:" + tm) SLEEP(0.010) IF tm >= 60 THEN BREAK UNTIL !IE.Busy AND IE.readyState = 4 EXCEPT IE = getIEObj(-1) PRINT IE.document.URL + " のIEオブジェクトを取得しました。" BusyWait(IE) ENDTRY FUKIDASI() FEND FUNCTION chuki(JD) JD = JD - 9/24 DIM t = (JD + 0.5 - 2451545) / 36525 DIM λsun = longitudeSun(t) DIM λsun0 = 30 * INT(λsun/30) REPEAT t = (JD + 0.5 - 2451545) / 36525 λsun = longitudeSun(t) DIM Δλ = λsun - λsun0 SELECT TRUE CASE Δλ > 180 Δλ = Δλ - 360 CASE Δλ < -180 Δλ = Δλ + 180 SELEND DIM Δt = Δλ * 365.2 / 360 JD = JD - Δt UNTIL Δt <= 1/86400 JD = JD + 9/24 DIM arr[1] = JD, λsun RESULT = SLICE(arr) FEND MODULE Cipher FUNCTION Caesar.encode(str, num = 3) DIM res = "" FOR n = 1 TO LENGTH(str) DIM s = COPY(str, n, 1) DIM ofs = "" DIM normalizedNumber = IIF(num >= 0, num MOD 26, INT(ABS(num / 26) + 1) * 26 + num) SELECT TRUE CASE ASC(s) >= ASC("A") AND ASC(s) <= ASC("Z") ofs = (ASC(s) - ASC("A") + normalizedNumber) MOD 26 res = res + CHR(ofs + ASC("A")) CASE ASC(s) >= ASC("a") AND ASC(s) <= ASC("z") ofs = (ASC(s) - ASC("a") + normalizedNumber) MOD 26 res = res + CHR(ofs + ASC("a")) DEFAULT res = res + s SELEND NEXT RESULT = res FEND FUNCTION Caesar.decode(str, num = 3) DIM res = "" FOR n = 1 TO LENGTH(str) DIM s = COPY(str, n, 1) DIM ofs = "" DIM normalizedNumber = IIF(num >= 0, num MOD 26, INT(ABS(num / 26) + 1) * 26 + num) SELECT TRUE CASE ASC(s) >= ASC("A") AND ASC(s) <= ASC("Z") ofs = (ASC(s) - ASC("A") - normalizedNumber + 26) MOD 26 res = res + CHR(ofs + ASC("A")) CASE ASC(s) >= ASC("a") AND ASC(s) <= ASC("z") ofs = (ASC(s) - ASC("a") - normalizedNumber + 26) MOD 26 res = res + CHR(ofs + ASC("a")) DEFAULT res = res + s SELEND NEXT RESULT = res FEND FUNCTION ROT13.encode(str) RESULT = Cipher.Caesar.encode(str, 13) FEND FUNCTION ROT13.decode(str) RESULT = Cipher.ROT13.encode(str) FEND FUNCTION Vigenere.encode(str, key) str = STRCONV(str, SC_LOWERCASE) key = STRCONV(key, SC_LOWERCASE) DIM res = "" DIM ofs = "" FOR n = 1 TO LENGTH(str) DIM s = COPY(str, n, 1) SELECT TRUE CASE ASC(s) >= ASC("a") AND ASC(s) <= ASC("z") DIM num = (n - 1) MOD LENGTH(key) + 1 ofs = ((ASC(s) - ASC("a")) + (ASC(COPY(key, num, 1)) - ASC("a")) + 26) MOD 26 res = res + CHR(ofs + ASC("a")) DEFAULT res = res + s SELEND NEXT RESULT = res FEND FUNCTION Vigenere.decode(str, key) str = STRCONV(str, SC_LOWERCASE) key = STRCONV(key, SC_LOWERCASE) DIM res = "" DIM ofs = "" FOR n = 1 TO LENGTH(str) DIM s = COPY(str, n, 1) SELECT TRUE CASE ASC(s) >= ASC("a") AND ASC(s) <= ASC("z") DIM num = (n - 1) MOD LENGTH(key) + 1 ofs = ((ASC(s) - ASC("a")) - (ASC(COPY(key, num, 1)) - ASC("a")) + 26) MOD 26 res = res + CHR(ofs + ASC("a")) DEFAULT res = res + s SELEND NEXT RESULT = res FEND FUNCTION XOR.encode(str, key) DIM res = "" FOR n = 1 TO LENGTH(str) DIM num = (n - 1) MOD LENGTH(key) + 1 DIM a = ASC(COPY(str, n, 1)) DIM b = ASC(COPY(key, num, 1)) res = res + "" + REPLACE(FORMAT(VARTYPE(decToBin(a XOR b), VAR_INTEGER), 8), " ", "0") NEXT RESULT = res FEND FUNCTION XOR.decode(str, key) DIM res = "" FOR n = 1 TO LENGTH(str) / 8 DIM num = (n - 1) MOD LENGTH(key) + 1 DIM a = binToDec(COPY(str, n * 8 - 7, 8)) DIM b = ASC(COPY(key, num, 1)) res = res + CHR(a XOR b) NEXT RESULT = res FEND ENDMODULE FUNCTION Collatz(num) IFB !reTest(num, "\d+") THEN RESULT = ERR_VALUE EXIT ENDIF DIM array[-1] arrayPush(array, num) WHILE num <> 1 num = IIF(num MOD 2 = 0, num / 2, num * 3 + 1) arrayPush(array, num) WEND RESULT = SLICE(array) FEND FUNCTION colorToBGR(color) DIM array[2] array[0] = (color AND $FF0000) / $10000 array[1] = (color AND $FF00) / $100 array[2] = color AND $FF RESULT = SLICE(array) FEND FUNCTION colorToRGB(color) DIM array[2] array[0] = color AND $FF array[1] = (color AND $FF00) / $100 array[2] = (color AND $FF0000) / $10000 RESULT = SLICE(array) FEND PROCEDURE combSort(Var array[]) DIM num = UBound(array) DIM h = num DIM flg = FALSE WHILE h > 1 OR flg IF h > 1 THEN h = INT(h / 1.3) flg = FALSE FOR n = 0 TO num - h IFB array[n] > array[n+h] THEN swap(array[n], array[n+h]) flg = TRUE ENDIF NEXT WEND FEND FUNCTION complementaryColor(color) DIM array = colorToRGB(color) DIM num = CALCARRAY(array, CALC_MAX) + CALCARRAY(array, CALC_MIN) arrayMap(num + " - %val%", array) RESULT = RGBToColor(array[0], array[1], array[2]) FEND FUNCTION convert(num, before, after) HASHTBL unit // 重量 unit["g,sg"] = "num * 6.85217658567918 * POWER(10, -5)" unit["g,lbm"] = "num * 2.20462262184878 * POWER(10, -3)" unit["g,u"] = "num * 6.02217 * POWER(10, +23)" unit["g,ozm"] = "num * 3.52739619495804 * POWER(10, -2)" unit["sg,g"] = "num * 1.45939029372064 * POWER(10, +4)" unit["sg,lbm"] = "num * 3.21740485564304 * POWER(10, +1)" unit["sg,u"] = "num * 8.78869644513561 * POWER(10, +27)" unit["sg,ozm"] = "num * 5.14784776902887 * POWER(10, +2)" unit["lbm,g"] = "num * 4.5359237 * POWER(10, +2)" unit["lbm,sg"] = "num * 3.10809501715673 * POWER(10, -2)" unit["lbm,u"] = "num * 2.7316103628429 * POWER(10, +26)" unit["lbm,ozm"] = "num * 1.6 * POWER(10, +1)" unit["u,g"] = "num * 1.66053100460465 * POWER(10, -24)" unit["u,sg"] = "num * 1.13782516695463 * POWER(10, -28)" unit["u,lbm"] = "num * 3.66084421703269 * POWER(10, -27)" unit["u,ozm"] = "num * 5.8573507472523 * POWER(10, -26)" unit["ozm,g"] = "num * 2.8349523125 * POWER(10, +1)" unit["ozm,sg"] = "num * 1.94255938572295 * POWER(10, -3)" unit["ozm,lbm"] = "num * 6.25 * POWER(10, -2)" unit["ozm,u"] = "num * 1.70725647677681 * POWER(10, +25)" // 距離 unit["m,mi"] = "num * 6.21371192237334 * POWER(10, -4)" unit["m,Nmi"] = "num * 5.39956803455724 * POWER(10, -4)" unit["m,in"] = "num * 3.93700787401575 * POWER(10, +1)" unit["m,ft"] = "num * 3.28083989501312 * POWER(10, +0)" unit["m,yd"] = "num * 1.09361329833771 * POWER(10, +0)" unit["m,ang"] = "num * 1 * POWER(10, +10)" unit["m,pica"] = "num * 2.36220472440945 * POWER(10, +2)" unit["mi,m"] = "num * 1.609344 * POWER(10, +3)" unit["mi,Nmi"] = "num * 8.68976241900648 * POWER(10, -1)" unit["mi,in"] = "num * 6.336 * POWER(10, +4)" unit["mi,ft"] = "num * 5.28 * POWER(10, +3)" unit["mi,yd"] = "num * 1.76 * POWER(10, +3)" unit["mi,ang"] = "num * 1.609344 * POWER(10, +13)" unit["mi,pica"] = "num * 3.8016 * POWER(10, +5)" unit["Nmi,m"] = "num * 1.852 * POWER(10, +3)" unit["Nmi,mi"] = "num * 1.15077944802354 * POWER(10, +0)" unit["Nmi,in"] = "num * 7.29133858267717 * POWER(10, +4)" unit["Nmi,ft"] = "num * 6.0761154855643 * POWER(10, +3)" unit["Nmi,yd"] = "num * 2.02537182852143 * POWER(10, +3)" unit["Nmi,ang"] = "num * 1.852 * POWER(10, +13)" unit["Nmi,pica"] = "num * 4.3748031496063 * POWER(10, +5)" unit["in,m"] = "num * 2.54 * POWER(10, -2)" unit["in,mi"] = "num * 1.57828282828283 * POWER(10, -5)" unit["in,Nmi"] = "num * 1.37149028077754 * POWER(10, -5)" unit["in,ft"] = "num * 8.33333333333333 * POWER(10, -2)" unit["in,yd"] = "num * 2.77777777777778 * POWER(10, -2)" unit["in,ang"] = "num * 2.54 * POWER(10, +8)" unit["in,pica"] = "num * 6 * POWER(10, +0)" unit["ft,m"] = "num * 3.048 * POWER(10, -1)" unit["ft,mi"] = "num * 1.89393939393939 * POWER(10, -4)" unit["ft,Nmi"] = "num * 1.64578833693305 * POWER(10, -4)" unit["ft,in"] = "num * 1.2 * POWER(10, +1)" unit["ft,yd"] = "num * 3.33333333333333 * POWER(10, -1)" unit["ft,ang"] = "num * 3.048 * POWER(10, +9)" unit["ft,pica"] = "num * 7.2 * POWER(10, +1)" unit["yd,m"] = "num * 9.144 * POWER(10, -1)" unit["yd,mi"] = "num * 5.68181818181818 * POWER(10, -4)" unit["yd,Nmi"] = "num * 4.93736501079914 * POWER(10, -4)" unit["yd,in"] = "num * 3.6 * POWER(10, +1)" unit["yd,ft"] = "num * 3 * POWER(10, +0)" unit["yd,ang"] = "num * 9.144 * POWER(10, +9)" unit["yd,pica"] = "num * 2.16 * POWER(10, +2)" unit["ang,m"] = "num * 1 * POWER(10, -10)" unit["ang,mi"] = "num * 6.21371192237334 * POWER(10, -14)" unit["ang,Nmi"] = "num * 5.39956803455724 * POWER(10, -14)" unit["ang,in"] = "num * 3.93700787401575 * POWER(10, -9)" unit["ang,ft"] = "num * 3.28083989501312 * POWER(10, -10)" unit["ang,yd"] = "num * 1.09361329833771 * POWER(10, -10)" unit["ang,pica"] = "num * 2.36220472440945 * POWER(10, -8)" unit["pica,m"] = "num * 4.23333333333333 * POWER(10, -3)" unit["pica,mi"] = "num * 2.63047138047138 * POWER(10, -6)" unit["pica,Nmi"] = "num * 2.28581713462923 * POWER(10, -6)" unit["pica,in"] = "num * 1.66666666666667 * POWER(10, -1)" unit["pica,ft"] = "num * 1.38888888888889 * POWER(10, -2)" unit["pica,yd"] = "num * 4.62962962962963 * POWER(10, -3)" unit["pica,ang"] = "num * 4.23333333333333 * POWER(10, +7)" // 時間 unit["yr,day"] = "num * 3.6525 * POWER(10, +2)" unit["yr,hr"] = "num * 8.766 * POWER(10, +3)" unit["yr,mn"] = "num * 5.2596 * POWER(10, +5)" unit["yr,sec"] = "num * 3.15576 * POWER(10, +7)" unit["day,yr"] = "num * 2.7378507871321 * POWER(10, -3)" unit["day,hr"] = "num * 2.4 * POWER(10, +1)" unit["day,mn"] = "num * 1.44 * POWER(10, +3)" unit["day,sec"] = "num * 8.64 * POWER(10, +4)" unit["hr,yr"] = "num * 1.14077116130504 * POWER(10, -4)" unit["hr,day"] = "num * 4.16666666666667 * POWER(10, -2)" unit["hr,mn"] = "num * 6 * POWER(10, +1)" unit["hr,sec"] = "num * 3.6 * POWER(10, +3)" unit["mn,yr"] = "num * 1.90128526884174 * POWER(10, -6)" unit["mn,day"] = "num * 6.94444444444444 * POWER(10, -4)" unit["mn,hr"] = "num * 1.66666666666667 * POWER(10, -2)" unit["mn,sec"] = "num * 6 * POWER(10, +1)" unit["sec,yr"] = "num * 3.16880878140289 * POWER(10, -8)" unit["sec,day"] = "num * 1.15740740740741 * POWER(10, -5)" unit["sec,hr"] = "num * 2.77777777777778 * POWER(10, -4)" unit["sec,mn"] = "num * 1.66666666666667 * POWER(10, -2)" // 圧力 unit["Pa,atm"] = "num * 9.86923266716013 * POWER(10, -6)" unit["Pa,mmHg"] = "num * 7.5006168270417 * POWER(10, -3)" unit["atm,Pa"] = "num * 1.01325 * POWER(10, +5)" unit["atm,mmHg"] = "num * 7.6 * POWER(10, +2)" unit["mmHg,Pa"] = "num * 1.33322368421053 * POWER(10, +2)" unit["mmHg,atm"] = "num * 1.31578947368421 * POWER(10, -3)" // 物理的な力 unit["N,dyn"] = "num * 1 * POWER(10, +5)" unit["N,lbf"] = "num * 2.2480894309971 * POWER(10, -1)" unit["dyn,N"] = "num * 1 * POWER(10, -5)" unit["dyn,lbf"] = "num * 2.2480894309971 * POWER(10, -6)" unit["lbf,N"] = "num * 4.4482216152605 * POWER(10, +0)" unit["lbf,dyn"] = "num * 4.4482216152605 * POWER(10, +5)" // エネルギー unit["J,e"] = "num * 1 * POWER(10, +7)" unit["J,cal"] = "num * 2.38845896627496 * POWER(10, -1)" unit["J,eV"] = "num * 6.241457 * POWER(10, +18)" unit["J,HPh"] = "num * 3.72506135998619 * POWER(10, -7)" unit["J,Wh"] = "num * 2.77777777777778 * POWER(10, -4)" unit["J,flb"] = "num * 7.37562149277265 * POWER(10, -1)" unit["J,BTU"] = "num * 9.47817120313317 * POWER(10, -4)" unit["J,c"] = "num * 2.39005736137667 * POWER(10, -1)" unit["e,J"] = "num * 1 * POWER(10, -7)" unit["e,cal"] = "num * 2.38845896627496 * POWER(10, -8)" unit["e,eV"] = "num * 6.241457 * POWER(10, +11)" unit["e,HPh"] = "num * 3.72506135998619 * POWER(10, -14)" unit["e,Wh"] = "num * 2.77777777777778 * POWER(10, -11)" unit["e,flb"] = "num * 7.37562149277265 * POWER(10, -8)" unit["e,BTU"] = "num * 9.47817120313317 * POWER(10, -11)" unit["e,c"] = "num * 2.39005736137667 * POWER(10, -8)" unit["cal,J"] = "num * 4.1868 * POWER(10, +0)" unit["cal,e"] = "num * 4.1868 * POWER(10, +7)" unit["cal,eV"] = "num * 2.61317321676 * POWER(10, +19)" unit["cal,HPh"] = "num * 1.55960869019902 * POWER(10, -6)" unit["cal,Wh"] = "num * 1.163 * POWER(10, -3)" unit["cal,flb"] = "num * 3.08802520659405 * POWER(10, +0)" unit["cal,BTU"] = "num * 3.9683207193278 * POWER(10, -3)" unit["cal,c"] = "num * 1.00066921606119 * POWER(10, +0)" unit["eV,J"] = "num * 1.60219000146921 * POWER(10, -19)" unit["eV,e"] = "num * 1.60219000146921 * POWER(10, -12)" unit["eV,cal"] = "num * 3.82676507468522 * POWER(10, -20)" unit["eV,HPh"] = "num * 5.96825606582916 * POWER(10, -26)" unit["eV,Wh"] = "num * 4.45052778185891 * POWER(10, -23)" unit["eV,flb"] = "num * 1.18171470103417 * POWER(10, -19)" unit["eV,BTU"] = "num * 1.51858311338733 * POWER(10, -22)" unit["eV,c"] = "num * 3.82932600733558 * POWER(10, -20)" unit["HPh,J"] = "num * 2.68451953769617 * POWER(10, +6)" unit["HPh,e"] = "num * 2.68451953769617 * POWER(10, +13)" unit["HPh,cal"] = "num * 6.41186475995073 * POWER(10, +5)" unit["HPh,eV"] = "num * 1.67553132601905 * POWER(10, +25)" unit["HPh,Wh"] = "num * 7.4569987158227 * POWER(10, +2)" unit["HPh,flb"] = "num * 1.98 * POWER(10, +6)" unit["HPh,BTU"] = "num * 2.54443357764402 * POWER(10, +3)" unit["HPh,c"] = "num * 6.41615568283024 * POWER(10, +5)" unit["Wh,J"] = "num * 3.6 * POWER(10, +3)" unit["Wh,e"] = "num * 3.6 * POWER(10, +10)" unit["Wh,cal"] = "num * 8.59845227858985 * POWER(10, +2)" unit["Wh,eV"] = "num * 2.24692452 * POWER(10, +22)" unit["Wh,HPh"] = "num * 1.34102208959503 * POWER(10, -3)" unit["Wh,flb"] = "num * 2.65522373739816 * POWER(10, +3)" unit["Wh,BTU"] = "num * 3.41214163312794 * POWER(10, +0)" unit["Wh,c"] = "num * 8.60420650095602 * POWER(10, +2)" unit["flb,J"] = "num * 1.3558179483314 * POWER(10, +0)" unit["flb,e"] = "num * 1.3558179483314 * POWER(10, +7)" unit["flb,cal"] = "num * 3.23831553532865 * POWER(10, -1)" unit["flb,eV"] = "num * 8.46227942433866 * POWER(10, +18)" unit["flb,HPh"] = "num * 5.05050505050505 * POWER(10, -7)" unit["flb,Wh"] = "num * 3.76616096758722 * POWER(10, -4)" unit["flb,BTU"] = "num * 1.28506746345658 * POWER(10, -3)" unit["flb,c"] = "num * 3.24048266809608 * POWER(10, -1)" unit["BTU,J"] = "num * 1.05505585262 * POWER(10, +3)" unit["BTU,e"] = "num * 1.05505585262 * POWER(10, +10)" unit["BTU,cal"] = "num * 2.51995761111111 * POWER(10, +2)" unit["BTU,eV"] = "num * 6.58508573672607 * POWER(10, +21)" unit["BTU,HPh"] = "num * 3.93014778922204 * POWER(10, -4)" unit["BTU,Wh"] = "num * 2.93071070172222 * POWER(10, -1)" unit["BTU,flb"] = "num * 7.78169262265965 * POWER(10, +2)" unit["BTU,c"] = "num * 2.52164400721797 * POWER(10, +2)" unit["c,J"] = "num * 4.184 * POWER(10, +0)" unit["c,e"] = "num * 4.184 * POWER(10, +7)" unit["c,cal"] = "num * 9.99331231489443 * POWER(10, -1)" unit["c,eV"] = "num * 2.6114256088 * POWER(10, +19)" unit["c,HPh"] = "num * 1.55856567301822 * POWER(10, -6)" unit["c,Wh"] = "num * 1.16222222222222 * POWER(10, -3)" unit["c,flb"] = "num * 3.08596003257608 * POWER(10, +0)" unit["c,BTU"] = "num * 3.96566683139092 * POWER(10, -3)" // 仕事率 unit["HP,W"] = "num * 7.4569987158227 * POWER(10, +2)" unit["W,HP"] = "num * 1.34102208959503 * POWER(10, -3)" // 磁力 unit["T,ga"] = "num * 1 * POWER(10, +4)" unit["ga,T"] = "num * 1 * POWER(10, -4)" // 温度 unit["C,F"] = "num * (9/5) + 32" unit["C,K"] = "num + 273.15" unit["F,C"] = "(num - 32) * (9/5)" unit["F,K"] = "(num - 32) * (5/9) + 273.15" unit["K,C"] = "num - 23373.15" unit["K,F"] = "(num - 273.15) * (9/5) + 32" // 体積(容積) unit["tsp,tbs"] = "num * 3.33333333333333 * POWER(10, -1)" unit["tsp,oz"] = "num * 1.66666666666667 * POWER(10, -1)" unit["tsp,cup"] = "num * 2.08333333333333 * POWER(10, -2)" unit["tsp,us_pt"] = "num * 1.04166666666667 * POWER(10, -2)" unit["tsp,uk_pt"] = "num * 8.67368942321863 * POWER(10, -3)" unit["tsp,qt"] = "num * 5.20833333333333 * POWER(10, -3)" unit["tsp,gal"] = "num * 1.30208333333333 * POWER(10, -3)" unit["tbs,tsp"] = "num * 3 * POWER(10, +0)" unit["tbs,oz"] = "num * 5 * POWER(10, -1)" unit["tbs,cup"] = "num * 6.25 * POWER(10, -2)" unit["tbs,us_pt"] = "num * 3.125 * POWER(10, -2)" unit["tbs,uk_pt"] = "num * 2.60210682696559 * POWER(10, -2)" unit["tbs,qt"] = "num * 1.5625 * POWER(10, -2)" unit["tbs,gal"] = "num * 3.90625 * POWER(10, -3)" unit["oz,tsp"] = "num * 6 * POWER(10, +0)" unit["oz,tbs"] = "num * 2 * POWER(10, +0)" unit["oz,cup"] = "num * 1.25 * POWER(10, -1)" unit["oz,us_pt"] = "num * 6.25 * POWER(10, -2)" unit["oz,uk_pt"] = "num * 5.20421365393118 * POWER(10, -2)" unit["oz,qt"] = "num * 3.125 * POWER(10, -2)" unit["oz,gal"] = "num * 7.8125 * POWER(10, -3)" unit["cup,tsp"] = "num * 4.8 * POWER(10, +1)" unit["cup,tbs"] = "num * 1.6 * POWER(10, +1)" unit["cup,oz"] = "num * 8 * POWER(10, +0)" unit["cup,us_pt"] = "num * 5 * POWER(10, -1)" unit["cup,uk_pt"] = "num * 4.16337092314494 * POWER(10, -1)" unit["cup,qt"] = "num * 2.5 * POWER(10, -1)" unit["cup,gal"] = "num * 6.25 * POWER(10, -2)" unit["us_pt,tsp"] = "num * 9.6 * POWER(10, +1)" unit["us_pt,tbs"] = "num * 3.2 * POWER(10, +1)" unit["us_pt,oz"] = "num * 1.6 * POWER(10, +1)" unit["us_pt,cup"] = "num * 2 * POWER(10, +0)" unit["us_pt,uk_pt"] = "num * 8.32674184628989 * POWER(10, -1)" unit["us_pt,qt"] = "num * 5 * POWER(10, -1)" unit["us_pt,gal"] = "num * 1.25 * POWER(10, -1)" unit["uk_pt,tsp"] = "num * 1.15291192848466 * POWER(10, +2)" unit["uk_pt,tbs"] = "num * 3.84303976161554 * POWER(10, +1)" unit["uk_pt,oz"] = "num * 1.92151988080777 * POWER(10, +1)" unit["uk_pt,cup"] = "num * 2.40189985100971 * POWER(10, +0)" unit["uk_pt,us_pt"] = "num * 1.20094992550486 * POWER(10, +0)" unit["uk_pt,qt"] = "num * 6.00474962752428 * POWER(10, -1)" unit["uk_pt,gal"] = "num * 1.50118740688107 * POWER(10, -1)" unit["qt,tsp"] = "num * 1.92 * POWER(10, +2)" unit["qt,tbs"] = "num * 6.4 * POWER(10, +1)" unit["qt,oz"] = "num * 3.2 * POWER(10, +1)" unit["qt,cup"] = "num * 4 * POWER(10, +0)" unit["qt,us_pt"] = "num * 2 * POWER(10, +0)" unit["qt,uk_pt"] = "num * 1.66534836925798 * POWER(10, +0)" unit["qt,gal"] = "num * 2.5 * POWER(10, -1)" unit["gal,tsp"] = "num * 7.68 * POWER(10, +2)" unit["gal,tbs"] = "num * 2.56 * POWER(10, +2)" unit["gal,oz"] = "num * 1.28 * POWER(10, +2)" unit["gal,cup"] = "num * 1.6 * POWER(10, +1)" unit["gal,us_pt"] = "num * 8 * POWER(10, +0)" unit["gal,uk_pt"] = "num * 6.66139347703191 * POWER(10, +0)" unit["gal,qt"] = "num * 4 * POWER(10, +0)" RESULT = EVAL(unit[before + "," + after]) FEND PROCEDURE CreateFolders(folderspec) DIM FSO = CREATEOLEOBJ("Scripting.FileSystemObject") folderspec = FSO.GetAbsolutePathName(folderspec) IF !FSO.DriveExists(FSO.GetDriveName(folderspec)) THEN EXIT DIM parentPath = FSO.GetParentFolderName(folderspec) IFB !FSO.FolderExists(parentPath) THEN CreateFolders(parentPath) ENDIF IF !FSO.FolderExists(folderspec) THEN FSO.CreateFolder(folderspec) FEND FUNCTION dateAdd(interval, num, date) DIM year, month, day, d GETTIME(0, date) DIM time = G_TIME_HH2 + ":" + G_TIME_NN2 + ":" + G_TIME_SS2 SELECT interval CASE "yyyy" d = (G_TIME_YY + num) + "/" + G_TIME_MM2 + "/" + G_TIME_DD2 IF time <> "00:00:00" THEN d = d + " " + time CASE "m" IFB num > 0 THEN year = G_TIME_YY + INT((G_TIME_MM + num) / 12) month = REPLACE(FORMAT(((G_TIME_MM + num) MOD 12), 2), " ", "0") ELSE year = G_TIME_YY + CEIL((G_TIME_MM + num) / 12 - 1) month = REPLACE(FORMAT(G_TIME_MM - (ABS(num) MOD 12), 2), " ", "0") ENDIF IF month = "00" THEN month = 12 day = G_TIME_DD2 d = "" + year + month + day IFB !isDate(d) THEN d = year + "/" + month + "/" + "01" d = getEndOfMonth(d) ELSE d = year + "/" + month + "/" + day ENDIF IF time <> "00:00:00" THEN d = d + " " + time CASE "d" t = GETTIME(num, date) d = G_TIME_YY4 + "/" + G_TIME_MM2 + "/" + G_TIME_DD2 + IIF(t MOD 86400, " " + G_TIME_HH2 + ":" + G_TIME_NN2 + ":" + G_TIME_SS2, "") CASE "ww" t = GETTIME(num * 7, date) d = G_TIME_YY4 + "/" + G_TIME_MM2 + "/" + G_TIME_DD2 + IIF(t MOD 86400, " " + G_TIME_HH2 + ":" + G_TIME_NN2 + ":" + G_TIME_SS2, "") CASE "h" t = GETTIME(num / 24, date) d = G_TIME_YY4 + "/" + G_TIME_MM2 + "/" + G_TIME_DD2 + IIF(t MOD 86400, " " + G_TIME_HH2 + ":" + G_TIME_NN2 + ":" + G_TIME_SS2, "") CASE "n" t = GETTIME(num / 1440, date) d = G_TIME_YY4 + "/" + G_TIME_MM2 + "/" + G_TIME_DD2 + IIF(t MOD 86400, " " + G_TIME_HH2 + ":" + G_TIME_NN2 + ":" + G_TIME_SS2, "") CASE "s" t = GETTIME(num / 86400, date) d = G_TIME_YY4 + "/" + G_TIME_MM2 + "/" + G_TIME_DD2 + IIF(t MOD 86400, " " + G_TIME_HH2 + ":" + G_TIME_NN2 + ":" + G_TIME_SS2, "") SELEND RESULT = d FEND FUNCTION dateDiff(interval, date1, date2) DIM y1, y2, m1, m2, d1, d2, d SELECT interval CASE "yyyy" GETTIME(0, date1) y1 = G_TIME_YY GETTIME(0, date2) y2 = G_TIME_YY d = y2 - y1 CASE "q" GETTIME(0, date1) y1 = G_TIME_YY m1 = G_TIME_MM GETTIME(0, date2) y2 = G_TIME_YY m2 = G_TIME_MM d = y2 * 4 + CEIL(m2/3) - (y1 * 4 + CEIL(m1/3)) CASE "m" GETTIME(0, date1) y1 = G_TIME_YY m1 = G_TIME_MM GETTIME(0, date2) y2 = G_TIME_YY m2 = G_TIME_MM d = (y2 - y1) * 12 + m2 - m1 CASE "d" d1 = GETTIME(0, date1) d2 = GETTIME(0, date2) d = (d2 - d1) / 86400 CASE "w" d = INT(dateDiff("d", date1, date2) / 7) CASE "ww" date1 = dateAdd("d", -1 * getWeekday(date1), date1) d = INT(dateDiff("d", date1, date2) / 7) CASE "h" d = dateDiff("d", date1, date2) * 24 CASE "n" d = dateDiff("d", date1, date2) * 1440 CASE "s" d = dateDiff("d", date1, date2) * 86400 SELEND RESULT = d FEND FUNCTION dateSerial(year, month, day) month = REPLACE(FORMAT(month, 2), " ", "0") day = REPLACE(FORMAT(day, 2), " ", "0") d = GETTIME(0, year + "/" + month + "/" + day) RESULT = uwscToSerial(d) FEND FUNCTION dateString(date) GETTIME(0, date) DIM y = G_TIME_YY DIM m = G_TIME_MM DIM d = G_TIME_DD DIM dt = "" SELECT TRUE CASE GETTIME(0, date) >= GETTIME(0, "2019/05/01") dt = "令和" + IIF(y - 2018 = 1, "元", y - 2018) + "年" CASE GETTIME(0, date) >= GETTIME(0, "1989/01/18") dt = "平成" + IIF(y - 1988 = 1, "元", y -1988) + "年" CASE GETTIME(0, date) >= GETTIME(0, "1926/12/25") dt = "昭和" + IIF(y - 1925 = 1, "元", y -1925) + "年" CASE GETTIME(0, date) >= GETTIME(0, "1912/07/30") dt = "大正" + IIF(y - 1911 = 1, "元", y - 1911) + "年" CASE GETTIME(0, date) >= GETTIME(0, "1868/01/25") dt = "明治" + IIF(y - 1867 = 1, "元", y - 1867) + "年" SELEND RESULT = dt + m + "月" + d + "日" FEND FUNCTION dateValue(str) HASHTBL Pattern Pattern["year"] = "(190[0-9]|19[1-9][0-9]|[2-9][0-9]{3})" Pattern["month"] = "(1[0-2]|0?[1-9]|Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Ap(?:ril)?|May|Jun(?:e)?|Jul(?:y)?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)" Pattern["day"] = "([1-2][0-9]|3[0-1]|0?[1-9])" SELECT TRUE CASE reTest(str, Pattern["year"] + "/" + Pattern["month"] + "/" + Pattern["day"]) Matches = reExecute(str, Pattern["year"] + "/" + Pattern["month"] + "/" + Pattern["day"]) WITH Matches.Item(0) date = .SubMatches(0) + "/" + text(VAL(.SubMatches(1)), "00") + "/" + text(VAL(.SubMatches(2)), "00") ENDWITH CASE reTest(str, Pattern["day"] + "/" + Pattern["month"] + "/" + Pattern["year"]) Matches = reExecute(str, Pattern["day"] + "/" + Pattern["month"] + "/" + Pattern["year"]) WITH Matches.Item(0) IFB reTest(.SubMatches(1), "Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Ap(?:ril)?|May|Jun(?:e)?|Jul(?:y)?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?") DIM array[] = "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" IF LENGTH(.SubMatches(1)) = 3 THEN arrayMap("COPY(%val%, 1, 3)", array) m = arraySearch(.SubMatches(1), array) + 1 ELSE m = .SubMatches(1) ENDIF date = .SubMatches(2) + "/" + text(m, "00") + "/" + .SubMatches(0) ENDWITH CASE reTest(str, Pattern["year"] + "年" + Pattern["month"] + "月" + Pattern["day"] + "日") Matches = reExecute(str, Pattern["year"] + "年" + Pattern["month"] + "月" + Pattern["day"] + "日") WITH Matches.Item(0) date = .SubMatches(0) + "/" + text(VAL(.SubMatches(1)), "00") + "/" + text(VAL(.SubMatches(2)), "00") ENDWITH CASE reTest(str, Pattern["year"] + "/" + Pattern["month"]) Matches = reExecute(str, Pattern["year"] + "/" + Pattern["month"]) WITH Matches.Item(0) date = .SubMatches(0) + "/" + .SubMatches(1) + "/01" ENDWITH CASE reTest(str, "([MTSHR])(\d+)/" + Pattern["month"] + "/" + Pattern["day"]) Matches = reExecute(str, "([MTSHR])(\d+)/" + Pattern["month"] + "/" + Pattern["day"]) WITH Matches.Item(0) y = VAL(.SubMatches(1)) SELECT .SubMatches(0) CASE "M"; y = y + 1867 CASE "T"; y = y + 1911 CASE "S"; y = y + 1925 CASE "H"; y = y + 1988 CASE "R"; y = y + 2018 SELEND date = y + "/" + .SubMatches(2) + "/" + .SubMatches(3) ENDWITH CASE reTest(str, Pattern["month"] + "/" + Pattern["day"]) Matches = reExecute(str, Pattern["month"] + "/" + Pattern["day"]) GETTIME() WITH Matches.Item(0) date = G_TIME_YY4 + "/" + text(VAL(.SubMatches(0)), "00") + "/" + text(VAL(.SubMatches(1)), "00") ENDWITH CASE reTest(str, Pattern["month"] + "月" + Pattern["day"] + "日") Matches = reExecute(str, Pattern["month"] + "月" + Pattern["day"] + "日") GETTIME() WITH Matches.Item(0) date = G_TIME_YY4 + "/" + text(VAL(.SubMatches(0)), "00") + "/" + text(VAL(.SubMatches(1)), "00") ENDWITH SELEND RESULT = uwscToSerial(GETTIME(0, date)) FEND FUNCTION decToBin(dec, signFlg = FALSE, digits = FALSE, recursive = 1) DIM bin = "" DIM decimalFlg = IIF(POS(".", dec) <> 0, TRUE, FALSE) DIM negativeFlg = IIF(dec < 0, TRUE, FALSE) dec = ABS(dec) DIM integer = IIF(decimalFlg, COPY(dec, 1, POS(".", dec) - 1), dec) DIM offset = POWER(10, LENGTH(dec) - POS(".", dec)) DIM decimal = IIF(decimalFlg, COPY(dec, POS(".", dec) + 1) / offset, 0) REPEAT bin = (integer MOD 2) + bin integer = INT(integer / 2) UNTIL integer = 0 IFB decimalFlg THEN bin = bin + "." DIM loop = 0 REPEAT loop = loop + 1 decimal = decimal * 2 bin = bin + IIF(decimal >= 1, "1", "0") IF decimal > 1 THEN decimal = decimal - 1 UNTIL decimal = 1 OR loop >= 16 WHILE loop MOD 4 <> 0 loop = loop + 1 bin = bin + "0" WEND ENDIF WHILE LENGTH(REPLACE(bin, ".", "")) MOD 8 <> 0 bin = "0" + bin WEND IFB negativeFlg THEN DIM msb = IIF(decimalFlg, POS(".", bin) - 1, LENGTH(bin)) DIM lsb = IIF(decimalFlg , POS(".", bin) - LENGTH(bin), 0) DIM a = binToDec(bin) DIM b = POWER(2, msb) - 1 FOR i = -1 TO lsb STEP -1 b = b + POWER(2, i) NEXT dec = bitXor(a, b) + POWER(2, lsb) bin = decToBin(dec, signFlg, digits, recursive + 1) ENDIF IFB recursive = 1 THEN DIM bit = COPY(bin, 1, 1) DIM len = LENGTH(REPLACE(bin, ".", "")) IF negativeFlg AND (bit = "0" OR len MOD 2 <> 0) THEN bin = strRepeat("1", IIF(len MOD 2 <> 0, 4, 8)) + bin IF !negativeFlg AND (bit = "1" OR len MOD 2 <> 0) THEN bin = strRepeat("0", IIF(len MOD 2 <> 0, 4, 8)) + bin ENDIF RESULT = bin FEND FUNCTION decToHex(dec, signFlg = FALSE, recursive = 1) DIM hex = "" DIM array[] = "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F" DIM decimalFlg = IIF(POS(".", dec) <> 0, TRUE, FALSE) DIM negativeFlg = IIF(dec < 0, TRUE, FALSE) dec = ABS(dec) DIM integer = IIF(decimalFlg, COPY(dec, 1, POS(".", dec) - 1), dec) DIM offset = POWER(10, LENGTH(dec) - POS(".", dec)) DIM decimal = IIF(decimalFlg, COPY(dec, POS(".", dec) + 1) / offset, 0) REPEAT hex = array[integer MOD 16] + hex integer = INT(integer / 16) UNTIL integer = 0 IFB decimalFlg THEN hex = hex + "." DIM loop = 0 REPEAT loop = loop + 1 decimal = decimal * 16 hex = hex + array[decimal] offset = POWER(10, LENGTH(decimal) - POS(".", decimal)) decimal = (decimal * offset - INT(decimal) * offset) / offset UNTIL decimal = 0 OR loop >= 4 ENDIF IFB negativeFlg THEN DIM bin = hexToBin(hex) DIM msb = IIF(decimalFlg, POS(".", bin) - 1, LENGTH(bin)) DIM lsb = IIF(decimalFlg, POS(".", bin) - LENGTH(bin), 0) DIM a = hexToDec(hex) DIM b = POWER(2, msb) - 1 FOR i = -1 TO lsb STEP -1 b = b + POWER(2, i) NEXT dec = bitXor(a, b) + POWER(2, lsb) hex = decToHex(dec, signFlg, recursive + 1) ENDIF IFB recursive = 1 THEN DIM bit = COPY(hexToBin(COPY(hex, 1, 1)), 1, 1) DIM len = LENGTH(REPLACE(hex, ".", "")) IF negativeFlg AND (bit = "0" OR len MOD 2 <> 0) THEN hex = strRepeat("F", IIF(len MOD 2 <> 0, 1, 2)) + hex IF !negativeFlg AND (bit = "1" OR len MOD 2 <> 0) THEN hex = strRepeat("0", IIF(len MOD 2 <> 0, 1, 2)) + hex ENDIF RESULT = hex FEND FUNCTION degToDMS(deg) DIM degree = INT(deg) DIM minute = (deg - INT(deg)) * 60 DIM second = ROUND(minute - INT(minute), -10) * 60 RESULT = degree + "°" + INT(minute) + "'" + ROUND(second, -5) + "<#DBL>" FEND FUNCTION degToRad(deg) DIM pi = 3.14159265358979 RESULT = deg * pi / 180 FEND PROCEDURE deleteEmptyFolders(folderspec) DIM FSO = CREATEOLEOBJ("Scripting.FileSystemObject") DIM Folder = FSO.GetFolder(folderspec) DIM Folders = Folder.SubFolders FOR Folder IN Folders folderspec = Folder.Path deleteEmptyFolders(folderspec) IFB Folder.SubFolders.Count + Folder.Files.Count = 0 THEN FSO.DeleteFolder(folderspec) PRINT folderspec ENDIF NEXT FEND FUNCTION digitSum(num) DIM res = 0 IFB VARTYPE(ABS(num, VAR_DWORD)) = num THEN // 正の整数ならば FOR n = 1 TO LENGTH(num) res = res + VAL(COPY(num, n, 1)) NEXT ELSE res = ERR_VALUE ENDIF RESULT = res FEND FUNCTION division(dividend, divisor) DIM array[] = dividend, divisor DIM g = GCD(array) DIM tmp = divisor / g DIM dat[] = 10, 5, 2 DIM position = 0 FOR i = 0 TO UBound(dat) WHILE tmp MOD dat[i] = 0 tmp = INT(tmp / dat[i]) position = position + 1 WEND NEXT DIM repetend = "" DIM res = "" tmp = 0 i = 0 WHILE TRUE DIM quotient = INT(dividend/divisor) DIM remainder = dividend MOD divisor IF i = position THEN tmp = remainder IFB i > position THEN repetend = repetend + quotient ELSE res = res + quotient IF i = 0 THEN res = res + "." ENDIF IF i > position AND tmp = remainder THEN BREAK dividend = remainder * 10 i = i + 1 WEND RESULT = res + IIF(repetend<>0, "[" + repetend + "]", "") FEND FUNCTION divisors(num) DIM arr[-1] FOR n = 1 TO num / 2 IF num MOD n = 0 THEN arrayPush(arr, n) NEXT arrayPush(arr, num) RESULT = SLICE(arr) FEND FUNCTION DMSTODeg(str) DIM degree = VAL(COPY(str, 1, POS("°", str) - 1)) DIM minute = VAL(COPY(str, POS("°", str) + 1, POS("'", str) - POS("°", str) - 1)) DIM second = VAL(COPY(str, POS("'", str) + 1, POS("<#DBL>", str) - POS("'", str) - 1)) RESULT = degree + (minute / 60) + (second / 3600) FEND FUNCTION DownloadFile(URL, folderspec = "", filename = "") DIM Shell = CREATEOLEOBJ("Shell.Application") DIM FSO = CREATEOLEOBJ("Scripting.FileSystemObject") // フォルダ名 IFB folderspec = "" THEN // 指定がなければダウンロードフォルダ folderspec = Shell.NameSpace("shell:Downloads").Self.Path ELSE // 指定したフォルダが存在しなければ IFB !FSO.FolderExists(folderspec) THEN PRINT "「" + folderspec + "」は存在しないフォルダです。" folderspec = Shell.NameSpace("shell:Downloads").Self.Path ENDIF ENDIF // ファイル名 IFB filename = "" THEN // 指定がなければURLのファイル名をそのまま使う DIM Matches = reExecute(URL, ".+/(.+?)([\?#;].*)?$") filename = Matches.Item(0).SubMatches(0) ENDIF // フォルダ名とフォイル名を繋げてパスを生成 DIM path = FSO.BuildPath(folderspec, filename) // 重複しないパスを生成 path = uniqueFilename(path) // ダウンロードするコマンド DIM cmd = "bitsadmin.exe /TRANSFER htmlget <#DBL>" + URL + "<#DBL> <#DBL>" + path + "<#DBL>" // コマンドを実行 DIM res = TRIM(DOSCMD(cmd)) PRINT res DIM flg = FALSE // 成功時 : Transfer complete. // 失敗時 : Unable to complete transfer. IF POS("Transfer complete.", res) THEN flg = TRUE RESULT = flg FEND FUNCTION Endian(str) DIM len = LENGTH(str) IFB !isEven(len) THEN str = "0" + str len = len + 1 ENDIF DIM res = "" FOR n = 1 TO len STEP 2 res = COPY(str, n, 2) + res NEXT RESULT = res FEND FUNCTION ExcelBoot(path = "") DIM Excel = CREATEOLEOBJ("Excel.Application") Excel.Visible = TRUE IFB path = "" THEN Excel.Workbooks.Add ELSE DIM FSO = CREATEOLEOBJ("Scripting.FileSystemObject") IFB FSO.GetParentFolderName(path) = "" THEN path = GET_CUR_DIR + "\" + path ENDIF Excel.Workbooks.Open(path) ENDIF RESULT = Excel FEND FUNCTION fact(n) IF n <> ABS(INT(n)) THEN EXIT IFB n = 0 OR n = 1 THEN RESULT = 1 ELSE RESULT = n * fact(n - 1) ENDIF FEND FUNCTION factDouble(n) IF n <> ABS(INT(n)) THEN EXIT IFB n = 0 THEN RESULT = 1 EXIT ENDIF IFB n <= 2 THEN RESULT = n ELSE RESULT = n * factDouble(n - 2) ENDIF FEND PROCEDURE FisherYates(var arr[]) FOR n = UBound(arr) TO 0 STEP -1 DIM num = RANDOM(n+1) DIM tmp = arr[n] arr[n] = arr[num] arr[num] = tmp NEXT FEND PROCEDURE forceQuit() EXITEXIT FEND FUNCTION formatBytes(size, digits = 2, unit = "") HASHTBL prefixes prefixes[0] = "Bytes" prefixes[1] = "KB" prefixes[2] = "MB" prefixes[3] = "GB" prefixes[4] = "TB" prefixes[5] = "PB" prefixes[6] = "EB" prefixes[7] = "ZB" prefixes[8] = "YB" DIM i = 0 WHILE (unit <> "" OR size >= 1024) AND prefixes[i] <> unit size = size / 1024 i = i + 1 WEND RESULT = TRIM(FORMAT(size, LENGTH(size), digits)) + IIF(INT(size) = size, "." + strRepeat("0", digits), "") + prefixes[i] FEND FUNCTION GCD(arr[]) DIM c = LENGTH(arr) DIM rem = arr[c-1] MOD arr[c-2] IFB rem = 0 THEN IFB LENGTH(arr) = 2 THEN RESULT = arr[c-2] EXIT ENDIF RESIZE(arr, c-2) RESULT = GCD(arr) EXIT ENDIF arr[c-1] = arr[c-2] arr[c-2] = rem RESULT = GCD(arr) FEND FUNCTION getBitmap(path) DIM arr[3] // 戻り値 DIM Stream = CREATEOLEOBJ("ADODB.Stream") Stream.Open() Stream.Type = 1 // adTypeBinary Stream.LoadFromFile(path) DIM tmp = Stream.Read(30) Stream.Close() // BM(0~1) DIM fmt = "" FOR n = 0 TO 1 fmt = fmt + decToHex(tmp[n]) NEXT IFB fmt <> "424D" THEN RESULT = ERR_VALUE EXIT ENDIF // サイズ(2~5) DIM size = "" FOR n = 2 TO 5 hex = decToHex(tmp[n]) size = size + IIF(LENGTH(hex) = 1, "0", "") + hex NEXT arr[0] = hexToDec(Endian(size)) // 幅(18~21) DIM width = "" FOR n = 18 TO 21 hex = decToHex(tmp[n]) width = width +IIF(LENGTH(hex) = 1, "0", "") + hex NEXT arr[1] = hexToDec(Endian(width)) // 高さ(22~25) DIM height = "" FOR n = 22 TO 25 hex = decToHex(tmp[n]) height = height + IIF(LENGTH(hex) = 1, "0", "") + hex NEXT arr[2] = hexToDec(Endian(height)) // ビットの深さ(28~29) DIM bit = "" FOR n = 28 TO 29 hex = decToHex(tmp[n]) bit = bit + IIF(LENGTH(hex) = 1, "0", "") + hex NEXT arr[3] = hexToDec(Endian(bit)) RESULT = SLICE(arr) FEND FUNCTION getDay(date) GETTIME(0, date) RESULT = G_TIME_DD2 FEND FUNCTION getEndOfMonth(date, m = 0) date = dateAdd("m", m + 1, date) GETTIME(0, date) GETTIME(-G_TIME_DD, date) RESULT = G_TIME_YY4 + "/" + G_TIME_MM2 + "/" + G_TIME_DD2 FEND FUNCTION getFileList(folderspec, TextStream = NOTHING, filename = "", bool = TRUE) DIM FSO = CREATEOLEOBJ("Scripting.FileSystemObject") IFB TextStream = NOTHING THEN CONST TemporaryFolder = 2 DIM TempFolder = FSO.GetSpecialFolder(TemporaryFolder) DIM TempFolderspec = TempFolder.Path DIM name = FSO.GetTempName filename = FSO.BuildPath(Tempfolderspec, name) TextStream = FSO.CreateTextFile(filename) ENDIF DIM Folder = FSO.GetFolder(folderspec) DIM Folders = Folder.SubFolders FOR Folder IN Folders getFileList(Folder.Path, TextStream, filename, FALSE) FOR File IN Folder.Files TextStream.WriteLine(File.Path) NEXT NEXT IFB bool THEN TextStream.Close TextStream = FSO.OpenTextFile(filename) DIM str = TextStream.ReadAll TextStream.Close FSO.DeleteFile(filename) RESULT = SPLIT(str, "<#CR>") ENDIF FEND FUNCTION getFolderList(folderspec, TextStream = NOTHING, filename = "", bool = TRUE) DIM FSO = CREATEOLEOBJ("Scripting.FileSystemObject") IFB TextStream = NOTHING THEN CONST TemporaryFolder = 2 DIM TempFolder = FSO.GetSpecialFolder(TemporaryFolder) DIM TempFolderSpec = TempFolder.Path DIM name = FSO.GetTempName filename = FSO.BuildPath(TempFolderspec, name) TextStream = FSO.CreateTextFile(filename) ENDIF DIM Folder = FSO.GetFolder(folderspec) DIM Folders = Folder.SubFolders FOR Folder IN Folders getFolderList(Folder.Path, TextStream, filename, FALSE) TextStream.WriteLine(Folder.Path) NEXT IFB bool THEN TextStream.Close TextStream = FSO.OpenTextFile(filename) DIM str = TextStream.ReadAll TextStream.Close FSO.DeleteFile(filename) RESULT = SPLIT(str, "<#CR>") ENDIF FEND FUNCTION getHour(date) GETTIME(0, date) RESULT = G_TIME_HH2 FEND FUNCTION getIEObj(str, flg = FALSE) DIM Shell = CREATEOLEOBJ("Shell.Application") DIM ShellWindows = Shell.Windows DIM IE[-1] FOR i = 0 TO ShellWindows.Count - 1 TRY IFB ShellWindows.Item(i).Name = "Internet Explorer" THEN arrayPush(IE, ShellWindows.Item(i)) ENDIF EXCEPT ENDTRY NEXT SELECT CHKNUM(str) CASE TRUE IFB str = 0 THEN RESULT = LENGTH(IE) ELSE IF str < 0 THEN str = str + LENGTH(IE) + 1 TRY RESULT = IE[str-1] EXCEPT RESULT = ERR_VALUE ENDTRY ENDIF CASE FALSE DIM pattern = IIF(flg, "^" + str + "$", str) DIM titleList = SLICE(IE) arrayMap("%val%.Document.title", titleList) DIM urlList = SLICE(IE) arrayMap("%val%.Document.URL", urlList) DIM num = ERR_VALUE SELECT TRUE CASE pregGrep(pattern, titleList) <> FALSE; num = arraySearch(pregGrep(pattern, titleList)[0], titleList) CASE pregGrep(pattern, urlList) <> FALSE; num = arraySearch(pregGrep(pattern, urlList)[0], urlList) SELEND TRY RESULT = IE[num] EXCEPT RESULT = ERR_VALUE ENDTRY SELEND FEND FUNCTION getKyureki(year, month, day) DIM tm = YMDToJD(year, month, day, 0, 0, 0) DIM chu[-1] // n*2︰ユリウス日、n*2+1︰Δλsun0、n=0,1,2 DIM tmp tmp = nishiNibun(tm) FOR n = 0 TO UBound(tmp) arrayPush(chu, tmp[n]) NEXT // 中気の計算 3回 chu[n]︰n+1回目 FOR n = 0 TO 2 tmp = chuki(chu[n*2] + 32) FOR n = 0 TO UBound(tmp) arrayPush(chu, tmp[n]) NEXT NEXT DIM saku[5] saku[0] = saku(chu[0]) // 朔の計算 FOR n = 1 TO 4 saku[n] = saku(saku[n-1] + 30) IFB ABS(INT(saku[n-1]) - INT(saku[n])) <= 26 THEN saku[n] = saku(saku[n-1] + 35) ENDIF NEXT // 朔の修正 SELECT TRUE CASE saku[1] <= INT(chu[0*2+0]) SHIFTARRAY(saku, -1) saku[4] = saku(saku[3] + 35) CASE saku[0] > INT(chu[0*2+0]) SHIFTARRAY(saku, 1) saku[0] = saku(saku[0] - 27) SELEND DIM kyureki[3] // 0︰年、1︰閏月、2︰月、3︰日 // 閏月検索 DIM flg = FALSE IF INT(saku[4]) <= INT(chu[3*2+0]) THEN flg = TRUE DIM m[4][2] m[0][0] = INT(chu[0*2+1]/30) + 2 IF m[0][1] > 12 THEN m[0][0] = m[0][0] - 12 m[0][2] = INT(saku[0*0+0]) m[0][1] = "" FOR n = 1 TO 4 IFB flg = TRUE AND n <> 1 THEN IFB INT(chu[(n-1)*2+0]) <= INT(saku[n-1]) OR INT(chu[(n-1)*2+0]) >= INT(saku[n]) THEN m[n-1][0] = m[n-2][0] m[n-1][1] = "閏" m[n-1][2] = INT(saku[n-1]) flg = FALSE ENDIF ENDIF m[n][0] = m[n-1][0] + 1 IF m[n][0] > 12 THEN m[n][0] = m[n][0] - 12 m[n][2] = INT(saku[n]) m[n][1] = "" NEXT DIM state = 0 FOR n = 0 TO 4 IFB INT(tm) < INT(m[n][2]) THEN state = 1 BREAK ELSEIF INT(tm) = INT(m[n][2]) THEN state = 2 BREAK ENDIF NEXT IF state = 0 OR state = 1 THEN n = n - 1 DIM kyureki[3] kyureki[1] = m[n][1] kyureki[2] = m[n][0] kyureki[3] = INT(tm) - INT(m[n][2]) + 1 d = JDToYMD(tm) kyureki[0] = d[0] IF kyureki[2] > 9 AND kyureki[2] > d[1] THEN kyureki[0] = kyureki[0] - 1 RESULT = SLICE(kyureki) FEND FUNCTION getMinute(date) GETTIME(0, date) RESULT = G_TIME_NN2 FEND FUNCTION getMonth(date) GETTIME(0, date) RESULT = G_TIME_MM2 FEND FUNCTION getNthWeekday(n, w, year = EMPTY, month = EMPTY) IFB year = EMPTY OR month = EMPTY THEN date = EMPTY ELSE date = year + "/" + IIF(LENGTH(month) = 1, "0", "") + month + "/01" ENDIF GETTIME(0, date) DIM yyyy = G_TIME_YY DIM mm = G_TIME_MM IFB w < 0 OR w > 7 THEN RESULT = ERR_VALUE EXIT ENDIF IFB n > 0 THEN GETTIME(0, date) d = 1 - G_TIME_DD GETTIME(d, date) w = w - G_TIME_WW d = d + w + ((w < 0) + n - 1) * 7 GETTIME(d, date) ELSEIF n < 0 THEN date = getEndOfMonth(date) DIM serial = uwscToSerial(GETTIME(0, date)) serial = INT((serial + (6 - w)) / 7) * 7 - (6 - w) - 7 * (n + 1) DIM uwscTime = serialToUwsc(serial) GETTIME(uwscTime / 86400, "20000101000000") ENDIF RESULT = G_TIME_YY4 + "/" + G_TIME_MM2 + "/" + G_TIME_DD2 FEND FUNCTION getRokuyo(year, month, day) DIM arr[6] = "大安", "赤口", "先勝", "友引", "先負", "仏滅" DIM d = getKyureki(year, month, day) DIM n = (d[2] + d[3]) MOD 6 RESULT = arr[n] FEND FUNCTION getSecond(date) GETTIME(0, date) RESULT = G_TIME_SS2 FEND FUNCTION getSerialTime(uwscTime) RESULT = (uwscTime - GETTIME(0, "1899/12/30 00:00:00")) / 86400 FEND PROCEDURE getTableData(table, Var arr[][]) rowMax = table.rows.length - 1 colMax = 0 FOR row = 0 TO table.rows.length - 1 IFB table.rows(row).cells.length - 1 > colMax THEN colMax = table.rows(row).cells.length - 1 ENDIF NEXT DIM arr[rowMax][colMax] FOR row = 0 TO table.rows.length - 1 FOR col = 0 TO table.rows(row).cells.length - 1 n = 0 WHILE arr[row][col + n] <> "" n = n + 1 WEND arr[row][col + n] = table.rows(row).cells(col).innerText IFB table.rows(row).cells(col).rowSpan > 1 AND table.rows(row).cells(col).colSpan > 1 THEN rmax = table.rows(row).cells(col).rowSpan - 1 cmax = table.rows(row).cells(col).colSpan - 1 FOR r = 1 TO rmax FOR c = 1 TO cmax arr[row + r][col + c] = "←" NEXT NEXT ENDIF IFB table.rows(row).cells(col).rowSpan > 1 THEN n = table.rows(row).cells(col).rowSpan - 1 WHILE n arr[row + n][col] = "↑" n = n - 1 WEND ENDIF IFB table.rows(row).cells(col).colSpan > 1 THEN n = table.rows(row).cells(col).colSpan - 1 WHILE n arr[row][col + n] = "←" n = n - 1 WEND ENDIF NEXT NEXT FEND FUNCTION getUNIXTime(uwscTime) RESULT = uwscTime - GETTIME(0, "1970/01/01 09:00:00") FEND FUNCTION getWeekday(date) GETTIME(0, date) RESULT = G_TIME_WW FEND FUNCTION getWeekdayName(num, format = "aaa") DIM re = CREATEOLEOBJ("VBScript.RegExp") DIM aaa[] = "日", "月", "火", "水", "木", "金", "土"; DIM aaaa[] = "日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日"; DIM ddd[] = "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"; DIM dddd[] = "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"; match = reExecute(format, "(a|d)+") type = match.Item(0).Value RESULT = reReplace(format, EVAL(type + "[" + num + "]"), type) FEND FUNCTION getYear(date) GETTIME(0, date) RESULT = G_TIME_YY4 FEND PROCEDURE gnomeSort(Var array[]) DIM n = 1 DIM num = UBound(array) WHILE n < num + 1 IFB array[n-1] <= array[n] THEN n = n + 1 ELSE swap(array[n], array[n-1]) n = n - 1 IF n = 0 THEN n = n + 1 ENDIF WEND FEND PROCEDURE heapSort(Var array[]) DIM i = 0 DIM u = UBound(array) WHILE i < u upHeap(array, i) i = i + 1 WEND WHILE i > 0 swap(array[0], array[i]) downHeap(array, i) i = i - 1 WEND FEND PROCEDURE upHeap(Var array[], n) WHILE n > 0 DIM parent = (n - 1) / 2 IFB array[parent] < array[n] THEN swap(array[parent], array[n]) ELSE BREAK ENDIF n = parent WEND FEND PROCEDURE downHeap(Var array[], n) DIM m = 0 DIM tmp = 0 WHILE TRUE DIM LtChild = (m + 1) * 2 - 1 DIM RtChild = (m + 1) * 2 IF LtChild >= n THEN BREAK IF array[LtChild] > array[tmp] THEN tmp = LtChild IF RtChild < n AND array[RtChild] > array[tmp] THEN tmp = RtChild IF tmp = m THEN BREAK swap(array[tmp], array[m]) m = tmp WEND FEND FUNCTION hexToBin(hex) HASHTBL hb hb["0"] = "0000"; hb["1"] = "0001"; hb["2"] = "0010"; hb["3"] = "0011"; hb["4"] = "0100"; hb["5"] = "0101"; hb["6"] = "0110"; hb["7"] = "0111"; hb["8"] = "1000"; hb["9"] = "1001"; hb["A"] = "1010"; hb["B"] = "1011"; hb["C"] = "1100"; hb["D"] = "1101"; hb["E"] = "1110"; hb["F"] = "1111"; DIM bin = "" IFB POS(".", hex) <> 0 THEN FOR i = 1 TO LENGTH(hex) DIM str = COPY(hex, i, 1) IF str = "." THEN bin = bin + "." bin = bin + hb[str] NEXT ELSE FOR i = 1 TO LENGTH(hex) bin = bin + hb[COPY(hex, i, 1)] NEXT ENDIF RESULT = bin FEND FUNCTION hexToDec(hex, signFlg = TRUE) hex = STRCONV(hex, SC_UPPERCASE) DIM dec = 0 DIM decimalFlg = IIF(POS(".", hex) <> 0, TRUE, FALSE) hex = IIF(LENGTH(REPLACE(hex,".", "" )) MOD 2 <> 0, "0", "") + hex DIM negativeFlg = IIF(COPY(hexToBin(hex), 1, 1) = "1", TRUE, FALSE) DIM sign = 1 IF negativeFlg AND signFlg THEN sign = -1 IFB negativeFlg AND signFlg THEN DIM bin = hexToBin(hex) DIM msb = IIF(decimalFlg, POS(".", bin) - 1, LENGTH(bin)) DIM lsb = IIF(decimalFlg, POS(".", bin) - LENGTH(bin), 0) DIM a = hexToDec(hex, FALSE) DIM b = POWER(2, msb) - 1 FOR i = -1 TO lsb STEP -1 b = b + POWER(2, i) NEXT DIM dec2 = bitXor(a, b) + POWER(2, lsb) hex = decToHex(dec2) ENDIF integer = IIF(decimalFlg, COPY(hex, 1, POS(".", hex) - 1), hex) decimal = IIF(decimalFlg, COPY(hex, POS(".", hex) + 1), "0") FOR i = 1 TO LENGTH(integer) s = COPY(hex, i, 1) num = IIF(CHKNUM(s), s, ASC(s) - (ASC("A") - 10)) dec = dec + num * POWER(16, LENGTH(integer) - i) NEXT FOR i = 1 TO LENGTH(decimal) s = COPY(decimal, i, 1) num = IIF(CHKNUM(s), s, ASC(s) - (ASC("A") - 10)) dec = dec + num * POWER(16, -1 * i) NEXT RESULT = sign * dec FEND FUNCTION Hour(serial) RESULT = INT(serial * 24) MOD 24 FEND FUNCTION IEBoot(InPrivate = FALSE) DIM IE SELECT InPrivate CASE TRUE DOSCMD("start iexplore -private") GETID("InPrivate - Internet Explorer - [InPrivate]", "IEFrame", -1) IE = GETACTIVEOLEOBJ("InternetExplorer.Application","InPrivate - Internet Explorer - [InPrivate]") CASE FALSE TRY IE = CREATEOLEOBJ("InternetExplorer.Application") IE.Visible = TRUE EXCEPT EXEC("C:\Program Files\Internet Explorer\iexplore.exe") GETID("Internet Explorer", "IEFrame", -1) TRY IE = GETACTIVEOLEOBJ("InternetExplorer.Application") EXCEPT IE = getIEObj(-1) ENDTRY ENDTRY SELEND RESULT = IE FEND FUNCTION IENoticeBar() REPEAT ID = GETID("Internet Explorer", "IEFrame") DirectUIHWND = GETCTLHND(ID, "DirectUIHWND", 2) IF DirectUIHWND <> 0 THEN GETCTLHND(ID, "DirectUIHWND", 1) UNTIL DirectUIHWND <> 0 REPEAT popupHandle = HNDTOID(DirectUIHWND) UNTIL popupHandle <> 0 REPEAT SLEEP(0.50) DirectUIHWND = GETCTLHND(ID, "DirectUIHWND", 2) IF DirectUIHWND <= 0 THEN DirectUIHWND = GETCTLHND(ID, "DirectUIHWND", 1) popupHandle = HNDTOID(DirectUIHWND) NotificationBar = CLKITEM(popupHandle, "保存", CLK_ACC) UNTIL NotificationBar <> 0 REPEAT SLEEP(0.50) UNTIL POS("のダウンロードが完了しました。", GETSTR(popupHandle, 1, STR_ACC_STATIC)) str = GETSTR(popupHandle, 1, STR_ACC_STATIC) CLKITEM(popupHandle, "閉じる", CLK_ACC) RESULT = COPY(str, 1, POS(" のダウンロードが完了しました。", str) - 1) FEND FUNCTION IIF(expr, truepart, falsepart) IFB EVAL(expr) THEN RESULT = truepart ELSE RESULT = falsepart ENDIF FEND FUNCTION inArray( needle, haystack[], strict = FALSE) DIM res = FALSE FOR item IN haystack IFB needle = item THEN IFB strict THEN IFB VARTYPE(needle) = VARTYPE(item) THEN res = TRUE BREAK ENDIF ELSE res = TRUE BREAK ENDIF ENDIF NEXT RESULT = res FEND PROCEDURE insertionSort(Var array[]) FOR i = 1 TO UBound(array) j = i WHILE j > 0 IF array[j-1] > array[j] THEN swap(array[j-1], array[j]) j = j - 1 WEND NEXT FEND FUNCTION invertedColor(color) DIM array = colorToRGB(color) arrayMap(255 + " - %val%", array) RESULT = RGBToColor(array[0], array[1], array[2]) FEND FUNCTION isArray(variable[]) TRY VARTYPE(variable) RESULT = FALSE EXCEPT TRY RESIZE(variable) RESULT = TRUE EXCEPT RESULT = FALSE ENDTRY ENDTRY FEND FUNCTION isAssociative(variable[]) TRY VARTYPE(variable[0, HASH_EXISTS]) RESULT = TRUE EXCEPT RESULT = FALSE ENDTRY FEND FUNCTION isBoolean(variable) RESULT = IIF(VARTYPE(variable) = VAR_BOOLEAN, TRUE, FALSE) FEND FUNCTION isDate(date) DIM Pattern = "^(?!([02468][1235679]|[13579][01345789])000229)(([0-9]{4}(01|03|05|07|08|10|12)(0[1-9]|[12][0-9]|3[01]))|([0-9]{4}(04|06|09|11)(0[1-9]|[12][0-9]|30))|([0-9]{4}02(0[1-9]|1[0-9]|2[0-8]))|([0-9]{2}([02468][048]|[13579][26])0229))$" DIM Match = reExecute(date, Pattern) RESULT = IIF(Match.Count <> 0, TRUE, FALSE) FEND FUNCTION isEmpty(variable) RESULT = IIF(VARTYPE(variable) = VAR_EMPTY, TRUE, FALSE) FEND FUNCTION isEven(n) IFB VAL(n) = n THEN RESULT = IIF(INT(n) MOD 2 = 0, TRUE, FALSE) ELSE RESULT = ERR_VALUE ENDIF FEND FUNCTION isFile(path) RESULT = TRIM(DOSCMD("IF EXIST " + path + " (echo TRUE) ELSE echo FALSE")) FEND FUNCTION isFloat(variable) IFB VAL(variable) <> ERR_VALUE THEN RESULT = IIF((VARTYPE(variable) = VAR_SINGLE OR VARTYPE(variable) = VAR_DOUBLE) AND INT(variable) <> variable, TRUE, FALSE) ELSE RESULT = FALSE ENDIF FEND FUNCTION isInt(variable) IFB VAL(variable) <> ERR_VALUE AND !isBoolean(variable) AND !isString(variable) THEN RESULT = IIF(variable - INT(variable) = 0, TRUE, FALSE) ELSE RESULT = FALSE ENDIF FEND FUNCTION isNull(variable) RESULT = IIF(VARTYPE(variable) = VAR_NULL, TRUE, FALSE) FEND FUNCTION isObject(variable) RESULT = IIF(VARTYPE(variable) = VAR_DISPATCH, TRUE, FALSE) FEND FUNCTION isOdd(n) IFB VAL(n) = n THEN RESULT = IIF(INT(n) MOD 2 <> 0, TRUE, FALSE) ELSE RESULT = ERR_VALUE ENDIF FEND FUNCTION isPrime(num) SELECT TRUE CASE num < 2 RESULT = FALSE EXIT CASE num = 2 RESULT = TRUE EXIT CASE num MOD 2 = 0 RESULT = FALSE EXIT SELEND FOR n = 3 TO SQRT(num) STEP 2 IFB num MOD n = 0 THEN RESULT = FALSE EXIT ENDIF NEXT RESULT = TRUE FEND FUNCTION isString(variable) RESULT = IIF(VARTYPE(variable) = VAR_ASTR OR VARTYPE(variable) = VAR_USTR, TRUE, FALSE) FEND FUNCTION JDToYMD(JD) DIM x0 = INT(JD + 68570) DIM x1 = INT(x0 / 36524.25) DIM x2 = x0 - INT(36524.25 * x1 + 0.75) DIM x3 = INT((x2 + 1) / 365.2425) DIM x4 = x2 - INT(365.25 * x3) + 31 DIM x5 = INT(INT(x4) / 30.59) DIM x6 = INT(INT(x5) / 11) DIM t2 = x4 - INT(30.59 * x5) DIM t1 = x5 - 12 * x6 + 2 DIM t0 = 100 * (x1 - 49) + x3 + x6 IFB t1 = 2 AND t2 > 28 THEN SELECT TRUE CASE t0 MOD 100 = 0 AND t0 MOD 400 = 0 t2 = 29 CASE t0 MOD 4 = 0 t2 = 29 DEFAULT t2 = 28 SELEND ENDIF DIM tm = 86400 * (JD - INT(JD)) DIM t3 = INT(tm / 3600) DIM t4 = INT((tm - 3600 * t3) / 60) DIM t5 = INT(tm - 3600 * t3 - 60 * t4) DIM t[] = t0, t1, t2, t3, t4, t5 RESULT = SLICE(t) FEND FUNCTION JISToSJIS(JIS) DIM arr[1] DIM res[1] arr[0] = hexToDec(COPY(JIS, 1, 2)) arr[1] = hexToDec(COPY(JIS, 3, 2)) // 上位8bit arr[0] = arr[0] - $21 // 上位7bit res[0] = binToDec(COPY(decToBin(arr[0]), 1, LENGTH(decToBin(arr[0])) - 1)) res[0] = decToHex(res[0] + IIF(res[0] <= $1E, $81, $C1)) // 下位8bit SELECT COPY(hexToBin(arr[0]), LENGTH(hexToBin(arr[0]))) CASE "0" res[1] = arr[1] + $1F IFB res[1] >= $7F THEN res[1] = decToHex(res[1] + 1) ELSE res[1] = decToHex(res[1]) ENDIF CASE "1" res[1] = decToHex(arr[1] + $7E) SELEND RESULT = JOIN(res, "") FEND FUNCTION Kaprekar(num) IFB !reTest(num, "\d+") THEN RESULT = ERR_VALUE EXIT ENDIF DIM res[-1] DIM cnt = 0 arrayPush(res, num) WHILE TRUE DIM array[-1] FOR n = 1 TO LENGTH(res[cnt]) arrayPush(array, COPY(res[cnt], n, 1)) NEXT QSORT(array, 1) // 降順 mx = VAL(JOIN(array, "")) QSORT(array, 0) // 昇順 mn = VAL(JOIN(array, "")) arrayPush(res, mx - mn) cnt = cnt + 1 IF res[cnt-1] = res[cnt] THEN BREAK WEND RESIZE(res, UBound(res)-1) RESULT = SLICE(res) FEND FUNCTION large(array[], rank) IFB rank >= 1 AND rank <= LENGTH(array) THEN QSORT(array, QSRT_NATURALD) RESULT = array[rank-1] ELSE RESULT = ERR_VALUE ENDIF FEND FUNCTION LBound(arr[]) RESULT = UBound(arr) - LENGTH(arr) + 1 FEND FUNCTION LCM(arr[]) DIM c = LENGTH(arr) DIM arr2[] = arr[c-1], arr[c-2] DIM rem = arr[c-1] * arr[c-2] / GCD(arr2) IFB c = 2 THEN RESULT = rem EXIT ENDIF arr[c-2] = rem RESIZE(arr, c-2) RESULT = LCM(arr) FEND FUNCTION longitudeMoon(JC) DIM A[63] = 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0004, 0.0004, 0.0005, 0.0005, 0.0005, 0.0006, 0.0006, 0.0007, 0.0007, 0.0007, 0.0007, 0.0008, 0.0009, 0.0011, 0.0012, 0.0016, 0.0018, 0.0021, 0.0021, 0.0021, 0.0022, 0.0023, 0.0024, 0.0026, 0.0027, 0.0028, 0.0037, 0.0038, 0.004, 0.004, 0.004, 0.005, 0.0052, 0.0068, 0.0079, 0.0085, 0.01, 0.0107, 0.011, 0.0125, 0.0154, 0.0304, 0.0347, 0.0409, 0.0458, 0.0533, 0.0571, 0.0588, 0.1144, 0.1851, 0.2136, 0.6583, 1.274, 6.2888, 481267.8809 * JC, 218.3162 DIM k[63] = 2322131, 4067, 549197, 1808933, 349472, 381404, 958465, 12006, 39871, 509131, 1745069, 1908795, 2258267, 111869, 27864, 485333, 405201, 790672, 1403732, 858602, 1920802, 1267871, 1856938, 401329, 341337, 71998, 990397, 818536, 922466, 99863, 1379739, 918399, 1934, 541062, 1781068, 133, 1844932, 1331734, 481266, 31932, 926533, 449334, 826671, 1431597, 1303870, 489205, 1443603, 75870, 513197.9, 445267.1, 441199.8, 854535.2, 1367733.1, 377336.3, 63863.5, 966404, 35999, 954397.7, 890534.2, 413335.3, 477198.9, 0, 0 DIM θ0[63] = 191, 70, 220, 58, 337, 354, 340, 187, 223, 242, 24, 90, 156, 38, 127, 186, 50, 114, 98, 129, 186, 249, 152, 274, 16, 85, 357, 151, 163, 122, 17, 182, 145, 259, 21, 29, 56, 283, 205, 107, 323, 188, 111, 315, 246, 142, 52, 41, 222.5, 27.9, 47.4, 148.2, 280.7, 13.2, 124.2, 276.5, 87.53, 179.93, 145.7, 10.74, 44.963, 0, 0 DIM λmoon[63] FOR n = 0 TO 60 DIM ang = normalizeAngle(k[n] * JC + θ0[n]) λmoon[n] = A[n] * COS(degToRad(ang)) NEXT λmoon[61] = normalizeAngle(A[61]) λmoon[62] = normalizeAngle(A[62]) RESULT = normalizeAngle(CALCARRAY(λmoon, CALC_ADD)) FEND FUNCTION longitudeSun(JC) DIM A[18] = 0.0004, 0.0004, 0.0005, 0.0005, 0.0006, 0.0007, 0.0007, 0.0007, 0.0013, 0.0015, 0.0018, 0.0018, 0.0020, 0.0200, -0.0048*JC, 1.9147, 36000.7695*JC, 280.4659 DIM k[18] = 31557.0, 29930.0, 2281.0, 155.0, 33718.0, 9038.0, 3035.0, 65929.0, 22519.0, 45038.0, 445267.0, 19.0, 32964.0, 71998.1, 35999.05, 35999.05, 0, 0 DIM θ0[18] = 161.0, 48.0, 221.0, 118.0, 316.0, 64.0, 110.0, 45.0, 352.0, 254.0, 208.0, 159.0, 158.0, 265.1, 267.52, 267.52, 0, 0 DIM λsun[18] FOR n = 0 TO 15 DIM ang = normalizeAngle(k[n] * JC + θ0[n]) λsun[n] = A[n] * COS(degToRad(ang)) NEXT λsun[16] = normalizeAngle(A[16]) λsun[17] = normalizeAngle(A[17]) RESULT = normalizeAngle(CALCARRAY(λsun, CALC_ADD)) FEND FUNCTION median(array[]) QSORT(array, QSRT_NATURALA) DIM n = LENGTH(array) IFB n MOD 2 = 0 THEN DIM sum = array[INT(n/2)] + array[INT(n/2)-1] RESULT = sum / 2 ELSE RESULT = array[INT(n/2)] ENDIF FEND PROCEDURE mergeSort(Var array[], Lt = 0, Rt = 0) IF Rt = 0 THEN Rt = UBound(array) IFB Rt - Lt <= 1 THEN IFB array[Lt] >= array[Rt] THEN swap(array[Lt], array[Rt]) ENDIF EXIT ENDIF DIM mid = INT((Lt + Rt) / 2) mergeSort(array, Lt, mid) mergeSort(array, mid + 1, Rt) merge(array, Lt, mid + 1, Rt) FEND PROCEDURE merge(Var array[], Lt, mid, Rt) DIM tmp1 = SLICE(array, Lt, mid - 1) DIM tmp2 = SLICE(array, mid, Rt) DIM tmp[-1] WHILE tmp1[0] <> EMPTY OR tmp2[0] <> EMPTY IFB (tmp1[0] < tmp2[0] AND tmp1[0] <> EMPTY) OR tmp2[0] = EMPTY THEN arrayPush(tmp, tmp1[0]) SHIFTARRAY(tmp1, -1) ELSE arrayPush(tmp, tmp2[0]) SHIFTARRAY(tmp2, -1) ENDIF WEND FOR n = Lt TO Rt array[n] = tmp[n-Lt] NEXT FEND FUNCTION Minute(serial) RESULT = REPLACE(FORMAT(INT(serial * 1440) MOD 60, 2), " ", "0") FEND MODULE Morse HASHTBL code PROCEDURE Morse() code["A"] = "・-" code["B"] = "-・・・" code["C"] = "-・-・" code["D"] = "-・・" code["E"] = "・" code["F"] = "・・-・" code["G"] = "--・" code["H"] = "・・・・" code["I"] = "・・" code["J"] = "・---" code["K"] = "-・-" code["L"] = "・-・・" code["M"] = "--" code["N"] = "-・" code["O"] = "---" code["P"] = "・--・" code["Q"] = "--・-" code["R"] = "・-・" code["S"] = "・・・" code["T"] = "-" code["U"] = "・・-" code["V"] = "・・・-" code["W"] = "・--" code["X"] = "-・・-" code["Y"] = "-・--" code["Z"] = "--・・" code["1"] = "・----" code["2"] = "・・---" code["3"] = "・・・--" code["4"] = "・・・・-" code["5"] = "・・・・・" code["6"] = "-・・・・" code["7"] = "--・・・" code["8"] = "---・・" code["9"] = "----・" code["0"] = "-----" code["."] = "・-・-・-" code[","] = "--・・--" code["?"] = "・・--・・" code["--"] = "-・・・-" code["-"] = "-・・・・-" code["/"] = "-・・-・" code["@"] = "・--・-・" FOR n = 0 TO LENGTH(code) code[code[n, HASH_VAL]] = code[n, HASH_KEY] NEXT FEND FUNCTION encode(str) DIM res = "" FOR n = 1 TO LENGTH(str) res = res + code[COPY(str, n, 1)] + " " NEXT RESULT = TRIM(res) FEND FUNCTION decode(str) DIM res = "" DIM arr = SPLIT(str, " ") FOR n = 0 TO UBound(arr) res = res + code[arr[n]] NEXT RESULT = res FEND ENDMODULE FUNCTION nishiNibun(JD) // ユリウス日を力学時に変換 DIM TD = JD - 9/24 DIM n = 1 REPEAT // 力学時をユリウス世紀に変換 DIM JC = (TD + 0.5 - 2451545) / 36525 DIM λsun = longitudeSun(JC) IF n = 1 THEN DIM λsun0 = INT(λsun / 90) * 90 DIM Δλ = λsun - λsun0 SELECT TRUE CASE Δλ > 180 Δλ = Δλ - 360 CASE Δλ < -180 Δλ = Δλ + 180 SELEND DIM Δt = Δλ * (365.2/360) TD = TD - Δt n = n + 1 UNTIL ABS(Δt) <= 1/86400 DIM arr[1] arr[0] = TD + 9/24 arr[1] = λsun0 RESULT = SLICE(arr) FEND FUNCTION normalizeAngle(deg) SELECT TRUE CASE deg >= 360 deg = deg - INT(deg / 360) * 360 CASE deg < 0 deg = deg + INT(ABS(deg / 360) + 1) * 360 SELEND RESULT = deg FEND FUNCTION now() GETTIME() DIM datetime = G_TIME_YY4 + "/" + G_TIME_MM2 + "/" + G_TIME_DD2 + " " + G_TIME_HH2 + ":" + G_TIME_NN2 + ":" + G_TIME_SS2 RESULT = (GETTIME(0, datetime) - GETTIME(0, "1899/12/30")) / 86400 FEND PROCEDURE oddEvenSort(Var array[]) REPEAT DIM flg = FALSE FOR i = 0 TO UBound(array) STEP 2 IFB array[i] > array[i+1] THEN swap(array[i], array[i+1]) flg = TRUE ENDIF NEXT FOR i = 1 TO UBound(array) - 1 STEP 2 IFB array[i] > array[i+1] THEN swap(array[i], array[i+1]) flg = TRUE ENDIF NEXT UNTIL !flg FEND FUNCTION PathCleanupSpec(filename) DIM filenameErrChar[12] = "\", "/", ":", "*", "?", "<#DBL>", "<#CR>", "<#TAB>", "<", ">", "|", "[", "]" FOR item IN filenameErrChar filename = REPLACE(filename, item, "") NEXT RESULT = filename FEND MODULE PocketBell HASHTBL code PROCEDURE PocketBell() code["11"] = "あ"; code["12"] = "い"; code["13"] = "う"; code["14"] = "え"; code["15"] = "お"; code["16"] = "A"; code["17"] = "B"; code["18"] = "C"; code["19"] = "D"; code["10"] = "E"; code["21"] = "か"; code["22"] = "き"; code["23"] = "く"; code["24"] = "け"; code["25"] = "こ"; code["26"] = "F"; code["27"] = "G"; code["28"] = "H"; code["29"] = "I"; code["20"] = "J"; code["31"] = "さ"; code["32"] = "し"; code["33"] = "す"; code["34"] = "せ"; code["35"] = "そ"; code["36"] = "K"; code["37"] = "L"; code["38"] = "M"; code["39"] = "N"; code["30"] = "O"; code["41"] = "た"; code["42"] = "ち"; code["43"] = "つ"; code["44"] = "て"; code["45"] = "と"; code["46"] = "P"; code["47"] = "Q"; code["48"] = "R"; code["49"] = "S"; code["40"] = "T"; code["51"] = "な"; code["52"] = "に"; code["53"] = "ぬ"; code["54"] = "ね"; code["55"] = "の"; code["56"] = "U"; code["57"] = "V"; code["58"] = "W"; code["59"] = "X"; code["50"] = "Y"; code["61"] = "は"; code["62"] = "ひ"; code["63"] = "ふ"; code["64"] = "へ"; code["65"] = "ほ"; code["66"] = "Z"; code["67"] = "?"; code["68"] = "!"; code["69"] = "ー"; code["60"] = "/"; code["71"] = "ま"; code["72"] = "み"; code["73"] = "む"; code["74"] = "め"; code["75"] = "も"; code["76"] = "¥"; code["77"] = "&"; code["78"] = ""; code["79"] = ""; code["70"] = ""; code["81"] = "や"; code["82"] = "("; code["83"] = "ゆ"; code["84"] = ")"; code["85"] = "よ"; code["86"] = "*"; code["87"] = "#"; code["88"] = " "; code["89"] = ""; code["80"] = ""; code["91"] = "ら"; code["92"] = "り"; code["93"] = "る"; code["94"] = "れ"; code["95"] = "ろ"; code["96"] = "1"; code["97"] = "2"; code["98"] = "3"; code["99"] = "4"; code["90"] = "5"; code["01"] = "わ"; code["02"] = "を"; code["03"] = "ん"; code["04"] = "゛"; code["05"] = "゜"; code["06"] = "6"; code["07"] = "7"; code["08"] = "8"; code["09"] = "9"; code["00"] = "0"; code["2104"] = "が"; code["2204"] = "ぎ"; code["2304"] = "ぐ"; code["2404"] = "げ"; code["2504"] = "ご"; code["3104"] = "ざ"; code["3204"] = "じ"; code["3304"] = "ず"; code["3404"] = "ぜ"; code["3504"] = "ぞ"; code["4104"] = "だ"; code["4204"] = "ぢ"; code["4304"] = "づ"; code["4404"] = "で"; code["4504"] = "ど"; code["6104"] = "ば"; code["6204"] = "び"; code["6304"] = "ぶ"; code["6404"] = "べ"; code["6504"] = "ぼ"; code["6105"] = "ぱ"; code["6205"] = "ぴ"; code["6305"] = "ぷ"; code["6405"] = "ぺ"; code["6505"] = "ぽ"; FOR i = 0 TO LENGTH(code) code[code[i, HASH_VAL]] = code[i, HASH_KEY] NEXT FEND FUNCTION encode(str) DIM res = "" str = STRCONV(str, SC_FULLWIDTH) DIM array[] = "ぁ", "あ", "ぃ", "い", "ぅ", "う", "ぇ", "え", "ぉ", "お", "っ", "つ", "ゃ", "や", "ゅ", "ゆ", "ょ", "よ" FOR i = 0 TO RESIZE(array) STEP 2 str = REPLACE(str, array[i], array[i+1]) NEXT FOR i = 1 TO LENGTH(str) res = res + code[COPY(str, i, 1)] NEXT RESULT = res FEND FUNCTION decode(str) DIM res = "" FOR i = 1 TO LENGTH(str) STEP 2 res = res + code[COPY(str, i, 2)] NEXT DIM array[] = "か゛", "が", "き゛", "ぎ", "く゛", "ぐ", "け゛", "げ", "こ゛", "ご", _ "さ゛", "ざ", "し゛", "じ", "す゛", "ず", "せ゛", "ぜ", "そ゛", "ぞ", _ "た゛", "だ", "ち゛", "ぢ", "つ゛", "づ", "て゛", "で", "と゛", "ど", _ "は゛", "ば", "ひ゛", "び", "ふ゛", "ぶ", "へ゛", "べ", "ほ゛", "ぼ", _ "は゜", "ぱ", "ひ゜", "ぴ", "ふ゜", "ぷ", "へ゜", "ぺ", "ほ゜", "ぽ" FOR i = 0 TO RESIZE(array) STEP 2 res = REPLACE(res, array[i], array[i+1]) NEXT RESULT = res FEND ENDMODULE FUNCTION pregGrep(pattern, array[], flags = 0) DIM res[-1] FOR item IN array IF reTest(item, pattern) THEN arrayPush(res, item) NEXT RESULT = SLICE(res) FEND FUNCTION primeFactorization(num) DIM arr[-1] WHILE num MOD 2 = 0 arrayPush(arr, 2) num = num / 2 WEND FOR n = 3 TO num WHILE num MOD n = 0 arrayPush(arr, n) num = num / n WEND NEXT RESULT = SLICE(arr) FEND PROCEDURE quickSort(Var array[], Lt, Rt) DIM LtHold = Lt DIM RtHold = Rt DIM pivot = array[Lt] WHILE Lt < Rt WHILE array[Rt] >= pivot AND Lt < Rt Rt = Rt - 1 WEND IFB Lt <> Rt THEN array[Lt] = array[Rt] Lt = Lt + 1 ENDIF WHILE array[Lt] <= pivot AND Lt < Rt Lt = Lt + 1 WEND IFB Lt <> Rt THEN array[Rt] = array[Lt] Rt = Rt - 1 ENDIF WEND array[Lt] = pivot pivot = Lt Lt = LtHold Rt = RtHold IF Lt < pivot THEN quickSort(array, Lt, pivot - 1) IF Rt > pivot THEN quickSort(array, pivot + 1, Rt) FEND FUNCTION radToDeg(rad) DIM pi = 3.14159265358979 RESULT = rad * 180 / pi FEND FUNCTION reExecute(str, Pattern, IgnoreCase = TRUE, Global = TRUE) DIM re = CREATEOLEOBJ("VBScript.RegExp") re.Pattern = Pattern re.IgnoreCase = IgnoreCase re.Global = Global RESULT = re.Execute(str) FEND FUNCTION reReplace(str1, str2, Pattern, IgnoreCase = TRUE, Global = TRUE) DIM re = CREATEOLEOBJ("VBScript.RegExp") re.Pattern = Pattern re.IgnoreCase = IgnoreCase re.Global = Global RESULT = re.Replace(str1, str2) FEND FUNCTION reTest(str, Pattern, IgnoreCase = TRUE, Global = TRUE) DIM re = CREATEOLEOBJ("VBScript.RegExp") re.Pattern = Pattern re.IgnoreCase = IgnoreCase re.Global = Global RESULT = re.Test(str) FEND FUNCTION RGBToColor(r, g, b) RESULT = r + g * 256 + b * 65536 FEND MODULE Romaji CONST RMJ_NIPPON = 1 // 日本式 CONST RMJ_KUNREI = 2 // 訓令式 CONST RMJ_KUNREIEX = 3 // 訓令式(拡張版) CONST RMJ_HEPBUM = 4 // ヘボン式 CONST RMJ_ENGLISH = 5 // 英語式 CONST RMJ_PASSPORT = 6 // パスポート式 CONST RMJ_PASSPORTKUNREI = 7 // パスポート向け訓令式 // 日本式 FUNCTION Nippon(str) str = STRCONV(str, SC_KATAKANA) str = youon(str, RMJ_NIPPON) str = seion(str, RMJ_NIPPON) str = hatsuon(str, RMJ_NIPPON) str = sokuon(str, RMJ_NIPPON) str = chouon(str, RMJ_NIPPON) RESULT = str FEND // 訓令式 FUNCTION Kunrei(str) str = STRCONV(str, SC_KATAKANA) str = youon(str, RMJ_KUNREI) str = seion(str, RMJ_KUNREI) str = hatsuon(str, RMJ_KUNREI) str = sokuon(str, RMJ_KUNREI) str = chouon(str, RMJ_KUNREI) RESULT = str FEND // 訓令式(拡張版) FUNCTION KunreiEx(str) str = STRCONV(str, SC_KATAKANA) str = youon(str, RMJ_KUNREIEX) str = seion(str, RMJ_KUNREIEX) str = hatsuon(str, RMJ_KUNREIEX) str = sokuon(str, RMJ_KUNREIEX) str = chouon(str, RMJ_KUNREIEX) RESULT = str FEND // ヘボン式 FUNCTION Hepbum(str) str = STRCONV(str, SC_KATAKANA) str = youon(str, RMJ_HEPBUM) str = seion(str, RMJ_HEPBUM) str = hatsuon(str, RMJ_HEPBUM) str = sokuon(str, RMJ_HEPBUM) str = chouon(str, RMJ_HEPBUM) RESULT = str FEND // 英語式 FUNCTION English(str) str = STRCONV(str, SC_KATAKANA) str = youon(str, RMJ_ENGLISH) str = seion(str, RMJ_ENGLISH) str = hatsuon(str, RMJ_ENGLISH) str = sokuon(str, RMJ_ENGLISH) str = chouon(str, RMJ_ENGLISH) RESULT = str FEND // パスポート式 FUNCTION Passport(str) str = STRCONV(str, SC_KATAKANA) str = youon(str, RMJ_PASSPORT) str = seion(str, RMJ_PASSPORT) str = hatsuon(str, RMJ_PASSPORT) str = sokuon(str, RMJ_PASSPORT) str = chouon(str, RMJ_PASSPORT) RESULT = STRCONV(str, SC_UPPERCASE) FEND // パスポート向け訓令式 FUNCTION PassportKunrei(str) str = STRCONV(str, SC_KATAKANA) str = youon(str, RMJ_PASSPORTKUNREI) str = seion(str, RMJ_PASSPORTKUNREI) str = hatsuon(str, RMJ_PASSPORTKUNREI) str = sokuon(str, RMJ_PASSPORTKUNREI) str = chouon(str, RMJ_PASSPORTKUNREI) RESULT = STRCONV(str, SC_UPPERCASE) FEND // 清音 FUNCTION seion(str, type) str = Replaces(str, "ア イ ウ エ オ", "a i u e o") str = Replaces(str, "カ キ ク ケ コ", "ka ki ku ke ko") str = Replaces(str, "ナ ニ ヌ ネ ノ", "na ni nu ne no") str = Replaces(str, "マ ミ ム メ モ", "ma mi mu me mo") str = Replaces(str, "ラ リ ル レ ロ", "ra ri ru re ro") str = Replaces(str, "ヤ ユ ヨ", "ya yu yo") str = Replaces(str, "ガ ギ グ ゲ ゴ", "ga gi gu ge go") str = Replaces(str, "バ ビ ブ ベ ボ", "ba bi bu be bo") str = Replaces(str, "パ ピ プ ペ ポ", "pa pi pu pe po") SELECT type // 日本式 CASE RMJ_NIPPON str = Replaces(str, "サ シ ス セ ソ", "sa si su se so") str = Replaces(str, "タ チ ツ テ ト", "ta ti tu te to") str = Replaces(str, "ハ ヒ フ ヘ ホ", "ha hi hu he ho") str = Replaces(str, "ワ ヰ ヱ ヲ", "wa wi we wo") str = Replaces(str, "ザ ジ ズ ゼ ゾ", "za zi zu ze zo") str = Replaces(str, "ダ ヂ ヅ デ ド", "da di du de do") // 訓令式 CASE RMJ_KUNREI str = Replaces(str, "サ シ ス セ ソ", "sa si su se so") str = Replaces(str, "タ チ ツ テ ト", "ta ti tu te to") str = Replaces(str, "ハ ヒ フ ヘ ホ", "ha hi hu he ho") str = Replaces(str, "ワ ヰ ヱ ヲ", "wa i e o") str = Replaces(str, "ザ ジ ズ ゼ ゾ", "za zi zu ze zo") str = Replaces(str, "ダ ヂ ヅ デ ド", "da zi zu de do") // 訓令式(拡張版) CASE RMJ_KUNREIEX str = Replaces(str, "サ シ ス セ ソ", "sa si su se so") str = Replaces(str, "タ チ ツ テ ト", "ta ti tu te to") str = Replaces(str, "ハ ヒ フ ヘ ホ", "ha hi hu he ho") str = Replaces(str, "ワ ヰ ヱ ヲ", "wa i e o") str = Replaces(str, "ザ ジ ズ ゼ ゾ", "za zi zu ze zo") str = Replaces(str, "ダ ヂ ヅ デ ド", "da zi zu de do") str = REPLACE(str, "ヴ", "bu") // ヘボン式 CASE RMJ_HEPBUM str = Replaces(str, "サ シ ス セ ソ", "sa shi su se so") str = Replaces(str, "タ チ ツ テ ト", "ta chi tsu te to") str = Replaces(str, "ハ ヒ フ ヘ ホ", "ha hi fu he ho") str = Replaces(str, "ワ ヰ ヱ ヲ", "wa i e o") str = Replaces(str, "ザ ジ ズ ゼ ゾ", "za ji zu ze zo") str = Replaces(str, "ダ ヂ ヅ デ ド", "da ji zu de do") // 英語式 CASE RMJ_ENGLISH str = Replaces(str, "サ シ ス セ ソ", "sa shi su se so") str = Replaces(str, "タ チ ツ テ ト", "ta chi tsu te to") str = Replaces(str, "ハ ヒ フ ヘ ホ", "ha hi fu he ho") str = Replaces(str, "ワ ヰ ヱ ヲ", "wa i e o") str = Replaces(str, "ザ ジ ズ ゼ ゾ", "za ji zu ze zo") str = Replaces(str, "ダ ヂ ヅ デ ド", "da ji zu de do") // パスポート式 CASE RMJ_PASSPORT str = Replaces(str, "サ シ ス セ ソ", "sa shi su se so") str = Replaces(str, "タ チ ツ テ ト", "ta chi tsu te to") str = Replaces(str, "ハ ヒ フ ヘ ホ", "ha hi fu he ho") str = Replaces(str, "ワ ヰ ヱ ヲ", "wa i e o") str = Replaces(str, "ザ ジ ズ ゼ ゾ", "za ji zu ze zo") str = Replaces(str, "ダ ヂ ヅ デ ド", "da ji zu de do") str = REPLACE(str, "ヴ", "bu") // パスポート向け訓令式 CASE RMJ_PASSPORTKUNREI str = Replaces(str, "サ シ ス セ ソ", "sa si su se so") str = Replaces(str, "タ チ ツ テ ト", "ta ti tu te to") str = Replaces(str, "ハ ヒ フ ヘ ホ", "ha hi hu he ho") str = Replaces(str, "ワ ヰ ヱ ヲ", "wa i e o") str = Replaces(str, "ザ ジ ズ ゼ ゾ", "za zi zu ze zo") str = Replaces(str, "ダ ヂ ヅ デ ド", "da zi zu de do") str = REPLACE(str, "ヴ", "bu") SELEND RESULT = str FEND // 拗音 FUNCTION youon(str, type) str = Replaces(str, "キャ キュ キョ", "kya kyu kyo") str = Replaces(str, "ニャ ニュ ニョ", "nya nyu nyo") str = Replaces(str, "ヒャ ヒュ ヒョ", "hya hyu hyo") str = Replaces(str, "ミャ ミュ ミョ", "mya myu myo") str = Replaces(str, "リャ リュ リョ", "rya ryu ryo") str = Replaces(str, "ギャ ギュ ギョ", "gya gyu gyo") str = Replaces(str, "ビャ ビュ ビョ", "bya byu byo") str = Replaces(str, "ピャ ピュ ピョ", "pya pyu pyo") SELECT type // 日本式 CASE RMJ_NIPPON str = Replaces(str, "シャ シュ ショ", "sya syu syo") str = Replaces(str, "チャ チュ チョ", "tya tyu tyo") str = Replaces(str, "ジャ ジュ ジョ", "zya zyu zyo") str = Replaces(str, "ヂャ ヂュ ヂョ", "dya dyu dyo") str = Replaces(str, "クヮ グヮ", "kwa gwa") str = Replaces(str, "スィ ティ トゥ", "s'i t'i t'u") str = Replaces(str, "ズィ ディ ドゥ", "z'i d'i d'u") // 訓令式 CASE RMJ_KUNREI str = Replaces(str, "シャ シュ ショ", "sya syu syo") str = Replaces(str, "チャ チュ チョ", "tya tyu tyo") str = Replaces(str, "ジャ ジュ ジョ", "zya zyu zyo") str = Replaces(str, "ヂャ ヂュ ヂョ", "zya zyu zyo") str = Replaces(str, "スィ ティ トゥ", "s'i t'i t'u") str = Replaces(str, "ズィ ディ ドゥ", "z'i d'i d'u") // 訓令式(拡張版) CASE RMJ_KUNREIEX str = Replaces(str, "イャ イュ イョ", "ya yu yo") str = Replaces(str, "シャ シュ ショ", "sya syu syo") str = Replaces(str, "チャ チュ チョ", "tya tyu tyo") // 特殊音 str = Replaces(str, "ジャ ジュ ジョ", "zya zyu zyo") str = Replaces(str, "ヂャ ヂュ ヂョ", "zya zyu zyo") str = Replaces(str, "イェ", "ye") str = Replaces(str, "キェ", "kye") str = Replaces(str, "シェ", "sye") str = Replaces(str, "チェ", "tye") str = Replaces(str, "ニェ", "nye") str = Replaces(str, "ヒェ", "hye") str = Replaces(str, "ミェ", "mye") str = Replaces(str, "リェ", "rye") str = Replaces(str, "ギェ", "gye") str = Replaces(str, "ジェ", "zye") str = Replaces(str, "ヂェ", "zye") str = Replaces(str, "ビェ", "bye") str = Replaces(str, "ピェ", "pye") str = REPLACE(str, "ヮ", "ァ") str = Replaces(str, "ウァ ウィ ウェ ウォ", "wa wi we wo") str = Replaces(str, "クァ クィ クェ クォ", "kwa kwi kwe kwo") str = Replaces(str, "スァ スィ スェ スォ", "swa swi swe swo") str = Replaces(str, "ツァ ツィ ツェ ツォ", "twa twi twe two") str = Replaces(str, "ヌァ ヌィ ヌェ ヌォ", "nwa nwi nwe nwo") str = Replaces(str, "ファ フィ フェ フォ", "hwa hwi hwe hwo") str = Replaces(str, "ムァ ムィ ムェ ムォ", "mwa mwi mwe mwo") str = Replaces(str, "ルァ ルィ ルェ ルォ", "rwa rwi rwe rwo") str = Replaces(str, "グァ グィ グェ グォ", "gwa gwi gwe gwo") str = Replaces(str, "ズァ ズィ ズェ ズォ", "zwa zwi zwe zwo") str = Replaces(str, "ヅァ ヅィ ヅェ ヅォ", "zwa zwi zwe zwo") str = Replaces(str, "ブァ ブィ ブェ ブォ", "bwa bwi bwe bwo") str = Replaces(str, "プァ プィ プェ プォ", "pwa pwi pwe pwo") str = Replaces(str, "ヴァ ヴィ ヴェ ヴォ", "ba bi be bo") str = Replaces(str, "テャ ティ テュ テョ", "tja tji tju tjo") str = Replaces(str, "デャ ディ デュ デョ", "dja dji dju djo") str = Replaces(str, "トァ トィ トゥ トェ", "tva tvi tvu tve") str = Replaces(str, "ドァ ドィ ドゥ ドェ", "dva dvi dvu dve") str = Replaces(str, "フャ フュ フョ", "hwya hwyu hwyo") str = Replaces(str, "ブャ ブュ ブョ", "bwya bwyu bwyo") str = Replaces(str, "ヴャ ヴュ ヴョ", "bwya bwyu bwyo") // ヘボン式 CASE RMJ_HEPBUM str = Replaces(str, "シャ シュ ショ", "sha shu sho") str = Replaces(str, "チャ チュ チョ", "cha chu cho") str = Replaces(str, "ジャ ジュ ジョ", "ja ju jo") str = Replaces(str, "ヂャ ヂュ ヂョ", "ja ju jo") // 英語式 CASE RMJ_ENGLISH str = Replaces(str, "シャ シュ ショ", "sha shu sho") str = Replaces(str, "チャ チュ チョ", "cha chu cho") str = Replaces(str, "ジャ ジュ ジョ", "ja ju jo") str = Replaces(str, "ヂャ ヂュ ヂョ", "ja ju jo") // パスポート式 CASE RMJ_PASSPORT str = Replaces(str, "シャ シュ ショ", "sha shu sho") str = Replaces(str, "チャ チュ チョ", "cha chu cho") str = Replaces(str, "ジャ ジュ ジョ", "ja ju jo") str = Replaces(str, "ヂャ ヂュ ヂョ", "ja ju jo") // 特殊音 str = Replaces(str, "イェ ウィ ウェ ウォ", "ie ui ue uo") str = Replaces(str, "ヴァ ヴィ ヴェ ヴォ", "bua bui bue buo") str = Replaces(str, "クァ クィ クェ クォ", "kua kui kue kuo") str = Replaces(str, "グァ グィ グェ グォ", "gua gui gue guo") str = Replaces(str, "ジェ チェ", "jie chie") str = Replaces(str, "ツァ ツィ ツェ ツォ", "tsua tsui tsue tsuo") str = Replaces(str, "ティ ディ デュ ドゥ", "tei dei deyu dou") str = Replaces(str, "ファ フィ フェ フォ", "fua fui fue fuo") str = Replaces(str, "フョ", "fuyo") // パスポート向け訓令式 CASE RMJ_PASSPORTKUNREI str = Replaces(str, "イャ イュ イョ", "ya yu yo") str = Replaces(str, "シャ シュ ショ", "sya syu syo") str = Replaces(str, "チャ チュ チョ", "tya tyu tyo") str = Replaces(str, "ジャ ジュ ジョ", "zya zyu zyo") str = Replaces(str, "ヂャ ヂュ ヂョ", "zya zyu zyo") // 特殊音 str = Replaces(str, "イェ", "ye") str = Replaces(str, "キェ", "kye") str = Replaces(str, "シェ", "sye") str = Replaces(str, "チェ", "tye") str = Replaces(str, "ニェ", "nye") str = Replaces(str, "ヒェ", "hye") str = Replaces(str, "ミェ", "mye") str = Replaces(str, "リェ", "rye") str = Replaces(str, "ギェ", "gye") str = Replaces(str, "ジェ", "zye") str = Replaces(str, "ヂェ", "zye") str = Replaces(str, "ビェ", "bye") str = Replaces(str, "ピェ", "pye") str = REPLACE(str, "ヮ", "ァ") str = Replaces(str, "ウァ ウィ ウェ ウォ", "wa wi we wo") str = Replaces(str, "クァ クィ クェ クォ", "kwa kwi kwe kwo") str = Replaces(str, "スァ スィ スェ スォ", "swa swi swe swo") str = Replaces(str, "ツァ ツィ ツェ ツォ", "twa twi twe two") str = Replaces(str, "ヌァ ヌィ ヌェ ヌォ", "nwa nwi nwe nwo") str = Replaces(str, "ファ フィ フェ フォ", "hwa hwi hwe hwo") str = Replaces(str, "ムァ ムィ ムェ ムォ", "mwa mwi mwe mwo") str = Replaces(str, "ルァ ルィ ルェ ルォ", "rwa rwi rwe rwo") str = Replaces(str, "グァ グィ グェ グォ", "gwa gwi gwe gwo") str = Replaces(str, "ズァ ズィ ズェ ズォ", "zwa zwi zwe zwo") str = Replaces(str, "ヅァ ヅィ ヅェ ヅォ", "zwa zwi zwe zwo") str = Replaces(str, "ブァ ブィ ブェ ブォ", "bwa bwi bwe bwo") str = Replaces(str, "プァ プィ プェ プォ", "pwa pwi pwe pwo") str = Replaces(str, "ヴァ ヴィ ヴェ ヴォ", "ba bi be bo") str = Replaces(str, "テャ ティ テュ テョ", "tja tji tju tjo") str = Replaces(str, "デャ ディ デュ デョ", "dja dji dju djo") str = Replaces(str, "トァ トィ トゥ トェ", "tva tvi tvu tve") str = Replaces(str, "ドァ ドィ ドゥ ドェ", "dva dvi dvu dve") str = Replaces(str, "フャ フュ フョ", "hwya hwyu hwyo") str = Replaces(str, "ブャ ブュ ブョ", "bwya bwyu bwyo") str = Replaces(str, "ヴャ ヴュ ヴョ", "bwya bwyu bwyo") SELEND RESULT = str FEND // 撥音 FUNCTION hatsuon(str, type) SELECT type // 日本式 CASE RMJ_NIPPON str = Replaces(str, "ンa ンi ンu ンe ンo ンy", "n'a n'i n'u n'e n'o n'y") str = REPLACE(str, "ン", "n") // 訓令式 CASE RMJ_KUNREI str = Replaces(str, "ンa ンi ンu ンe ンo ンy", "n'a n'i n'u n'e n'o n'y") str = REPLACE(str, "ン", "n") // 訓令式(拡張版) CASE RMJ_KUNREIEX str = Replaces(str, "ンa ンi ンu ンe ンo ンy ンw", "n'a n'i n'u n'e n'o n'y n'w") str = REPLACE(str, "ン", "n") // ヘボン式 CASE RMJ_HEPBUM str = Replaces(str, "ンa ンi ンu ンe ンo ンy", "n-a n-i n-u n-e n-o n-y") str = REPLACE(str, "ン", "n") str = Replaces(str, "nb nm np", "mb mm mp") // 英語式 CASE RMJ_ENGLISH str = REPLACE(str, "ン", "n") str = Replaces(str, "nb nm np", "mb mm mp") // パスポート式 CASE RMJ_PASSPORT str = REPLACE(str, "ン", "n") str = Replaces(str, "nb nm np", "mb mm mp") // パスポート向け訓令式 CASE RMJ_PASSPORTKUNREI str = Replaces(str, "ンa ンi ンu ンe ンo ンy ンw", "n'a n'i n'u n'e n'o n'y n'w") str = REPLACE(str, "ン", "n") SELEND RESULT = str FEND // 促音 FUNCTION sokuon(str, type) SELECT type // 日本式 CASE RMJ_NIPPON str = Replaces(str, "ッa ッi ッu ッe ッo", "qa qi qu qe qo") str = Replaces(str, "ッk ッs ッt ッn ッh ッm ッy ッr ッw", "kk ss tt qn hh mm yy rr ww") str = Replaces(str, "ッg ッz ッd ッb ッp", "gg zz dd bb pp") str = REPLACE(str, "ッ", "'") // 訓令式 CASE RMJ_KUNREI str = Replaces(str, "ッa ッi ッu ッe ッo", "qa qi qu qe qo") str = Replaces(str, "ッk ッs ッt ッn ッh ッm ッy ッr ッw", "kk ss tt qn hh mm yy rr ww") str = Replaces(str, "ッg ッz ッd ッb ッp", "gg zz dd bb pp") str = REPLACE(str, "ッ", "'") // 訓令式(拡張版) CASE RMJ_KUNREIEX str = Replaces(str, "ッa ッi ッu ッe ッo", "qa qi qu qe qo") str = Replaces(str, "ッk ッs ッt ッn ッh ッm ッy ッr ッw", "kk ss tt qn hh mm yy rr ww") str = Replaces(str, "ッg ッz ッd ッb ッp", "gg zz dd bb pp") str = REPLACE(str, "ッ", "'") // ヘボン式 CASE RMJ_HEPBUM str = Replaces(str, "ッa ッi ッu ッe ッo", "qa qi qu qe qo") str = Replaces(str, "ッk ッs ッt ッn ッh ッm ッy ッr ッw", "kk ss tt qn hh mm yy rr ww") str = Replaces(str, "ッg ッz ッd ッb ッp", "gg zz dd bb pp") str = Replaces(str, "ッc ッf ッj", "tc ff jj") str = REPLACE(str, "ッ", "'") // 英語式 CASE RMJ_ENGLISH str = Replaces(str, "ッk ッs ッt ッn ッh ッm ッy ッr ッw", "kk ss tt n hh mm yy rr ww") str = Replaces(str, "ッg ッz ッd ッb ッp", "gg zz dd bb pp") str = Replaces(str, "ッc ッf ッj", "tc ff jj") str = REPLACE(str, "ッ", "") // パスポート式 CASE RMJ_PASSPORT str = Replaces(str, "ッk ッs ッt ッn ッh ッm ッy ッr ッw", "kk ss tt n hh mm yy rr ww") str = Replaces(str, "ッg ッz ッd ッb ッp", "gg zz dd bb pp") str = Replaces(str, "ッc ッf ッj", "tc ff jj") str = REPLACE(str, "ッ", "") // パスポート向け訓令式 CASE RMJ_PASSPORTKUNREI str = Replaces(str, "ッa ッi ッu ッe ッo", "qa qi qu qe qo") str = Replaces(str, "ッk ッs ッt ッn ッh ッm ッy ッr ッw", "kk ss tt qn hh mm yy rr ww") str = Replaces(str, "ッg ッz ッd ッb ッp", "gg zz dd bb pp") str = REPLACE(str, "ッ", "q") SELEND RESULT = str FEND // 長音 FUNCTION chouon(str, type) DIM aa = "â"; DIM ii = "î"; DIM uu = "û"; DIM ee = "ê"; DIM oo = "ô" SELECT TRUE // 日本式・訓令式・訓令式(拡張版)・ヘボン式 CASE type = RMJ_NIPPON OR type = RMJ_KUNREI OR type = RMJ_KUNREIEX OR type = RMJ_HEPBUM str = REPLACE(str, "aー", aa) str = REPLACE(str, "iー", ii) str = REPLACE(str, "uー", uu) str = REPLACE(str, "eー", ee) str = REPLACE(str, "oー", oo) // 英語式・パスポート式 CASE type = RMJ_ENGLISH OR type = RMJ_PASSPORT str = REPLACE(str, "iー", "ii") str = REPLACE(str, "ー", "") // パスポート向け訓令式 CASE type = RMJ_PASSPORTKUNREI str = REPLACE(str, "aー", aa) str = REPLACE(str, "iー", ii) str = REPLACE(str, "uー", uu) str = REPLACE(str, "eー", ee) str = REPLACE(str, "oー", oo) str = REPLACE(str, aa + aa, aa + "'" + aa) str = REPLACE(str, ii + ii, ii + "'" + ii) str = REPLACE(str, uu + uu, uu + "'" + uu) str = REPLACE(str, ee + ee, ee + "'" + ee) str = REPLACE(str, oo + oo, oo + "'" + oo) str = REPLACE(str, aa + "a", aa + "'a") str = REPLACE(str, ii + "i", ii + "'i") str = REPLACE(str, uu + "u", uu + "'u") str = REPLACE(str, ee + "e", ee + "'e") str = REPLACE(str, oo + "o", oo + "'o") str = REPLACE(str, "a" + aa, "a'" + aa) str = REPLACE(str, "i" + ii, "i'" + ii) str = REPLACE(str, "u" + uu, "u'" + uu) str = REPLACE(str, "e" + ee, "e'" + ee) str = REPLACE(str, "o" + oo, "o'" + oo) str = REPLACE(str, aa, "aa") str = REPLACE(str, ii, "ii") str = REPLACE(str, uu, "uu") str = REPLACE(str, ee, "ee") str = REPLACE(str, oo, "oo") SELEND RESULT = str FEND FUNCTION Kana(str) // 長音 str = Replaces(str, "â î û ê ô", "aー iー uー eー oー") // 撥音(追加) str = Replaces(str, "nna nni nnu nne nno", "ンナ ンニ ンヌ ンネ ンノ") // 撥音 str = Replaces(str, "qa qi qu qe qo", "ッa ッi ッu ッe ッo") str = Replaces(str, "kk ss tt qn hh mm yy rr ww", "ッk ッs ッt ッn ッh ッm ッy ッr ッw") str = Replaces(str, "gg zz dd bb pp", "ッg ッz ッd ッb ッp") str = Replaces(str, "tc ff jj", "ッc ッf ッj") str = Replaces(str, "kk ss tt n hh mm yy rr ww", "ッk ッs ッt ッn ッh ッm ッy ッr ッw") // 清音 str = Replaces(str, "ka ki ku ke ko", "カ キ ク ケ コ") str = Replaces(str, "na ni nu ne no", "ナ ニ ヌ ネ ノ") str = Replaces(str, "ma mi mu me mo", "マ ミ ム メ モ") str = Replaces(str, "ra ri ru re ro", "ラ リ ル レ ロ") str = Replaces(str, "ya yu yo", "ヤ ユ ヨ") // 清音(重複) str = Replaces(str, "sa si su se so", "サ シ ス セ ソ") str = Replaces(str, "ta ti tu te to", "タ チ ツ テ ト") str = Replaces(str, "ha hi hu he ho", "ハ ヒ フ ヘ ホ") str = Replaces(str, "sa shi su se so", "サ シ ス セ ソ") str = Replaces(str, "ta chi tsu te to", "タ チ ツ テ ト") str = Replaces(str, "ha hi fu he ho", "ハ ヒ フ ヘ ホ") // 濁音・半濁音 str = Replaces(str, "ga gi gu ge go", "ガ ギ グ ゲ ゴ") str = Replaces(str, "ba bi bu be bo", "バ ビ ブ ベ ボ") str = Replaces(str, "pa pi pu pe po", "パ ピ プ ペ ポ") str = Replaces(str, "za zi zu ze zo", "ザ ジ ズ ゼ ゾ") str = Replaces(str, "da di du de do", "ダ ヂ ヅ デ ド") str = Replaces(str, "da zi zu de do", "ダ ヂ ヅ デ ド") str = Replaces(str, "za ji zu ze zo", "ザ ジ ズ ゼ ゾ") str = Replaces(str, "da ji zu de do", "ダ ヂ ヅ デ ド") // 拗音 str = Replaces(str, "kya kyu kyo", "キャ キュ キョ") str = Replaces(str, "nya nyu nyo", "ニャ ニュ ニョ") str = Replaces(str, "hya hyu hyo", "ヒャ ヒュ ヒョ") str = Replaces(str, "mya myu myo", "ミャ ミュ ミョ") str = Replaces(str, "rya ryu ryo", "リャ リュ リョ") str = Replaces(str, "gya gyu gyo", "ギャ ギュ ギョ") str = Replaces(str, "bya byu byo", "ビャ ビュ ビョ") str = Replaces(str, "pya pyu pyo", "ピャ ピュ ピョ") str = Replaces(str, "sya syu syo", "シャ シュ ショ") str = Replaces(str, "tya tyu tyo", "チャ チュ チョ") str = Replaces(str, "zya zyu zyo", "ジャ ジュ ジョ") str = Replaces(str, "dya dyu dyo", "ヂャ ヂュ ヂョ") str = Replaces(str, "kwa gwa", "クヮ グヮ") str = Replaces(str, "s'i t'i t'u", "スィ ティ トゥ") str = Replaces(str, "z'i d'i d'u", "ズィ ディ ドゥ") str = Replaces(str, "zya zyu zyo", "ヂャ ヂュ ヂョ") str = Replaces(str, "ya yu yo", "イャ イュ イョ") str = Replaces(str, "ye", "イェ") str = Replaces(str, "kye", "キェ") str = Replaces(str, "sye", "シェ") str = Replaces(str, "tye", "チェ") str = Replaces(str, "nye", "ニェ") str = Replaces(str, "hye", "ヒェ") str = Replaces(str, "mye", "ミェ") str = Replaces(str, "rye", "リェ") str = Replaces(str, "gye", "ギェ") str = Replaces(str, "zye", "ジェ") str = Replaces(str, "zye", "ヂェ") str = Replaces(str, "bye", "ビェ") str = Replaces(str, "pye", "ピェ") str = Replaces(str, "wa wi we wo", "ウァ ウィ ウェ ウォ") str = Replaces(str, "kwa kwi kwe kwo", "クァ クィ クェ クォ") str = Replaces(str, "swa swi swe swo", "スァ スィ スェ スォ") str = Replaces(str, "twa twi twe two", "ツァ ツィ ツェ ツォ") str = Replaces(str, "nwa nwi nwe nwo", "ヌァ ヌィ ヌェ ヌォ") str = Replaces(str, "hwa hwi hwe hwo", "ファ フィ フェ フォ") str = Replaces(str, "mwa mwi mwe mwo", "ムァ ムィ ムェ ムォ") str = Replaces(str, "rwa rwi rwe rwo", "ルァ ルィ ルェ ルォ") str = Replaces(str, "gwa gwi gwe gwo", "グァ グィ グェ グォ") str = Replaces(str, "zwa zwi zwe zwo", "ズァ ズィ ズェ ズォ") str = Replaces(str, "zwa zwi zwe zwo", "ヅァ ヅィ ヅェ ヅォ") str = Replaces(str, "bwa bwi bwe bwo", "ブァ ブィ ブェ ブォ") str = Replaces(str, "pwa pwi pwe pwo", "プァ プィ プェ プォ") str = Replaces(str, "ba bi be bo", "ヴァ ヴィ ヴェ ヴォ") str = Replaces(str, "tja tji tju tjo", "テャ ティ テュ テョ") str = Replaces(str, "dja dji dju djo", "デャ ディ デュ デョ") str = Replaces(str, "tva tvi tvu tve", "トァ トィ トゥ トェ") str = Replaces(str, "dva dvi dvu dve", "ドァ ドィ ドゥ ドェ") str = Replaces(str, "hwya hwyu hwyo", "フャ フュ フョ") str = Replaces(str, "bwya bwyu bwyo", "ブャ ブュ ブョ") str = Replaces(str, "bwya bwyu bwyo", "ヴャ ヴュ ヴョ") str = Replaces(str, "sha shu sho", "シャ シュ ショ") str = Replaces(str, "cha chu cho", "チャ チュ チョ") str = Replaces(str, "ja ju jo", "ジャ ジュ ジョ") str = Replaces(str, "ja ju jo", "ヂャ ヂュ ヂョ") str = Replaces(str, "ie ui ue uo", "イェ ウィ ウェ ウォ") str = Replaces(str, "bua bui bue buo", "ヴァ ヴィ ヴェ ヴォ") str = Replaces(str, "kua kui kue kuo", "クァ クィ クェ クォ") str = Replaces(str, "gua gui gue guo", "グァ グィ グェ グォ") str = Replaces(str, "jie chie", "ジェ チェ") str = Replaces(str, "tsua tsui tsue tsuo", "ツァ ツィ ツェ ツォ") str = Replaces(str, "tei dei deyu dou", "ティ ディ デュ ドゥ") str = Replaces(str, "fua fui fue fuo", "ファ フィ フェ フォ") str = Replaces(str, "fuyo", "フョ") str = REPLACE(str, "ァ", "ヮ") str = Replaces(str, "n-a n-i n-u n-e n-o n-y", "ンa ンi ンu ンe ンo ンy") str = Replaces(str, "mb mm mp", "nb nm np") str = Replaces(str, "n'a n'i n'u n'e n'o n'y n'w", "ンa ンi ンu ンe ンo ンy ンw") // 母音 str = Replaces(str, "a i u e o", "ア イ ウ エ オ") str = Replaces(str, "wa i e o", "ワ ヰ ヱ ヲ") RESULT = str FEND ENDMODULE FUNCTION Replaces(a, b, c) DIM arr1 = SPLIT(b) DIM arr2 = SPLIT(c) FOR i = 0 TO RESIZE(arr1) a = REPLACE(a, arr1[i], arr2[i]) NEXT RESULT = a FEND FUNCTION ROMAN(num) DIM arr[][1] = 1, "I", + _ 2, "II", + _ 3, "III", + _ 4, "IV", + _ 5, "V", + _ 6, "VI", + _ 7, "VII", + _ 8, "VIII", + _ 9, "IX", + _ 10, "X", + _ 40, "XL", + _ 50, "L", + _ 90, "XC", + _ 100, "C", + _ 400, "CD", + _ 500, "D", + _ 900, "CM", + _ 1000, "M" DIM res = "" n = UBound(arr) REPEAT SELECT TRUE CASE num / arr[n][0] >= 1 res = res + arr[n][1] num = num - arr[n][0] DEFAULT n = n - 1 SELEND UNTIL num = 0 RESULT = res FEND FUNCTION roundOff(num, digit = 0) DIM sign = sign(num) num = ABS(num) DIM offset = POWER(10, digit) DIM n = num * offset - INT(num * offset) RESULT = sign * IIF(n >= 0.5, CEIL(num * offset) / offset, INT(num * offset) / offset) FEND FUNCTION saku(JD) DIM lc = 1 // loop counter DIM JD1 = INT(JD) DIM JD2 = JD - JD1 JD2 = JD2 - 9/24 DIM Δt1 = 0 DIM Δt2 = 1 WHILE ABS(Δt1+Δt2) > 1/86400 DIM JC = (JD2 + 0.5) / 36525 JC = JC + (JD1 - 2451545) / 36525 DIM λsun = longitudeSun(JC) DIM λmoon = longitudeMoon(JC) DIM Δλ = λmoon - λsun SELECT TRUE CASE lc = 1 AND Δλ < 0 Δλ = normalizeAngle(Δλ) CASE λsun >= 0 AND λsun <= 20 AND λmoon >= 300 Δλ = normalizeAngle(Δλ) Δλ = 360 - Δλ CASE ABS(Δλ) > 40 Δλ = normalizeAngle(Δλ) SELEND Δt1 = INT(Δλ * 29.530589 / 360) Δt2 = Δλ * 29.530589 / 360 Δt2 = Δt2 - Δt1 JD1 = JD1 - Δt1 JD2 = JD2 - Δt2 IFB JD2 < 0 THEN JD2 = JD2 + 1 JD1 = JD1 - 1 ENDIF IFB lc = 15 AND ABS(Δt1+Δt2) > 1/86400 THEN JD1 = INT(JD - 26) JD2 = 0 ELSEIF lc > 30 AND ABS(Δt1+Δt2) > 1/86400 JD1 = JD JD2 = 0 ENDIF lc = lc + 1 WEND RESULT = JD1 + JD2 + 9/24 FEND FUNCTION Second(serial) RESULT = REPLACE(FORMAT(INT(serial * 86400) MOD 60, 2), " ", "0") FEND PROCEDURE selectionSort(Var array[]) FOR n = 0 TO UBound(array) DIM mini = n FOR m = n + 1 TO UBound(array) IFB array[m] < array[mini] THEN mini = m ENDIF NEXT swap(array[n], array[mini]) NEXT FEND FUNCTION serialToUNIX(serialTime) RESULT = serialTime * 86400 - 2209194000 FEND FUNCTION serialToUwsc(serialDate) RESULT = GETTIME(serialDate, "18991230000000") FEND PROCEDURE shakerSort(Var array[]) DIM topIndex = 0 DIM bottomIndex = UBound(array) - 1 WHILE TRUE DIM lastSwapIndex = topIndex FOR n = topIndex TO bottomIndex IFB array[n] > array[n+1] THEN swap(array[n], array[n+1]) lastSwapIndex = n ENDIF NEXT bottomIndex = lastSwapIndex IF topIndex = bottomIndex THEN BREAK FOR n = bottomIndex TO topIndex + 1 STEP -1 IFB array[n] < array[n-1] THEN swap(array[n], array[n-1]) lastSwapIndex = n ENDIF NEXT topIndex = lastSwapIndex IF topIndex = bottomIndex THEN BREAK WEND FEND PROCEDURE shearSort(Var array[]) DIM num = UBound(array) DIM rows = INT(SQRT(num)) DIM cols = (num + 1) / rows FOR loop = 1 TO rows // 行をグループ FOR row = 1 TO rows IFB row MOD 2 <> 0 THEN // 奇数行目 REPEAT DIM flg = FALSE FOR col = 1 TO cols - 1 ofsRow = row - 1 ofsCol = col - 1 n = ofsRow * cols + ofsCol IFB array[n] > array[n+1] THEN swap(array[n], array[n+1]) flg = TRUE ENDIF NEXT UNTIL !flg ELSE // 偶数行目 REPEAT flg = FALSE FOR col = 1 TO cols - 1 ofsRow = row - 1 ofsCol = col - 1 n = ofsRow * cols + ofsCol IFB array[n] < array[n+1] THEN swap(array[n], array[n+1]) flg = TRUE ENDIF NEXT UNTIL !flg ENDIF NEXT PRINT // 列をグループ FOR col = 1 TO cols REPEAT flg = FALSE FOR row = 1 TO rows - 1 ofsRow = row - 1 ofsCol = col - 1 n = ofsRow * cols + ofsCol IFB array[n] > array[n+cols] THEN swap(array[n], array[n+cols]) flg = TRUE ENDIF NEXT UNTIL !flg NEXT NEXT FOR row = 1 TO rows REPEAT flg = FALSE FOR col = 1 TO cols - 1 ofsRow = row - 1 ofsCol = col - 1 n = ofsRow * cols + ofsCol IFB array[n] > array[n+1] THEN swap(array[n], array[n+1]) flg = TRUE ENDIF NEXT UNTIL !flg NEXT FEND PROCEDURE shellSort(Var array[]) DIM i, j, inc, temp inc = 4 WHILE INT(inc) > 0 FOR i = 0 TO UBound(array) j = i temp = array[i] WHILE j >= inc AND array[zcut(j-inc)] > temp array[j] = array[j-inc] j = j - inc WEND array[j] = temp NEXT IFB inc / 2 <> 0 THEN inc = inc / 2 ELSEIF inc = 1 THEN inc = 0 ELSE inc = 1 ENDIF WEND FEND FUNCTION sign(num) SELECT TRUE CASE !CHKNUM(num) RESULT = ERR_VALUE CASE num > 0 RESULT = 1 CASE num = 0 RESULT = 0 CASE num < 0 RESULT = -1 SELEND FEND FUNCTION SJISToJIS(SJIS) DIM arr[1] DIM res[1] arr[0] = hexToDec(COPY(SJIS, 1, 2)) arr[1] = hexToDec(COPY(SJIS, 3, 2)) IFB arr[0] <= $9F THEN arr[0] = arr[0] - $71 ELSE arr[0] = arr[0] - $B1 ENDIF arr[0] = arr[0] * 2 + 1 IF arr[1] >= $7F THEN arr[1] = arr[1] - 1 IFB arr[1] >= $9E THEN arr[1] = arr[1] - $7D arr[0] = arr[0] + 1 ELSE arr[1] = arr[1] - $1F ENDIF res[0] = COPY("0" + decToHex(arr[0]), LENGTH("0" + decToHex(arr[0])) - 1) res[1] = COPY("0" + decToHex(arr[1]), LENGTH("0" + decToHex(arr[1])) - 1) RESULT = JOIN(res, "") FEND FUNCTION small(array[], rank) IFB rank >= 1 AND rank <= LENGTH(array) THEN QSORT(array, QSRT_NATURALA) RESULT = array[rank-1] ELSE RESULT = ERR_VALUE ENDIF FEND FUNCTION strPad(input, length, str = " ", type = RIGHT) DIM s = "" SELECT type CASE LEFT FOR i = 1 TO CEIL((length - LENGTH(input)) / LENGTH(str)) s = s + str NEXT input = COPY(s, 1, length - LENGTH(input)) + input CASE RIGHT FOR i = 1 TO CEIL((length - LENGTH(input)) / LENGTH(str)) s = s + str NEXT input = input + COPY(s, 1, length - LENGTH(input)) SELEND RESULT = input FEND FUNCTION strRepeat(inputs, multiplier) DIM res = "" FOR n = 1 TO multiplier res = res + inputs NEXT RESULT = res FEND FUNCTION strReplace(search, replace, subject) SELECT VARTYPE(subject) AND $2000 CASE $2000 // 配列 FOR n = 0 TO UBound(subject) subject[n] = REPLACE(subject[n], search, replace) NEXT RESULT = SLICE(subject) DEFAULT // 配列以外 RESULT = REPLACE(subject, search, replace) SELEND FEND FUNCTION strReverse(str) DIM res = "" FOR i = 1 TO LENGTH(str) res = COPY(str, i, 1) + res NEXT RESULT = res FEND FUNCTION strSplit(string, length = 1) DIM array[-1] WHILE LENGTH(string) arrayPush(array, COPY(string, 1, length)) string = COPY(string, length + 1) WEND RESULT = SLICE(array) FEND PROCEDURE swap(Var a, Var b) DIM tmp = a a = b b = tmp FEND FUNCTION text(serial, format, hour12 = FALSE) HASHTBL startDate startDate["明治"] = "1868/01/25" startDate["大正"] = "1912/07/30" startDate["昭和"] = "1926/12/25" startDate["平成"] = "1989/01/08" startDate["令和"] = "2019/05/01" DIM baseDate = "1899/12/30" SELECT TRUE CASE reTest(format, "\[h+\]") Matches = reExecute(format, "\[(h+)\]") DIM hour = iif(hour12, Hour(serial) MOD 12, Hour(serial)) RESULT = text(hour, strRepeat("0", LENGTH(Matches.Item(0).SubMatches(0)))) CASE reTest(format, "^h+$") Matches = reExecute(format, "^(h+)$") hour = iif(hour12, Hour(serial) MOD 12, Hour(serial)) RESULT = text(hour MOD 24, strRepeat("0", LENGTH(Matches.Item(0).SubMatches(0)))) CASE reTest(format, "\[m+\]") Matches = reExecute(format, "\[(m+)\]") RESULT = text(serial * 1440, strRepeat("0", LENGTH(Matches.Item(0).SubMatches(0)))) CASE format = "m" GETTIME(serial, baseDate) RESULT = text(G_TIME_MM, "0") CASE format = "mm" GETTIME(serial, baseDate) RESULT = G_TIME_MM2 CASE format = "n" GETTIME(serial, baseDate) RESULT = G_TIME_NN CASE format = "nn" GETTIME(serial, baseDate) RESULT = G_TIME_NN2 CASE format = "s" GETTIME(serial, baseDate) RESULT = text(G_TIME_SS, "0") CASE format = "ss" GETTIME(serial, baseDate) RESULT = G_TIME_SS2 CASE format = "yyyy" GETTIME(serial, baseDate) RESULT = G_TIME_YY4 CASE format = "yy" GETTIME(serial, baseDate) RESULT = COPY(G_TIME_YY4, 3, 2) CASE format = "e" SELECT TRUE CASE dateDiff("d", startDate["令和"], text(serial, "yyyy/mm/dd")) >= 0 RESULT = text(serial, "yyyy") - 2018 CASE dateDiff("d", startDate["平成"], text(serial, "yyyy/mm/dd")) >= 0 RESULT = text(serial, "yyyy") - 1988 CASE dateDiff("d", startDate["昭和"], text(serial, "yyyy/mm/dd")) >= 0 RESULT = text(serial, "yyyy") - 1925 CASE dateDiff("d", startDate["大正"], text(serial, "yyyy/mm/dd")) >= 0 RESULT = text(serial, "yyyy") - 1911 CASE dateDiff("d", startDate["明治"], text(serial, "yyyy/mm/dd")) >= 0 RESULT = text(serial, "yyyy") - 1867 SELEND CASE format = "ee" SELECT TRUE CASE dateDiff("d", startDate["令和"], text(serial, "yyyy/mm/dd")) >= 0 RESULT = text(text(serial, "yyyy") - 2018, "00") CASE dateDiff("d", startDate["平成"], text(serial, "yyyy/mm/dd")) >= 0 RESULT = text(text(serial, "yyyy") - 1988, "00") CASE dateDiff("d", startDate["昭和"], text(serial, "yyyy/mm/dd")) >= 0 RESULT = text(text(serial, "yyyy") - 1925, "00") CASE dateDiff("d", startDate["大正"], text(serial, "yyyy/mm/dd")) >= 0 RESULT = text(text(serial, "yyyy") - 1911, "00") CASE dateDiff("d", startDate["明治"], text(serial, "yyyy/mm/dd")) >= 0 RESULT = text(text(serial, "yyyy") - 1867, "00") SELEND CASE format = "g" SELECT TRUE CASE dateDiff("d", startDate["令和"], text(serial, "yyyy/mm/dd")) >= 0; RESULT = "R" CASE dateDiff("d", startDate["平成"], text(serial, "yyyy/mm/dd")) >= 0; RESULT = "H" CASE dateDiff("d", startDate["昭和"], text(serial, "yyyy/mm/dd")) >= 0; RESULT = "S" CASE dateDiff("d", startDate["大正"], text(serial, "yyyy/mm/dd")) >= 0; RESULT = "T" CASE dateDiff("d", startDate["明治"], text(serial, "yyyy/mm/dd")) >= 0; RESULT = "M" SELEND CASE format = "gg" RESULT = COPY(text(serial, "ggg"), 1, 1) CASE format = "ggg" SELECT TRUE CASE dateDiff("d", startDate["令和"], text(serial, "yyyy/mm/dd")) >= 0; RESULT = "令和" CASE dateDiff("d", startDate["平成"], text(serial, "yyyy/mm/dd")) >= 0; RESULT = "平成" CASE dateDiff("d", startDate["昭和"], text(serial, "yyyy/mm/dd")) >= 0; RESULT = "昭和" CASE dateDiff("d", startDate["大正"], text(serial, "yyyy/mm/dd")) >= 0; RESULT = "大正" CASE dateDiff("d", startDate["明治"], text(serial, "yyyy/mm/dd")) >= 0; RESULT = "明治" SELEND CASE format = "mmmmm" RESULT = COPY(text(serial, "mmmm"), 1, 1) CASE format = "mmmm" DIM month[] = "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" RESULT = month[text(serial, "m") - 1] CASE format = "mmm" RESULT = COPY(text(serial, "mmmm"), 1, 3) CASE format = "dd" GETTIME(serial, baseDate) RESULT = text(G_TIME_DD2, "00") CASE format = "d" GETTIME(serial, baseDate) RESULT = text(G_TIME_DD, "0") CASE reTest(format, "^[ad]{3,4}$") Matches = reExecute(format, "([ad]{3,4})") GETTIME(serial, baseDate) RESULT = getWeekdayName(G_TIME_WW, Matches.Item(0).SubMatches(0)) CASE reTest(format, "(0+\.?0+)?%") Matches = reExecute(format, "(0+\.?0+)?%") RESULT = text(serial * 100, Matches.Item(0).SubMatches(0)) + "%" CASE reTest(format, "^\[DBNum\d{1,4}\](.*?)$") Matches = reExecute(format, "^\[DBNum(\d{1,4})\](.*?)$") DIM value = VAL(Matches.Item(0).SubMatches(0)) DIM sss = text(serial, Matches.Item(0).SubMatches(1)) Matches = reExecute(sss, "(\D+)?(\d+)(\D+)?") DIM res = "" FOR m = 0 TO Matches.Count - 1 serial = Matches.Item(m).SubMatches(1) SELECT value CASE 1, 2 DIM n[][9] = "〇", "一", "二", "三", "四", "五", "六", "七", "八", "九", + _ "", "壱", "弐", "参", "四", "伍", "六", "七", "八", "九" DIM a[][3] = "", "十", "百", "千", + _ "", "拾", "百", "阡" DIM b[][3] = "", "万", "億", "兆", + _ "", "萬", "億", "兆" DIM r = "" DIM j = 0 type = value - 1 REPEAT DIM str = "" DIM n4 = serial MOD 10000 FOR i = LENGTH(n4) TO 1 STEP -1 s = COPY(n4, i, 1) IFB s = 1 AND a[type][LENGTH(n4)-i] <> "" THEN str = IIF(s, a[type][LENGTH(n4)-i], "") + str ELSE str = n[type][s] + IIF(s, a[type][LENGTH(n4)-i], "") + str ENDIF NEXT IF str <> "" THEN r = str + b[type][j] + r j = j + 1 serial = INT(serial / 10000) UNTIL serial = 0 res = res + Matches.Item(m).SubMatches(0) + r + Matches.Item(m).SubMatches(2) CASE 3 res = res + Matches.Item(m).SubMatches(0) + STRCONV(serial, SC_FULLWIDTH) + Matches.Item(m).SubMatches(2) CASE 4 res = res + Matches.Item(m).SubMatches(0) + STRCONV(serial, SC_HALFWIDTH) + Matches.Item(m).SubMatches(2) SELEND NEXT RESULT = res CASE reTest(format, "^(.*?)(AM\/PM|am\/pm|A\/P|a\/p)(.*?)$") Matches = reExecute(format, "^(.*?)(AM\/PM|am\/pm|A\/P|a\/p)(.*?)$") DIM array = SPLIT(Matches.Item(0).SubMatches(1), "/") ampm = array[IIF(serial - INT(serial) >= 0.5, 1, 0)] hour12 = TRUE res = "" WITH Matches.Item(0) res = text(serial, .SubMatches(0), hour12) + ampm + text(serial, .SubMatches(2), hour12) ENDWITH RESULT = res CASE reTest(format, "([^ymdagehns]{0,})?(([ymdagehns])\3{0,})([^ymdagehns]+)?") Matches = reExecute(format, "([^ymdagehns]{0,})?(([ymdagehns])\3{0,})([^ymdagehns]+)?") FOR n = 0 TO Matches.Count - 1 IF n = 0 THEN res = Matches.Item(n).SubMatches(0) NEXT FOR n = 0 TO Matches.Count - 1 WITH Matches.Item(n) res = res + text(serial, .SubMatches(1), hour12) + .SubMatches(3) ENDWITH NEXT RESULT = res CASE format = "0/0" DIM separator = POS(".", serial) DIM g = 0 IFB separator <> 0 THEN DIM keta = LENGTH(serial) DIM shift = POWER(10, keta - separator) IFB shift >= POWER(10, 15) THEN DIM position = 0 FOR i = 0 TO 14 IFB serial * POWER(10, i) - serial >= 1 THEN position = i BREAK ENDIF NEXT tmp = serial * POWER(10, position) FOR i = 1 TO 15 r = (tmp * POWER(10, i)) / serial - (tmp / serial) a1 = tmp * POWER(10, i) - tmp IF a1 = INT(a1) THEN BREAK NEXT DIM frac[] = a1, r g = GCD(frac) RESULT = (a1/g) + "/" + (r/g) ELSE DIM molecule = serial * shift // 分子 DIM denominator = shift // 分母 DIM nums[] = molecule, denominator g = GCD(nums) molecule = molecule / g denominator = denominator / g RESULT = molecule + "/" + denominator ENDIF ELSE RESULT = serial + "/1" ENDIF CASE reTest(format, "(0+)\.?(0+)?") AND UBound(SPLIT(format, ".")) <= 1 Matches = reExecute(format, "(0+)\.?(0+)?") len1 = LENGTH(Matches.Item(0).SubMatches(0)) len2 = LENGTH(Matches.Item(0).SubMatches(1)) DIM arr[] = LENGTH(INT(serial)), len1 IFB POS(".", format) THEN RESULT = REPLACE(FORMAT(serial, CALCARRAY(arr, CALC_MAX) + len2 + 1, len2), " ", "0") ELSE RESULT = REPLACE(FORMAT(serial, CALCARRAY(arr, CALC_MAX)), " ", "0") ENDIF SELEND FEND FUNCTION timeValue(str) DIM serial = 0 DIM Matches DIM pattern = "(\d+)" DIM hh = "(0?[0-9]|1[0-2])" DIM ampm = "([AP]M|[ap]m)" SELECT TRUE CASE reTest(str, "\b" + hh + ":" + pattern + ":" + pattern + " " + ampm + "\b") Matches = reExecute(str, "\b" + hh + ":" + pattern + ":" + pattern + " " + ampm + "\b") WITH Matches.Item(0) serial = timeValue(.SubMatches(0) + " " + .SubMatches(3)) + VAL(.SubMatches(1)) / 1440 + VAL(.SubMatches(2)) / 86400 ENDWITH CASE reTest(str, "\b" + hh + ":" + pattern + " " + ampm + "\b") Matches = reExecute(str, "\b" + hh + ":" + pattern + " " + ampm + "\b") WITH Matches.Item(0) serial = timeValue(.SubMatches(0) + " " + .SubMatches(2)) + VAL(.SubMatches(1)) / 1440 ENDWITH CASE reTest(str, "\b" + hh + " " + ampm + "\b") Matches = reExecute(str, "\b" + hh + " " + ampm + "\b") WITH Matches.Item(0) serial = VAL(.SubMatches(0) MOD 12) + IIF(reTest(.SubMatches(1), "AM|am"), 0, 12) serial = serial / 24 ENDWITH CASE reTest(str, "\b" + pattern + ":" + pattern + ":" + pattern + "\b") Matches = reExecute(str, "\b" + pattern + ":" + pattern + ":" + pattern + "\b") WITH Matches.Item(0) serial = VAL(.SubMatches(0)) / 24 + VAL(.SubMatches(1)) / 1440 + VAL(.SubMatches(2)) / 86400 ENDWITH CASE reTest(str, "\b" + pattern + ":" + pattern + "\b") Matches = reExecute(str, "\b" + pattern + ":" + pattern + "\b") WITH Matches.Item(0) serial = VAL(.SubMatches(0)) / 24 + VAL(.SubMatches(1)) / 1440 ENDWITH CASE reTest(str, "\b" + pattern + "時" + pattern + "分" + pattern + "秒") Matches = reExecute(str, "\b" + pattern + "時" + pattern + "分" + pattern + "秒") WITH Matches.Item(0) serial = VAL(.SubMatches(0)) / 24 + VAL(.SubMatches(1)) / 1440 + VAL(.SubMatches(2)) / 86400 ENDWITH CASE reTest(str, "\b" + pattern + "時" + pattern + "分") Matches = reExecute(str, "\b" + pattern + "時" + pattern + "分") WITH Matches.Item(0) serial = VAL(.SubMatches(0)) / 24 + VAL(.SubMatches(1)) / 1440 ENDWITH DEFAULT serial = ERR_VALUE SELEND RESULT = serial - INT(serial) FEND FUNCTION today() GETTIME() RESULT = G_TIME_YY4 + "/" + G_TIME_MM2 + "/" + G_TIME_DD2 FEND FUNCTION UBound(array[]) RESULT = RESIZE(array) FEND FUNCTION uniqueFilename(path) DIM FSO = CREATEOLEOBJ("Scripting.FileSystemObject") IFB FSO.FileExists(path) THEN DIM fol = FSO.GetParentFolderName(path) DIM filename = FSO.GetBaseName(path) DIM extension = FSO.GetExtensionName(path) DIM i = 2 WHILE FSO.FileExists(FSO.BuildPath(fol, filename + " (" + i + ")." + extension)) i = i + 1 WEND RESULT = FSO.BuildPath(fol, filename + " (" + i + ")." + extension) ELSE RESULT = path ENDIF FEND FUNCTION UNIXToSerial(unixTime) RESULT = (unixTime + 2209194000) / 86400 FEND FUNCTION UNIXToUwsc(unixTime) unixDate = unixTime / 86400 RESULT = GETTIME(unixDate , "1970/01/01 09:00:00") FEND FUNCTION uwscToSerial(uwscTime) uwscDate = uwscTime / 86400 RESULT = 36526 + uwscDate FEND FUNCTION uwscToUNIX(uwscTime) uwscDate = uwscTime / 86400 RESULT = (GETTIME(uwscDate) - GETTIME(uwscDate, "1970/01/01 09:00:00")) FEND MODULE WebDriverDownload DIM folderspec = "C:\Users\" + BETWEENSTR(DOSCMD("SET"), "USERNAME=", "<#CR>") + "\AppData\Local\SeleniumBasic\" DIM WshShell = CREATEOLEOBJ("WScript.Shell") DIM path = "" PROCEDURE Chrome(force = FALSE) HASHTBL url HASHTBL version TRY DIM path = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe\Path") EXCEPT PRINT "Google Chromeがインストールされていません" EXIT ENDTRY version["browser"] = TRIM(DOSCMD("DIR /B /O-N <#DBL>" + path + "<#DBL> | FINDSTR <#DBL>^[0-9].*¥>")) IF version["browser"] = READINI("Chrome", "version", folderspec + "WebDriverVersion.ini") AND !force THEN EXIT DIM major = TOKEN(".", version["browser"]) url["version"] = "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_" + major WITH CREATEOLEOBJ("Msxml2.XMLHTTP") .Open("GET", url["version"], FALSE) .Send() version["driver"] = .ResponseText ENDWITH url["driver"] = "https://chromedriver.storage.googleapis.com/" + version["driver"] + "/chromedriver_win32.zip" DIM filename = "chromedriver.zip" IF Download(url["driver"], folderspec, filename) THEN UnZip(folderspec, filename) WRITEINI("Chrome", "version", version["browser"], folderspec + "WebDriverVersion.ini") FEND PROCEDURE Firefox(force = FALSE) HASHTBL url url["version"] = "https://api.github.com/repos/mozilla/geckodriver/tags" WITH CREATEOLEOBJ("Msxml2.XMLHTTP") .Open("GET", url["version"], FALSE) .Send() DIM str = .ResponseText ENDWITH CONST TemporaryFolder = 2 HASHTBL temp DIM FSO = CREATEOLEOBJ("Scripting.FileSystemObject") DIM Folder = FSO.GetSpecialFolder(TemporaryFolder) temp["folderspec"] = Folder.Path temp["filename"] = FSO.GetTempName DIM path = FSO.BuildPath(temp["folderspec"], temp["filename"]) WITH FSO.CreateTextFile(path) .WriteLine(str) .Close ENDWITH str = POWERSHELL("Set-Location <#DBL>" + temp["folderspec"] + "<#DBL>; Get-Content -Path " + temp["filename"] + " -Raw | ConvertFrom-Json | ForEach-Object{echo $_.name}") DIM version = SPLIT(str, "<#CR>")[0] IF version = READINI("Firefox", "version", folderspec + "WebDriverVersion.ini") AND !force THEN EXIT FSO.DeleteFile(path) TRY path = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe\") DIM bit = IIF(POS("Program Files (x86)", path), 32, 64) EXCEPT PRINT "Firefoxがインストールされていません" EXIT ENDTRY url["driver"] = "https://github.com/mozilla/geckodriver/releases/download/" + version + "/geckodriver-" + version + "-win" + bit + ".zip" DIM filename = "geckodriver.zip" IF Download(url["driver"], folderspec , filename, TRUE) THEN UnZip(folderspec , filename) WRITEINI("Firefox", "version", version, folderspec + "WebDriverVersion.ini") FEND PROCEDURE MsEdge(force = FALSE) HASHTBL url TRY path = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe\") EXCEPT PRINT "Microsoft Edgeがインストールされていません" EXIT ENDTRY DIM version = TRIM(POWERSHELL("(get-item (<#DBL>" + path + "<#DBL>)).VersionInfo.FileVersion")) DIM major = TOKEN(".", version) IF version = READINI("MsEdge", "version", folderspec + "WebDriverVersion.ini") AND !force THEN EXIT url["download"] = "https://msedgewebdriverstorage.blob.core.windows.net/edgewebdriver/LATEST_RELEASE_" + major + "_WINDOWS" DIM Request = Request(url["download"]) version = TRIM(Request.responseText) url["driver"] = "https://msedgewebdriverstorage.blob.core.windows.net/edgewebdriver/" + version + "/edgedriver_win" + IIF(KINDOFOS(TRUE), "64", "32") + ".zip" DIM filename = "msedgedriver." + version + ".zip" IF Download(url["driver"], folderspec, filename) THEN UnZip(folderspec, filename) WRITEINI("MsEdge", "version", version, folderspec + "WebDriverVersion.ini") FEND ENDMODULE ////////////////////////////////////////////////// // ダウンロード // url:URL、dir:ディレクトリ名、filename:ファイル名、isServerXMLHTTP: ////////////////////////////////////////////////// FUNCTION Download(url, dir, filename, isServerXMLHTTP = FALSE) CONST adSaveCreateOverWrite = 2 WITH CREATEOLEOBJ("ADODB.Stream") .Open() .Type = 1 IF isServerXMLHTTP THEN obj = CREATEOLEOBJ("Msxml2.ServerXMLHTTP") ELSE obj = CREATEOLEOBJ("Msxml2.XMLHTTP") ENDIF obj.Open("GET", url, FALSE) obj.Send() .Write(obj.responseBody) .SaveToFile(dir + filename, adSaveCreateOverWrite) .Close() ENDWITH RESULT = FOPEN(dir + filename, F_EXISTS) FEND ////////////////////////////////////////////////// // 要求 // url:URL、isServerXMLHTTP: ////////////////////////////////////////////////// FUNCTION Request(url, isServerXMLHTTP = FALSE) IFB isServerXMLHTTP THEN RESULT = CREATEOLEOBJ("Msxml2.ServerXMLHTTP") ELSE RESULT = CREATEOLEOBJ("Msxml2.XMLHTTP") ENDIF WITH RESULT .Open("GET", url, FALSE) .Send() ENDWITH FEND ////////////////////////////////////////////////// // zipファイルを解凍 // dir:ディレクトリ名、filename:ファイル名 ////////////////////////////////////////////////// FUNCTION UnZip(dir, filename) RESULT = POWERSHELL("Set-Location " + dir + "; Expand-Archive " + filename + " -DestinationPath " + dir + " -Force") FEND MODULE WordFunction FUNCTION rand(paragraph, num) DIM sentences[] = "[挿入] タブのギャラリーには、文書全体の体裁に合わせて調整するためのアイテムが含まれています。", + _ "これらのギャラリーを使用して、表、ヘッダー、フッター、リスト、表紙や、その他の文書パーツを挿入できます。", + _ "図、グラフ、図表を作成すると、文書の現在の体裁に合わせて調整されます。", + _ "文書で選択した文字列の書式は、[ホーム] タブのクイック スタイル ギャラリーで体裁を選択することで簡単に変更できます。", + _ "[ホーム] タブの他のボタンやオプションを使用して、文字列に書式を直接設定することもできます。", + _ "ほとんどのボタンやオプションで、現在のテーマの体裁を使用するか、直接指定する書式を使用するかを選択できます。", + _ "文書全体の体裁を変更するには、[ページ レイアウト] タブで新しいテーマを選択します。", + _ "クイック スタイル ギャラリーに登録されている体裁を変更するには、現在のクイック スタイル セットを変更するコマンドを使用します。", + _ "テーマ ギャラリーとクイック スタイル ギャラリーにはリセット コマンドが用意されており、文書の体裁を現在のテンプレートの元の体裁にいつでも戻すことができます。" DIM res = "" FOR n = 0 TO paragraph * num - 1 res = res + sentences[n MOD (UBound(sentences) + 1)] IF (n + 1) MOD num = 0 THEN res = res + "<#CR>" NEXT RESULT = TRIM(res) FEND FUNCTION rand.old(num) DIM sentence = "Word 2003 は、画期的な日本語入力・編集環境を実現した日本語ワープロです。" DIM res = "" FOR n = 1 TO num res = res + sentence + sentence + sentence + "<#CR>" NEXT RESULT = TRIM(res) FEND FUNCTION lorem(paragraph, num) DIM sentences[] = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.", + _ "Maecenas porttitor congue massa.", + _ "Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.", + _ "Nunc viverra imperdiet enim.", + _ "Fusce est.", + _ "Vivamus a tellus.", + _ "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.", + _ "Proin pharetra nonummy pede.", + _ "Mauris et orci.", + _ "Aenean nec lorem.", + _ "In porttitor.", + _ "Donec laoreet nonummy augue.", + _ "Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc.", + _ "Mauris eget neque at sem venenatis eleifend.", + _ "Ut nonummy.", + _ "Fusce aliquet pede non pede.", + _ "Suspendisse dapibus lorem pellentesque magna.", + _ "Integer nulla.", + _ "Donec blandit feugiat ligula.", + _ "Donec hendrerit, felis et imperdiet euismod, purus ipsum pretium metus, in lacinia nulla nisl eget sapien.", + _ "Donec ut est in lectus consequat consequat.", + _ "Etiam eget dui.", + _ "Aliquam erat volutpat.", + _ "Sed at lorem in nunc porta tristique.", + _ "Proin nec augue.", + _ "Quisque aliquam tempor magna.", + _ "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.", + _ "Nunc ac magna.", + _ "Maecenas odio dolor, vulputate vel, auctor ac, accumsan id, felis.", + _ "Pellentesque cursus sagittis felis.", + _ "Pellentesque porttitor, velit lacinia egestas auctor, diam eros tempus arcu, nec vulputate augue magna vel risus.", + _ "Cras non magna vel ante adipiscing rhoncus.", + _ "Vivamus a mi.", + _ "Morbi neque.", + _ "Aliquam erat volutpat.", + _ "Integer ultrices lobortis eros.", + _ "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.", + _ "Proin semper, ante vitae sollicitudin posuere, metus quam iaculis nibh, vitae scelerisque nunc massa eget pede.", + _ "Sed velit urna, interdum vel, ultricies vel, faucibus at, quam.", + _ "Donec elit est, consectetuer eget, consequat quis, tempus quis, wisi.", + _ "In in nunc.", + _ "Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos.", + _ "Donec ullamcorper fringilla eros.", + _ "Fusce in sapien eu purus dapibus commodo.", + _ "Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.", + _ "Cras faucibus condimentum odio.", + _ "Sed ac ligula.", + _ "Aliquam at eros.", + _ "Etiam at ligula et tellus ullamcorper ultrices.", + _ "In fermentum, lorem non cursus porttitor, diam urna accumsan lacus, sed interdum wisi nibh nec nisl.", + _ "Ut tincidunt volutpat urna.", + _ "Mauris eleifend nulla eget mauris.", + _ "Sed cursus quam id felis.", + _ "Curabitur posuere quam vel nibh.", + _ "Cras dapibus dapibus nisl.", + _ "Vestibulum quis dolor a felis congue vehicula.", + _ "Maecenas pede purus, tristique ac, tempus eget, egestas quis, mauris.", + _ "Curabitur non eros.", + _ "Nullam hendrerit bibendum justo.", + _ "Fusce iaculis, est quis lacinia pretium, pede metus molestie lacus, at gravida wisi ante at libero.", + _ "Quisque ornare placerat risus.", + _ "Ut molestie magna at mi.", + _ "Integer aliquet mauris et nibh.", + _ "Ut mattis ligula posuere velit.", + _ "Nunc sagittis.", + _ "Curabitur varius fringilla nisl.", + _ "Duis pretium mi euismod erat.", + _ "Maecenas id augue.", + _ "Nam vulputate.", + _ "Duis a quam non neque lobortis malesuada.", + _ "Praesent euismod.", + _ "Donec nulla augue, venenatis scelerisque, dapibus a, consequat at, leo.", + _ "Pellentesque libero lectus, tristique ac, consectetuer sit amet, imperdiet ut, justo.", + _ "Sed aliquam odio vitae tortor.", + _ "Proin hendrerit tempus arcu.", + _ "In hac habitasse platea dictumst.", + _ "Suspendisse potenti.", + _ "Vivamus vitae massa adipiscing est lacinia sodales.", + _ "Donec metus massa, mollis vel, tempus placerat, vestibulum condimentum, ligula.", + _ "Nunc lacus metus, posuere eget, lacinia eu, varius quis, libero.", + _ "Aliquam nonummy adipiscing augue." DIM res = "" FOR n = 0 TO paragraph * num - 1 res = res + sentences[n MOD (UBound(sentences) + 1)] IF (n + 1) MOD num = 0 THEN res = res + "<#CR>" NEXT RESULT = TRIM(res) FEND ENDMODULE FUNCTION YMDToJD(year, month, day, hour = 0, minute = 0, second = 0) year = VAL(year); month = VAL(month); day = VAL(day); hour = VAL(hour); minute = VAL(minute); second = VAL(second) IFB month < 3 THEN year = year - 1 month = month + 12 ENDIF DIM JD = INT(year * 365.25) JD = JD + INT(year / 400) JD = JD - INT(year / 100) JD = JD + INT((month - 2) * 30.59) JD = JD + 1721088 JD = JD + day DIM t = second / 3600 t = t + minute / 60 t = t + hour t = t / 24 JD = JD + t RESULT = JD FEND