このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
sakura-macro [2022/01/12 11:36] tanaka [cb_pic.js] |
sakura-macro [2022/02/01 10:31] (現在) tanaka [visible_pack.js] |
||
---|---|---|---|
行 38: | 行 38: | ||
// ----------------------------------------------- | // ----------------------------------------------- | ||
// 1行の最大文字数を指定して改行を入れる | // 1行の最大文字数を指定して改行を入れる | ||
- | // 0x0Dが含まれる時は0x0Fに変換する(確認メッセージ有) | + | // ファイル名に.chopを付けて保存する(改行コードは入力する) |
+ | // 0x0Dが含まれる時は確認メッセージ表示 | ||
+ | // [はい]:0x0D を 0x0F に変換する | ||
+ | // [いいえ]: | ||
+ | // ※ 0x0D:' | ||
// ----------------------------------------------- | // ----------------------------------------------- | ||
main(); | main(); | ||
行 78: | 行 82: | ||
// ペースト | // ペースト | ||
Editor.Paste(0); | Editor.Paste(0); | ||
+ | |||
+ | // 改行コード | ||
+ | var code = parseInt(Editor.InputBox(' | ||
+ | if(isNaN(code)){ | ||
+ | Editor.WarnMsg(' | ||
+ | return; | ||
+ | } | ||
// 名前を指定して保存 | // 名前を指定して保存 | ||
var fileName = Editor.GetFilename() + ' | var fileName = Editor.GetFilename() + ' | ||
- | Editor.FileSaveAs(fileName); | + | Editor.FileSaveAs(fileName, 0, code); |
} | } | ||
</ | </ | ||
行 186: | 行 197: | ||
===== xsort.js ===== | ===== xsort.js ===== | ||
<sxh javascript; | <sxh javascript; | ||
- | TODO | + | // ----------------------------------------------- |
+ | // 複数キーのソート | ||
+ | // [入力方法]{開始位置}: | ||
+ | // ----------------------------------------------- | ||
+ | |||
+ | main(); | ||
+ | |||
+ | function main() { | ||
+ | |||
+ | // キー | ||
+ | var input = Editor.InputBox(' | ||
+ | if(!input) return; | ||
+ | |||
+ | var keys = []; | ||
+ | var inputWords = input.split(',' | ||
+ | var orderWords = inputWords[inputWords.length-1].split(' | ||
+ | if(inputWords.length - 1 == orderWords.length) { | ||
+ | for(var i=0; i< | ||
+ | |||
+ | var words = inputWords[i].split(':' | ||
+ | if(words.length == 2){ | ||
+ | var pos = 0; | ||
+ | var len = 0; | ||
+ | var order = ''; | ||
+ | |||
+ | pos = parseInt(words[0]); | ||
+ | len = parseInt(words[1]); | ||
+ | order = orderWords[i]; | ||
+ | |||
+ | var obj = new Key(pos, len, order); | ||
+ | keys.push(obj); | ||
+ | } | ||
+ | } | ||
+ | } else { | ||
+ | Editor.ErrorMsg(' | ||
+ | return; | ||
+ | } | ||
+ | |||
+ | // 行 | ||
+ | var items = []; | ||
+ | for(var i=1; i< | ||
+ | var line = GetLineStr(i); | ||
+ | |||
+ | var itemKeys = []; | ||
+ | for(var j=0; j< | ||
+ | itemKeys[j] = line.substr(keys[j].pos-1, | ||
+ | } | ||
+ | |||
+ | var objItem = new Item(i, itemKeys); | ||
+ | items.push(objItem); | ||
+ | } | ||
+ | |||
+ | // ソート | ||
+ | items.sort(function(a, | ||
+ | |||
+ | for(var i=0; i< | ||
+ | |||
+ | if(a.key[i] !== b.key[i]) { | ||
+ | if (a.key[i] < b.key[i]) { | ||
+ | return (keys[i].order.toUpperCase() == ' | ||
+ | } | ||
+ | if (a.key[i] > b.key[i]) { | ||
+ | return (keys[i].order.toUpperCase() == ' | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | return 0; | ||
+ | }); | ||
+ | |||
+ | var sortTxt = ''; | ||
+ | for(var i=0; i< | ||
+ | sortTxt += GetLineStr(items[i].lineNo); | ||
+ | } | ||
+ | |||
+ | // 上書き | ||
+ | Editor.SelectAll(); | ||
+ | Editor.InsText(sortTxt); | ||
+ | } | ||
+ | |||
+ | function Key(pos, len, order) { | ||
+ | this.pos = pos; | ||
+ | this.len = len; | ||
+ | this.order = order; | ||
+ | } | ||
+ | |||
+ | function Item(lineNo, | ||
+ | this.lineNo = lineNo; | ||
+ | this.key = key; | ||
+ | } | ||
</ | </ | ||
行 483: | 行 583: | ||
// pic句のバイト数を集計 | // pic句のバイト数を集計 | ||
// PICTURE文字列がN, | // PICTURE文字列がN, | ||
+ | // REDEFINES と OCCURS は未サポートです。 | ||
+ | // ・出現した時は警告を出します。 | ||
+ | // ・出てきた数を数えて警告に表示します。 | ||
// ----------------------------------------------- | // ----------------------------------------------- | ||
行 511: | 行 614: | ||
var picArr = []; | var picArr = []; | ||
+ | var note = ''; | ||
for(var i=lineFrom; i< | for(var i=lineFrom; i< | ||
行 516: | 行 620: | ||
var txt = Editor.GetLineStr(i); | var txt = Editor.GetLineStr(i); | ||
- | // インラインコメント削除 | + | // コメント行 |
- | var commentIndex | + | var arr = txt.match(/ |
- | if(commentIndex > 0) txt = txt.substring(0, | + | if(arr){ |
- | + | note | |
- | commentIndex = txt.indexOf(' | + | continue; |
- | if(commentIndex > 0) txt = txt.substring(0, | + | } |
// PicObj取得 | // PicObj取得 | ||
- | var pic = getPic(txt); | + | var pic = getPic(txt, note); |
if(!pic) continue; | if(!pic) continue; | ||
行 544: | 行 648: | ||
// 配列に入れる | // 配列に入れる | ||
picArr.push(pic); | picArr.push(pic); | ||
+ | |||
+ | note = ''; | ||
} | } | ||
行 564: | 行 670: | ||
} | } | ||
- | function Pic(no, name, type, option, byte, position) { | + | function Pic(no, name, type, option, byte, position, note) { |
this.no = no; | this.no = no; | ||
this.name = name; | this.name = name; | ||
行 571: | 行 677: | ||
this.byte = byte; | this.byte = byte; | ||
this.position = position; | this.position = position; | ||
+ | this.note = note; | ||
} | } | ||
- | + | ||
+ | /** | ||
+ | * コメント行の備考を取得 | ||
+ | */ | ||
+ | function getNote(line) { | ||
+ | |||
+ | var note = ''; | ||
+ | var words = line.split(';' | ||
+ | if(words.length == 2) { | ||
+ | var wds = words[1].split(/ | ||
+ | if(wds.length == 2) { | ||
+ | note = wds[1]; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | return note; | ||
+ | } | ||
/** | /** | ||
* 1行をPicにいれて返す | * 1行をPicにいれて返す | ||
*/ | */ | ||
- | function getPic(line) { | + | function getPic(line, note) { |
var pic = null; | var pic = null; | ||
- | // コメント行は何もしない | + | // インラインコメント削除 |
- | var arr = line.match(/\d{6}(\*|\/)/); | + | var commentIndex |
- | if(arr) return pic; | + | if(commentIndex > 0) line = line.substring(0, |
+ | |||
+ | commentIndex = line.indexOf(' | ||
+ | if(commentIndex > 0) line = line.substring(0, | ||
var found = line.match(/ | var found = line.match(/ | ||
行 588: | 行 715: | ||
// スペースで区切る | // スペースで区切る | ||
- | var words = found[0].split(/ | + | var words = found[0].split(/ |
// 最後のピリオド削除 | // 最後のピリオド削除 | ||
行 606: | 行 733: | ||
} | } | ||
- | // オプション | + | // オプション(レベル、変数名以外) |
var option = []; | var option = []; | ||
var j = 0; | var j = 0; | ||
- | for(var i=picPos+2; i< | + | for(var i=2; i< |
option[j++] = words[i]; | option[j++] = words[i]; | ||
行 622: | 行 749: | ||
if(picPos > 1) { | if(picPos > 1) { | ||
- | pic = new Pic(words[0], | + | pic = new Pic(words[0], |
} | } | ||
} | } | ||
行 801: | 行 928: | ||
} | } | ||
} | } | ||
- | + | ||
+ | /** | ||
+ | * オプション | ||
+ | */ | ||
+ | function getOption(option) { | ||
+ | |||
+ | for(var index in option) { | ||
+ | if(option[index]==' | ||
+ | || option[index]==' | ||
+ | return option[index]; | ||
+ | } | ||
+ | } | ||
+ | return ''; | ||
+ | } | ||
/** | /** | ||
* Pic配列を文字列に変換 | * Pic配列を文字列に変換 | ||
行 814: | 行 955: | ||
txt += ' | txt += ' | ||
txt += picArr[i].type; | txt += picArr[i].type; | ||
+ | var option = getOption(picArr[i].option) | ||
+ | if(option){ | ||
+ | txt += ' ' + getOption(picArr[i].option); | ||
+ | } | ||
txt += ' | txt += ' | ||
txt += picArr[i].byte; | txt += picArr[i].byte; | ||
txt += ' | txt += ' | ||
txt += picArr[i].position; | txt += picArr[i].position; | ||
+ | txt += ' | ||
+ | txt += picArr[i].note; | ||
txt += ' | txt += ' | ||
} | } | ||
行 826: | 行 973: | ||
\\ | \\ | ||
+ |