0
2

More than 1 year has passed since last update.

adobe ExtendScriptの個人用TIPS

Last updated at Posted at 2022-02-05

外部ライブラリを取り込む

外部ライブラリによく使う関数とかを詰めておくと良い。

//@include "functions.jsx"

コンソール出力関数をわかりやすく

これでd(hogehoge)でコンソール出力が出来る。

function d(obj) {
    $.writeln(obj);
}

配列の合間を詰める。

例えばarray[10] = "test" とかをすれば、配列の0から9まで空の配列が出来る。それを埋めて詰める。

検索すると.filterが使えれば早いらしいのだけれど、無理。for(...on...)を使うと何か逆順になる。ということで、lengthを使って配列数の最大値が取れるのを利用し、undefinedなら飛ばし、間を詰める関数を作った。

function array_close_gap(array) {
    var result = [];
    var j = 0;
    for (i = 0; i < array.length; i++) {
        if (array[i] === undefined) continue;
        result[j] = array[i];
        j++;
    }
    return result;
}
0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2