全自作関数

CALL "D:\Programs\UWSC\FUNCTIONS.uws" // FUNCTIONS.uwsを置いている絶対パスを指定

CALL関数でFUNCTIONS.uwsにあるすべての関数を利用できます。

このホームページで使われているすべての自作関数です。これをFUNCTIONS.uwsとして一次元で保存・呼び出しすることで重複した関数を定義したりすることなく、プログラムの管理・修正が楽になります。

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) num = REPLACE(str, arr[n][0], arr[n][1]) NEXT DIM res = 0 FOR s = 1 TO LENGTH(num) 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
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 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
FUNCTION arrayPop(var arr[]) DIM n = UBound(arr) DIM res = arr[n] RESIZE(arr, n-1) RESULT = res FEND
FUNCTION arrayPush(var arr[], str) DIM res = RESIZE(arr, UBound(arr) + 1) arr[res] = str RESULT = res + 1 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 arrayValues(var arr[]) DIM tmp[-1] FOR n = 0 TO UBound(arr) IF arr[n] <> EMPTY THEN arrayPush(tmp, arr[n]) NEXT RESIZE(arr, UBound(tmp)) FOR n = 0 TO UBound(tmp) arr[n] = tmp[n] NEXT FEND
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 binToDec(bin) dec = 0 FOR n = 1 TO LENGTH(bin) dec = dec + COPY(bin, n, 1) * POWER(2, LENGTH(bin) - n) NEXT 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"; len = CEIL(LENGTH(bin) / 4) * 4 bin = REPLACE(FORMAT(bin, len), " ", "0") hex = "" FOR n = 1 TO LENGTH(bin) / 4 str = COPY(bin, n * 4 - 3, 4) hex = hex + bh[str] NEXT RESULT = hex FEND
PROCEDURE BusyWait(IE) TRY SLEEP(0.500) REPEAT SLEEP(0.010) UNTIL !IE.Busy AND IE.readyState = 4 EXCEPT SLEEP(5.000) ENDTRY 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) // 1文字 DIM s = COPY(str, n, 1) // オフセット a:0, b:1, ..., z:25 DIM ofs = "" // SELECT TRUE CASE ASC(s) >= ASC("A") AND ASC(s) <= ASC("Z") // 数値を0〜25の範囲に正規化 normalizedNumber = IIF(num >= 0, num MOD 26, INT(ABS(num / 26) + 1) * 26 + num) ofs = (ASC(s) - ASC("A") + normalizedNumber) MOD 26 res = res + CHR(ofs + ASC("A")) CASE ASC(s) >= ASC("a") AND ASC(s) <= ASC("z") // 数値を0〜25の範囲に正規化 normalizedNumber = IIF(num >= 0, num MOD 26, INT(ABS(num / 26) + 1) * 26 + num) 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 = "" SELECT TRUE CASE ASC(s) >= ASC("A") AND ASC(s) <= ASC("Z") // 数値を0〜25の範囲に正規化 normalizedNumber = IIF(num >= 0, num MOD 26, INT(ABS(num / 26) + 1) * 26 + num) 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") // 数値を0〜25の範囲に正規化 normalizedNumber = IIF(num >= 0, num MOD 26, INT(ABS(num / 26) + 1) * 26 + num) 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 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
FUNCTION dateAdd(interval, num, date) GETTIME(0, date) SELECT interval CASE "yyyy" d = (G_TIME_YY + num) + "/" + G_TIME_MM2 + "/" + G_TIME_DD2 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 CASE "d" GETTIME(num, date) d = G_TIME_YY4 + "/" + G_TIME_MM2 + "/" + G_TIME_DD2 CASE "ww" GETTIME(num * 7, date) d = G_TIME_YY4 + "/" + G_TIME_MM2 + "/" + G_TIME_DD2 CASE "h" GETTIME(num / 24, date) d = G_TIME_YY4 + "/" + G_TIME_MM2 + "/" + G_TIME_DD2 + " " + G_TIME_HH2 + ":" + G_TIME_NN2 + ":" + G_TIME_SS2 CASE "n" GETTIME(num / 1440, date) d = G_TIME_YY4 + "/" + G_TIME_MM2 + "/" + G_TIME_DD2 + " " + G_TIME_HH2 + ":" + G_TIME_NN2 + ":" + G_TIME_SS2 CASE "s" GETTIME(num / 86400, date) d = G_TIME_YY4 + "/" + G_TIME_MM2 + "/" + G_TIME_DD2 + " " + G_TIME_HH2 + ":" + G_TIME_NN2 + ":" + G_TIME_SS2 SELEND result = d FEND
FUNCTION dateDiff(interval, date1, date2) SELECT interval CASE "yyyy" GETTIME(0, date1) y1 = G_TIME_YY GETTIME(0, date2) y2 = G_TIME_YY d = y2 - y1 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 SELEND RESULT = d FEND
FUNCTION dateString(date) GETTIME(0, date) y = G_TIME_YY4 SELECT TRUE CASE y > 2019 jc = "令和" + (y - 2018) + "年" CASE y = 2019 jc = "令和元年" CASE y > 1989 jc = "平成" + (y - 1988) + "年" CASE y = 1989 jc = "平成元年" CASE y > 1926 jc = "昭和" + (y - 1925) + "年" CASE y = 1926 jc = "昭和元年" CASE y > 1912 jc = "大正" + (y - 1911) + "年" CASE y = 1912 jc = "大正元年" CASE y > 1868 jc = "明治" + (y - 1867) + "年" CASE y = 1868 jc = "明治元年" DEFAULT RESULT = ERR_VALUE EXIT SELEND RESULT = jc + G_TIME_MM2 + "月" + G_TIME_DD2 + "日" 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])" 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) + "/" + xlTEXT(VAL(.SubMatches(1)), "00") + "/" + xlTEXT(VAL(.SubMatches(2)), "00") 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) + "/" + xlTEXT(VAL(.SubMatches(1)), "00") + "/" + xlTEXT(VAL(.SubMatches(2)), "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 + "/" + xlTEXT(VAL(.SubMatches(0)), "00") + "/" + xlTEXT(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 + "/" + xlTEXT(VAL(.SubMatches(0)), "00") + "/" + xlTEXT(VAL(.SubMatches(1)), "00") ENDWITH CASE reTest(str, "^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-" + Pattern["day"] + "$") Matches = reExecute(str, "^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-" + Pattern["day"] + "$") SELECT Matches.Item(0).SubMatches(0) CASE "Jan"; m = "01" CASE "Feb"; m = "02" CASE "Mar"; m = "03" CASE "Apr"; m = "04" CASE "May"; m = "05" CASE "Jun"; m = "06" CASE "Jul"; m = "07" CASE "Aug"; m = "08" CASE "Sep"; m = "09" CASE "Oct"; m = "10" CASE "Nov"; m = "11" CASE "Dec"; m = "12" SELEND GETTIME() date = G_TIME_YY4 + m + Matches.Item(0).SubMatches(1) SELEND RESULT = uwscToSerial(GETTIME(0, date)) FEND
FUNCTION decToBin(dec) bin = "" REPEAT bin = (dec MOD 2) + bin dec = INT(dec/2) UNTIL dec = 0 RESULT = bin FEND
FUNCTION decToHex(dec) RESULT = FORMAT(VAL(dec), 0, -1) FEND
FUNCTION degToRad(deg) DIM pi = 3.14159265358979 RESULT = deg * pi / 180 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 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 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
MODULE ExcelFunction CONST Excel = CREATEOLEOBJ("Excel.Application") FUNCTION ASC(str) RESULT = Excel.Evaluate("ASC(" + str + ")") FEND FUNCTION BAHTTEXT(num) RESULT = Excel.Evaluate("BAHTTEXT(" + num + ")") FEND FUNCTION CHAR(num) RESULT = Excel.Evaluate("CHAR(" + num + ")") FEND FUNCTION CLEAN(str) RESULT = Excel.Evaluate("CLEAN(" + str + ")") FEND FUNCTION CODE(str) RESULT = Excel.Evaluate("CODE(" + str + ")") FEND FUNCTION DATEVALUE(str) RESULT = Excel.Evaluate("DATEVALUE(<#DBL>" + str + "<#DBL>)") FEND FUNCTION YEN(num, digit = "") RESULT = Excel.Evaluate("YEN(" + num + ", " + digit + ")") FEND FUNCTION EXACT(str1, str2) RESULT = Excel.Evaluate("EXACT(" + str1 + ", " + str2 + ")") FEND FUNCTION FIND(str) RESULT = Excel.Evaluate("FIND(" + str + ")") FEND FUNCTION FINDB(str) RESULT = Excel.Evaluate("FINDB(" + str + ")") FEND FUNCTION FIXED(str, digit = "", separator = "") RESULT = Excel.Evaluate("FIXED(" + str + ", " + digit + ", " + separator + ")") FEND FUNCTION LEFT(str, num = "") RESULT = Excel.Evaluate("LEFT(<#DBL>" + str + "<#DBL>, " + num + ")") FEND FUNCTION LEFTB(str, byte = "") RESULT = Excel.Evaluate("LEFTB(" + str + ", " + byte + ")") FEND FUNCTION LEN(str) RESULT = Excel.Evaluate("LEN(<#DBL>" + str + ")") FEND FUNCTION LENB(str) RESULT = Excel.Evaluate("LENB(" + str + ")") FEND FUNCTION LOWER(str) RESULT = Excel.Evaluate("LOWER(" + str + ")") FEND FUNCTION MID(str, start, num) RESULT = Excel.Evaluate("MID(" + str + ", " + start + ", " + num + ")") FEND FUNCTION MIDB(str, start, num) RESULT = Excel.Evaluate("MIDB(" + str + ", " + start + ", " + num + ")") FEND FUNCTION PROPER(str) RESULT = Excel.Evaluate("PROPER(" + str + ")") FEND FUNCTION REPLACE(str, start, length, replace) RESULT = Excel.Evaluate("REPLACE(" + str + ", " + start + ", " + length + ", " + replace + ")") FEND FUNCTION REPLACEB(str, start, byte, replace) RESULT = Excel.Evaluate("REPLACEB(" + str + ", " + start + ", " + byte + ", " + replace + ")") FEND FUNCTION REPT(str, num) RESULT = Excel.Evaluate("REPT(" + str + ", " + num + ")") FEND FUNCTION RIGHT(str, num = "") RESULT = Excel.Evaluate("RIGHT(<#DBL>" + str + "<#DBL>, " + num + ")") FEND FUNCTION RIGHTB(str, byte = "") RESULT = Excel.Evaluate("RIGHTB(" + str + ", " + byte + ")") FEND FUNCTION SEARCH(str, target, start = "") RESULT = Excel.Evaluate("SEARCH(" + str + ", " + target + ", " + start + ")") FEND FUNCTION SEARCHB(str, target, start = "") RESULT = Excel.Evaluate("SEARCHB(" + str + ", " + target + ", " + start + ")") FEND FUNCTION SUBSTITUTE(str1, str2, str3, target = "") RESULT = Excel.Evaluate("SUBSTITUTE(" + str1 + ", " + str2 + ", " + str3 + ", " + target + ")") FEND FUNCTION T(num) RESULT = Excel.Evaluate("T(" + num + ")") FEND FUNCTION TEXT(num, format) RESULT = Excel.Evaluate("TEXT(" + num + ", <#DBL>" + format + "<#DBL>)") FEND FUNCTION TRIM(str) RESULT = Excel.Evaluate("TRIM(" + str + ")") FEND FUNCTION UPPER(str) RESULT = Excel.Evaluate("UPPER(" + str + ")") FEND FUNCTION VALUE(str) RESULT = Excel.Evaluate("VALUE(" + str + ")") FEND ENDMODULE
FUNCTION fact(n) IFB n <> ABS(VARTYPE(n, VAR_INTEGER)) THEN RESULT = ERR_VALUE EXIT ENDIF IFB n = 0 THEN RESULT = 1 EXIT ENDIF IFB n = 1 THEN RESULT = 1 ELSE RESULT = n * fact(n - 1) ENDIF FEND
FUNCTION factDouble(n) IFB n <> ABS(VARTYPE(n, VAR_INTEGER)) THEN RESULT = ERR_VALUE EXIT ENDIF 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 GCD(arr[]) c = LENGTH(arr) 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 size = size + REPLACE(FORMAT(decToHex(tmp[n]), 2), " ", "0") NEXT arr[0] = hexToDec(Endian(size)) // 幅(18~21) DIM width = "" FOR n = 18 TO 21 width = width + REPLACE(FORMAT(decToHex(tmp[n]), 2), " ", "0") NEXT arr[1] = hexToDec(Endian(width)) // 高さ(22~25) DIM height = "" FOR n = 22 TO 25 height = height + REPLACE(FORMAT(decToHex(tmp[n]), 2), " ", "0") NEXT arr[2] = hexToDec(Endian(height)) // ビットの深さ(28~29) DIM bit = "" FOR n = 28 TO 29 bit = bit + REPLACE(FORMAT(decToHex(tmp[n]), 2), " ", "0") NEXT arr[3] = hexToDec(Endian(bit)) RESULT = SLICE(arr) FEND
FUNCTION getBitNumber() SELECT KINDOFOS(TRUE) CASE TRUE RESULT = "64bit" CASE FALSE RESULT = "32bit" SELEND FEND
FUNCTION getDay(date) GETTIME(0, date) RESULT = G_TIME_DD2 FEND
FUNCTION getEndOfMonth(date, m = 0) GETTIME(0, date) IFB m >= 0 THEN year = G_TIME_YY + INT((G_TIME_MM + m + 1) / 12) month = REPLACE(FORMAT(((G_TIME_MM + m + 1) MOD 12), 2), " ", "0") ELSE year = G_TIME_YY + CEIL((G_TIME_MM + m + 1) / 12 - 1) month = REPLACE(FORMAT(G_TIME_MM - (ABS(m + 1) MOD 12), 2), " ", "0") IF EVAL(month) < 0 THEN month = REPLACE(FORMAT(12 + EVAL(month), 2), " ", "0") ENDIF IF month = "00" THEN month = "12" day = "01" d = "" + year + month + day GETTIME(-1, d) RESULT = G_TIME_YY4 + "/" + G_TIME_MM2 + "/" + G_TIME_DD2 FEND
FUNCTION getHour(date) GETTIME(0, date) RESULT = G_TIME_HH2 FEND
FUNCTION getIEObj(str, flg = FALSE) DIM Shell = CREATEOLEOBJ("Shell.Application") SELECT CHKNUM(str) CASE TRUE DIM cnt = 0 SELECT TRUE CASE str > 0 FOR n = 0 TO Shell.Windows.Count - 1 TRY IFB Shell.Windows.Item(n).Name = "Internet Explorer" THEN cnt = cnt + 1 IFB str = cnt THEN RESULT = Shell.Windows.Item(n) EXIT ENDIF ENDIF EXCEPT ENDTRY NEXT CASE str < 0 FOR n = Shell.Windows.Count - 1 TO 0 STEP -1 TRY IFB Shell.Windows.Item(n).Name = "Internet Explorer" THEN cnt = cnt + 1 IFB ABS(str) = cnt THEN RESULT = Shell.Windows.Item(n) EXIT ENDIF ENDIF EXCEPT ENDTRY NEXT CASE str = 0 FOR n = 0 TO Shell.Windows.Count - 1 TRY IF Shell.Windows.Item(n).Name = "Internet Explorer" THEN cnt = cnt + 1 EXCEPT ENDTRY NEXT RESULT = cnt EXIT SELEND CASE FALSE t = GETTIME() REPEAT FOR n = 0 TO Shell.Windows.Count - 1 TRY targetObj = Shell.Windows.Item(n) IFB targetObj.Name = "Internet Explorer" THEN SELECT flg CASE TRUE IFB targetObj.document.title = str OR targetObj.LocationURL = str THEN RESULT = Shell.Windows.Item(n) EXIT ENDIF CASE FALSE IFB POS(str, targetObj.document.title) OR POS(str, targetObj.LocationURL) THEN RESULT = Shell.Windows.Item(n) EXIT ENDIF SELEND ENDIF EXCEPT ENDTRY NEXT UNTIL GETTIME() - t >= 5 SELEND RESULT = ERR_VALUE 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 getMakerName() RESULT = TRIM(REPLACE(DOSCMD("wmic csproduct get Vendor"), "Vendor", "")) FEND
FUNCTION getMinute(date) GETTIME(0, date) RESULT = G_TIME_NN2 FEND
FUNCTION getModelName() RESULT = TRIM(REPLACE(DOSCMD("wmic csproduct get Name"), "Name", "")) FEND
FUNCTION getMonth(date) GETTIME(0, date) RESULT = G_TIME_MM2 FEND
FUNCTION getMUSCUR(n) HASHTBL cur cur[CUR_APPSTARTING] = "砂時計付き矢印カーソル" cur[CUR_ARROW] = "標準矢印カーソル" cur[CUR_CROSS] = "十字カーソル" cur[CUR_HAND] = "ハンドカーソル" cur[CUR_HELP] = "クエスチョンマーク付き矢印カーソル" cur[CUR_IBEAM] = "アイビーム(縦線)カーソル" cur[CUR_NO] = "禁止カーソル" cur[CUR_SIZEALL] = "4方向矢印カーソル" cur[CUR_SIZENESW] = "斜め左下がりの両方向矢印カーソル" cur[CUR_SIZENS] = "上下両方向矢印カーソル" cur[CUR_SIZENWSE] = "斜め右下がりの両方向矢印カーソル" cur[CUR_SIZEWE] = "左右両方向矢印カーソル" cur[CUR_UPARROW] = "垂直の矢印カーソル" cur[CUR_WAIT] = "砂時計カーソル" RESULT = cur[n] FEND
FUNCTION getNthWeekday(n, w, date = EMPTY) 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) RESULT = G_TIME_YY4 + "/" + G_TIME_MM2 + "/" + G_TIME_DD2 FEND
FUNCTION getOSType() HASHTBL os os["10"] = "NT3.5"; os["11"] = "NT4"; os["12"] = "Win2000"; os["13"] = "WinXP"; os["14"] = "Server2003"; os["20"] = "Vista"; os["21"] = "Server2008"; os["22"] = "Windows 7"; os["23"] = "Windows 8"; os["24"] = "Server2012"; os["25"] = "Windows 8.1"; os["30"] = "Windows 10"; os["31"] = "Server2016"; RESULT = os[KINDOFOS()] 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 getSerialNumber() RESULT = TRIM(REPLACE(DOSCMD("wmic csproduct get IdentifyingNumber"), "IdentifyingNumber", "")) FEND
FUNCTION getSerialTime(uwscTime) //「1899/12/30 00:00:00」からdateまでの日数 RESULT = (GETTIME(0, uwscTime) - GETTIME(0, "1899/12/30 00:00:00")) / 86400 FEND
PROCEDURE getSubFolders(var array[], folderspec) DIM FSO = CREATEOLEOBJ("Scripting.FileSystemObject") DIM Folder = FSO.GetFolder(folderspec) DIM Folders = Folder.SubFolders FOR Folder IN Folders arrayPush(array, Folder.Path) getSubFolders(array, Folder.Path) NEXT 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 // テーブルの値を格納するための2次元配列を作成 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 // rowSpan(行結合)とcolSpan(列結合)の両方があれば 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 // rowSpan(行結合)があれば結合セルに「↑」を代入 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 // colSpan(列結合)があれば結合セルに「←」を代入 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(date) //「1970/01/01 09:00:00」からの秒数 RESULT = (GETTIME(0, date) - GETTIME(0, "1970/01/01 09:00:00")) FEND
FUNCTION getVARTYPE(n) HASHTBL type type[VAR_EMPTY] = "Empty" type[VAR_NULL] = "Null" type[VAR_SMALLINT] = "2バイト整数" type[VAR_INTEGER] = "4バイト整数" type[VAR_SINGLE] = "単精度浮動小数点値" type[VAR_DOUBLE] = "倍精度浮動小数点値" type[VAR_CURRENCY] = "通貨型" type[VAR_DATE] = "日付型" type[VAR_DISPATCH] = "オブジェクト" type[VAR_ERROR] = "エラー値" type[VAR_BOOLEAN] = "ブール型" type[VAR_VARIANT] = "バリアント" type[VAR_UNKNOWN] = "未定義のオブジェクト" type[VAR_SBYTE] = "1バイト整数" type[VAR_BYTE] = "1バイト整数" type[VAR_WORD] = "2バイト整数" type[VAR_DWORD] = "4バイト整数" type[VAR_INT64] = "8バイト整数" type[VAR_ASTR] = "ANSI文字列" type[VAR_USTR] = "UNICODE文字列" type[VAR_ARRAY] = "配列" RESULT = type[n] 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 getWiFiInterface(n) DIM arr[] = "名前", "説明", "GUID", "物理アドレス", "状態", "SSID", "BSSID", "ネットワークの種類", "無線の種類", "認証", "暗号", "接続モード", "チャネル", "受信速度", "送信速度", "シグナル", "プロファイル", "ホストされたネットワークの状態" str = DOSCMD("netsh wlan show interface") match = reExecute(str, arr[n] + ".*?:\s(.*?)\r\n") RESULT = match.Item(0).SubMatches.Item(0) FEND
FUNCTION getWiFiPass(SSID) str = DOSCMD("netsh wlan show profiles name=" + SSID + " key=clear") match = reExecute(str, "主要なコンテンツ.*?\r\n") RESULT = TRIM(COPY(match.Item(0).Value, POS(":", match.Item(0).Value)+1)) FEND
FUNCTION getWiFiProfiles() cmd = "netsh wlan show profiles" str = DOSCMD(cmd) matches = reExecute(str, ".*?:\s(.*?)\r\n") num = matches.Count - 1 DIM res[num] FOR n = 0 TO num res[n] = matches.Item(n).SubMatches(0) NEXT RESULT = SLICE(res) FEND
FUNCTION getYear(date) GETTIME(0, date) RESULT = G_TIME_YY4 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"; bin = "" FOR n = 1 TO LENGTH(hex) str = COPY(hex, n, 1) bin = bin + hb[str] NEXT RESULT = bin FEND
FUNCTION hexToDec(hex) dec = 0 hex = STRCONV(hex, SC_LOWERCASE) FOR n = 1 TO LENGTH(hex) str = COPY(hex, n, 1) IFB CHKNUM(str) THEN num = str ELSE num = ASC(str) - 87 ENDIF dec = dec + (num * POWER(16, LENGTH(hex) - n)) NEXT RESULT = dec FEND
FUNCTION Hour(serial) RESULT = REPLACE(FORMAT(INT(serial * 24), 2), " ", "0") FEND
FUNCTION IEBoot() TRY IE = CREATEOLEOBJ("InternetExplorer.Application") EXCEPT EXEC("C:\Program Files\Internet Explorer\iexplore.exe") SLEEP(1.00) ENDTRY REPEAT TRY IE = GETACTIVEOLEOBJ("InternetExplorer.Application") EXCEPT IE = getIEObj(-1) ENDTRY UNTIL IE <> ERR_VALUE IE.Visible = TRUE 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 VAL(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 res = TRUE BREAK ENDIF NEXT RESULT = res FEND
// WiFiに接続しているかどうか FUNCTION isConnectedWiFi() HASHTBL LAN str = SPLIT(DOSCMD("netsh wlan show interface"), "<#CR>") FOR n = 0 TO UBound(str) IFB POS(":", str[n]) THEN arr = SPLIT(str[n], ":") LAN[TRIM(arr[0])] = TRIM(arr[1]) ENDIF NEXT res = FALSE // SSIDが取得できたらWiFiに接続されていると判断 IF LENGTH(LAN["SSID"]) <> 0 THEN res = TRUE RESULT = res FEND
FUNCTION isDate(date) 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))$" match = reExecute(date, Pattern) SELECT match.Count CASE 1 res = TRUE CASE 0 res = FALSE SELEND RESULT = res FEND
FUNCTION isEven(n) IFB n <> VARTYPE(n, VAR_INTEGER) THEN RESULT = ERR_VALUE EXIT ENDIF RESULT = IIF(n MOD 2 = 0, TRUE, FALSE) FEND
FUNCTION isFile(path) RESULT = TRIM(DOSCMD("IF EXIST " + path + " (echo TRUE) ELSE echo FALSE")) FEND
FUNCTION isOdd(n) IFB n <> VARTYPE(n, VAR_INTEGER) THEN RESULT = ERR_VALUE EXIT ENDIF RESULT = IIF(n MOD 2 <> 0, TRUE, FALSE) 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 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 LBound(arr[]) RESULT = UBound(arr) - LENGTH(arr) + 1 FEND
FUNCTION LCM(arr[]) c = LENGTH(arr) DIM arr2[] = arr[c-1], arr[c-2] 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 Left(str, len) RESULT = COPY(str, 1, len) 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 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() RESULT = G_TIME_YY4 + "/" + G_TIME_MM2 + "/" + G_TIME_DD2 + " " + G_TIME_HH2 + ":" + G_TIME_NN2 FEND
FUNCTION PathCleanupSpec(filename) DIM filenameErrChar[12] = "\", "/", ":", "*", "?", "<#DBL>", "<#CR>", "<#TAB>", "<", ">", "|", "[", "]" FOR n = 0 TO UBound(filenameErrChar) filename = REPLACE(filename, filenameErrChar[n], "") NEXT RESULT = filename FEND
MODULE QuotedPrintable FUNCTION encode(str) DIM res = "" FOR n = 1 TO LENGTH(str) DIM s = COPY(str, n, 1) DIM Matches = reExecute(JISToSJIS(decToHex(ExcelFunction.CODE("<#DBL>" + s + "<#DBL>"))), "([0-9A-F]{2})([0-9A-F]{2})") FOR m = 0 TO Matches.Count - 1 res = res + "=" + Matches.Item(m).SubMatches(0) + "=" + Matches.Item(m).SubMatches(1) NEXT NEXT RESULT = res FEND FUNCTION decode(str) DIM res = "" DIM Matches = reExecute(str, "=([0-9A-F]{2})+") DIM n = 0 WHILE n <= Matches.Count - 1 SELECT TRUE CASE hexToDec(Matches.Item(n).SubMatches(0)) >= $81 res = res + ExcelFunction.CHAR(hexToDec(SJISToJIS(Matches.Item(n).SubMatches(0) + Matches.Item(n+1).SubMatches(0)))) n = n + 2 DEFAULT res = res + ExcelFunction.CHAR(hexToDec(Matches.Item(n).SubMatches(0))) n = n + 1 SELEND WEND RESULT = res FEND ENDMODULE
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 REPT(str, num) DIM res IFB ABS(INT(num)) <> num THEN RESULT = ERR_VALUE EXIT ENDIF FOR n = 1 TO num res = res + str NEXT RESULT = res 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 Right(str, len) RESULT = COPY(str, LENGTH(str) - len + 1) 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 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
FUNCTION serialToUNIX(serialTime) RESULT = serialTime - 2209194000 FEND
FUNCTION serialToUwsc(serialTime) //秒から日に単位変換 serialDate = serialTime / 86400 RESULT = GETTIME(serialDate, "18991230000000") FEND
PROCEDURE showSubFolders(path) DIM FSO = CREATEOLEOBJ("Scripting.FileSystemObject") DIM Folder = FSO.GetFolder(path).SubFolders FOR n = 0 TO GETOLEITEM(Folder) - 1 PRINT ALL_OLE_ITEM[n].Path showSubFolders(ALL_OLE_ITEM[n].Path) NEXT 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 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 TEXT(serial, format) SELECT TRUE CASE reTest(format, "\[h+\]") Matches = reExecute(format, "\[(h+)\]") RESULT = TEXT(Hour(serial), strRepeat("0", LENGTH(Matches.Item(0).SubMatches(0)))) CASE reTest(format, "^h+$") Matches = reExecute(format, "^(h+)$") RESULT = TEXT(Hour(serial) 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, "1899/12/30") RESULT = TEXT(G_TIME_MM, "0") CASE format = "mm" GETTIME(serial, "1899/12/30") RESULT = G_TIME_MM2 CASE format = "s" GETTIME(serial, "1899/12/30") RESULT = TEXT(G_TIME_SS, "0") CASE format = "ss" GETTIME(serial, "1899/12/30") RESULT = G_TIME_SS2 CASE format = "yyyy" GETTIME(serial, "1899/12/30") RESULT = G_TIME_YY4 CASE format = "yy" GETTIME(serial, "1899/12/30") RESULT = COPY(G_TIME_YY4, 3, 2) CASE format = "e" SELECT TRUE // 令和 CASE dateDiff("d", "2019/05/01", TEXT(serial, "yyyy/mm/dd")) >= 0 RESULT = TEXT(serial, "yyyy") - 2018 // 平成 CASE dateDiff("d", "1989/01/08", TEXT(serial, "yyyy/mm/dd")) >= 0 RESULT = TEXT(serial, "yyyy") - 1988 // 昭和 CASE dateDiff("d", "1926/12/25", TEXT(serial, "yyyy/mm/dd")) >= 0 RESULT = TEXT(serial, "yyyy") - 1925 // 大正 CASE dateDiff("d", "1912/07/30", TEXT(serial, "yyyy/mm/dd")) >= 0 RESULT = TEXT(serial, "yyyy") - 1911 // 明治 CASE dateDiff("d", "1868/01/25", TEXT(serial, "yyyy/mm/dd")) >= 0 RESULT = TEXT(serial, "yyyy") - 1867 SELEND CASE format = "g" SELECT TRUE // 令和 CASE dateDiff("d", "2019/05/01", TEXT(serial, "yyyy/mm/dd")) >= 0 RESULT = "R" // 平成 CASE dateDiff("d", "1989/01/08", TEXT(serial, "yyyy/mm/dd")) >= 0 RESULT = "H" // 昭和 CASE dateDiff("d", "1926/12/25", TEXT(serial, "yyyy/mm/dd")) >= 0 RESULT = "S" // 大正 CASE dateDiff("d", "1912/07/30", TEXT(serial, "yyyy/mm/dd")) >= 0 RESULT = "T" // 明治 CASE dateDiff("d", "1868/01/25", 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", "2019/05/01", TEXT(serial, "yyyy/mm/dd")) >= 0 RESULT = "令和" // 平成 CASE dateDiff("d", "1989/01/08", TEXT(serial, "yyyy/mm/dd")) >= 0 RESULT = "平成" // 昭和 CASE dateDiff("d", "1926/12/25", TEXT(serial, "yyyy/mm/dd")) >= 0 RESULT = "昭和" // 大正 CASE dateDiff("d", "1912/07/30", TEXT(serial, "yyyy/mm/dd")) >= 0 RESULT = "大正" // 明治 CASE dateDiff("d", "1868/01/25", TEXT(serial, "yyyy/mm/dd")) >= 0 RESULT = "明治" SELEND CASE format = "mmmmm" RESULT = COPY(TEXT(serial, "mmmm"), 1, 1) CASE format = "mmmm" SELECT TEXT(serial, "m") CASE 1; RESULT = "January" CASE 2; RESULT = "February" CASE 3; RESULT = "March" CASE 4; RESULT = "April" CASE 5; RESULT = "May" CASE 6; RESULT = "June" CASE 7; RESULT = "July" CASE 8; RESULT = "August" CASE 9; RESULT = "September" CASE 10; RESULT = "October" CASE 11; RESULT = "November" CASE 12; RESULT = "December" SELEND CASE format = "mmm" RESULT = COPY(TEXT(serial, "mmmm"), 1, 3) CASE format = "dd" GETTIME(serial, "1899/12/30") RESULT = TEXT(G_TIME_DD2, "00") CASE format = "d" GETTIME(serial, "1899/12/30") RESULT = TEXT(G_TIME_DD, "0") CASE format = "aaaa" GETTIME(serial, "1899/12/30") RESULT = getWeekdayName(G_TIME_WW, "aaaa") CASE format = "aaa" GETTIME(serial, "1899/12/30") RESULT = getWeekdayName(G_TIME_WW, "aaa") CASE format = "dddd" GETTIME(serial, "1899/12/30") RESULT = getWeekdayName(G_TIME_WW, "dddd") CASE format = "ddd" GETTIME(serial, "1899/12/30") RESULT = getWeekdayName(G_TIME_WW, "ddd") CASE reTest(format, "(0+\.?0+)?%") Matches = reExecute(format, "(0+\.?0+)?%") RESULT = TEXT(serial * 100, Matches.Item(0).SubMatches(0)) + "%" CASE reTest(format, "^(.*?)\/(.*?)$") // 分母、分子 DIM demon, numer // 分数 DIM frac[1] DIM Pattern = "(\d+\.\d*?(\d+)\2+)" IFB reTest(serial, Pattern) THEN Matches = reExecute(serial, Pattern) // 循環節の桁数 digit = LENGTH(Matches.Item(0).SubMatches(1)) denom = POWER(10, digit) - 1 numer = serial * POWER(10, digit) - serial // 分子が小数なら整数に通分する num = POWER(10, LENGTH(numer) - POS(".", numer)) denom = denom * num numer = numer * num ELSE denom = POWER(10, LENGTH(serial) - POS(".", serial)) numer = serial * denom ENDIF frac[0] = denom frac[1] = numer // 最大公約数を求める n = GCD(frac) denom = frac[0] numer = frac[1] // 既約分数にする denom = denom / n numer = numer / n RESULT = numer + "/" + denom CASE reTest(format, "((#+),?)+") RESULT = reReplace(serial, "$1,", "(\d)(?=(\d{3})+(?!\d))") CASE reTest(format, "(0+)\.?(0+)?") 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 CASE reTest(format, "(.+)?((?:AM?|am?)\/(?:PM?|pm?))(.+)?") DIM arr[2] Matches = reExecute(format, "(.+)?((?:AM?|am?)\/(?:PM?|pm?))(.+)?") res = "" FOR n = 0 TO Matches.Item(0).SubMatches.Count - 1 arr[n] = Matches.Item(0).SubMatches(n) NEXT DIM res[2] FOR n = 0 TO 2 STEP 2 Matches = reExecute(arr[n], "([^yegmdahs]+)?(([yegmdahs])\3{0,})([^yegmdahs]+)?") FOR m = 0 TO Matches.Count - 1 SELECT TRUE // 「m」を含む CASE reTest(Matches.Item(m).SubMatches(1), "m+") // アルファベット部分の前後で「m」が月か分か判断 SELECT TRUE // 「m」が最初に出現するアルファベットなら CASE m = 0 // 次に出現するアルファベットが「d」なら「m」は月 IFB reTest(Matches.Item(m+1).SubMatches(1), "d+") THEN res[n] = res[n] + TEXT(serial, Matches.Item(m).SubMatches(1)) ENDIF // 次に出現するアルファベットが「s」なら「m」は分 IFB reTest(Matches.Item(m+1).SubMatches(1), "s+") THEN res[n] = res[n] + TEXT(INT(serial * 1440) MOD 60, strRepeat("0", LENGTH(Matches.Item(m).SubMatches(1)))) ENDIF // 「m」が2番目(2-1=1)以降に出現するアルファベットなら CASE m >= 1 // 前に出現したアルファベットが「y」なら「m」は月 IFB reTest(Matches.Item(m-1).SubMatches(1), "y+") THEN res[n] = res[n] + TEXT(serial, Matches.Item(m).SubMatches(1)) ENDIF // 前に出現したアルファベットが「h」なら「m」は分 IFB reTest(Matches.Item(m-1).SubMatches(1), "h+") THEN res[n] = res[n] + TEXT(INT(serial * 1440) MOD 60, strRepeat("0", LENGTH(Matches.Item(m).SubMatches(1)))) ENDIF SELEND CASE reTest(Matches.Item(m).SubMatches(1), "^h+$") IFB TEXT(serial, Matches.Item(m).SubMatches(1)) < 12 THEN res[1] = COPY(arr[1], 1, POS("/", arr[1]) - 1) // 午前 ELSE res[1] = COPY(arr[1], POS("/", arr[1]) + 1) // 午後 ENDIF res[n] = res[n] + TEXT(serial, Matches.Item(m).SubMatches(1)) // それ以外ならば DEFAULT res[n] = res[n] + TEXT(serial, Matches.Item(m).SubMatches(1)) SELEND res[n] = Matches.Item(m).SubMatches(0) + res[n] + Matches.Item(m).SubMatches(3) NEXT NEXT RESULT = JOIN(res, "") CASE reTest(format, "(([yegmdahs])\2{0,})([^yegmdahs]+)?") res = "" Matches = reExecute(format, "(([yegmdahs])\2{0,})([^yegmdahs]+)?") FOR n = 0 TO Matches.Count - 1 // mの前がyもしくはmの後がdならば→mは月 SELECT TRUE // 「m」を含む CASE reTest(Matches.Item(n).SubMatches(0), "m+") // アルファベット部分の前後で「m」が月か分か判断 SELECT TRUE // 「m」が最初に出現するアルファベットなら CASE n = 0 // 次に出現するアルファベットが「d」なら「m」は月 IFB reTest(Matches.Item(n+1).SubMatches(0), "d+") THEN res = res + TEXT(serial, Matches.Item(n).SubMatches(0)) ENDIF // 次に出現するアルファベットが「s」なら「m」は分 IFB reTest(Matches.Item(n+1).SubMatches(0), "s+") THEN res = res + TEXT(INT(serial * 1440) MOD 60, strRepeat("0", LENGTH(Matches.Item(n).SubMatches(0)))) ENDIF // 「m」が2番目(2-1=1)以降に出現するアルファベットなら CASE n >= 1 // 前に出現したアルファベットが「y」なら「m」は月 IFB reTest(Matches.Item(n-1).SubMatches(0), "y+") THEN res = res + TEXT(serial, Matches.Item(n).SubMatches(0)) ENDIF // 前に出現したアルファベットが「h」なら「m」は分 IFB reTest(Matches.Item(n-1).SubMatches(0), "h+") THEN res = res + TEXT(INT(serial * 1440) MOD 60, strRepeat("0", LENGTH(Matches.Item(n).SubMatches(0)))) ENDIF SELEND // それ以外ならば DEFAULT res = res + TEXT(serial, Matches.Item(n).SubMatches(0)) SELEND res = res + Matches.Item(n).SubMatches(2) NEXT RESULT = res SELEND FEND
FUNCTION timeValue(str) HASHTBL Pattern Pattern["hour"] = "(1[0-9]|2[0-4]|0?[0-9])" Pattern["minute"] = "([1-5][0-9]|60|0?[0-9])" pattern["second"] = "([1-5][0-9]|60|0?[0-9])" SELECT TRUE CASE reTest(str, Pattern["hour"] + ":" + Pattern["minute"] + ":" + pattern["second"] + " (AM|PM)") Matches = reExecute(str, Pattern["hour"] + ":" + Pattern["minute"] + ":" + pattern["second"] + " (AM|PM)") WITH Matches.Item(0) SELECT .SubMatches(3) CASE "AM" time = (.SubMatches(0) / 24) + (.SubMatches(1) / 1440) + (.SubMatches(2) / 86400) CASE "PM" time = ((.SubMatches(0) + 12) / 24) + (.SubMatches(1) / 1440) + (.SubMatches(2) / 86400) SELEND ENDWITH CASE reTest(str, Pattern["hour"] + ":" + Pattern["minute"] + ":" + pattern["second"]) Matches = reExecute(str, Pattern["hour"] + ":" + Pattern["minute"] + ":" + pattern["second"]) WITH Matches.Item(0) time = (.SubMatches(0) / 24) + (.SubMatches(1) / 1440) + (.SubMatches(2) / 86400) ENDWITH SELEND RESULT = time FEND
FUNCTION today() GETTIME() RESULT = G_TIME_YY4 + "/" + G_TIME_MM2 + "/" + G_TIME_DD2 FEND
PROCEDURE tweet(msg) IE = CREATEOLEOBJ("InternetExplorer.Application") IE.Visible = TRUE IE.Navigate("https://twitter.com") BusyWait(IE) TRY obj = IE.document.getElementsByClassName("name") username = obj.Item(0).innerText EXCEPT IE.Navigate("https://twitter.com/login?lang=ja") BusyWait(IE) IESETDATA(IE, "電話番号/メールアドレス/ユーザー名", "session[username_or_email]", EMPTYPARAM, 2) IESETDATA(IE, "パスワード", "session[password]", EMPTYPARAM, 2) IE.document.forms[2].submit() BusyWait(IE) ENDTRY text = ENCODE(ENCODE(msg, CODE_UTF8), CODE_URL) IE.Navigate("https://twitter.com/intent/tweet?text=" + text) BusyWait(IE) TRY IE.document.forms[1].submit() EXCEPT ENDTRY BusyWait(IE) IFB IE.document.title = "ツイートが投稿されました" THEN PRINT "ツイート完了" ELSE PRINT "ツイート失敗" ENDIF IE.Quit FEND
FUNCTION UBound(array[]) RESULT = RESIZE(array) FEND
FUNCTION uniqueFilename(path) DIM FSO = CREATEOLEOBJ("Scripting.FileSystemObject") IFB FSO.FileExists(path) THEN fol = FSO.GetParentFolderName(path) filename = FSO.GetBaseName(path) extension = FSO.GetExtensionName(path) 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 //「1899/12/30 00:00:00」からの時間 RESULT = 36526 + uwscDate FEND
FUNCTION uwscToUNIX(uwscTime) //秒から日に単位変換 uwscDate = uwscTime / 86400 RESULT = (GETTIME(uwscDate) - GETTIME(uwscDate, "1970/01/01 09:00:00")) 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 xlCODE(str) DIM Excel = CREATEOLEOBJ("Excel.Application") RESULT = Excel.Evaluate("CODE(<#DBL>" + str + "<#DBL>)") FEND
FUNCTION xlTEXT(num, format) DIM Excel = CREATEOLEOBJ("Excel.Application") RESULT = Excel.Evaluate("TEXT(<#DBL>" + num + "<#DBL>, <#DBL>" + format + "<#DBL>)") FEND
FUNCTION YMDToJD(year, month, day, hour = 0, minute = 0, second = 0) 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

この記事は役に立ちましたか?
役に立った 役に立たなかった