從腳本中消除空行我有一個腳本,它在 JMP 表內建立第二個腳本,複製該腳本並將其貼上到 JMP 腳本視窗以建立功能腳本。由於實現此目的的本質原因,我在完成的腳本中出現了很多空行,我想消除這些空行。重新格式化並不能解決問題,我對 REGEX 和 GLOBALREPLACE 的嘗試也失敗了。有人成功做到這一點嗎?
我在這裡尋找線索,但我仍然不在那裡。
編寫腳本編輯器腳本 (jmp.com)
自動化和腳本編寫回覆:從腳本中消除空行這是一個想法。它需要一個腳本,基本上刪除所有換行符,然後重新格式化腳本。
重新格式化的腳本重新調整了程式碼
Names Default To Here( 1 );
nw = New Window( "This is a script box",
sb = Script Box( "print(\!" Hello\!");
print(\!" Hello\!");
print(\!" Hello\!");
print(\!" Hello\!");
print(\!" Hello\!");", 300, 100 );
);
sb << Save Text( "$TEMP/Test.jsl" );
nw << close window;
intText = Load Text File( "$TEMP/Test.jsl" );
substitute into(intText,hextochar("0D"), " ");
nw = New Window( "This is a new script box",
sb = Script Box()
);
sb << Append Text( intText );
sb << reformat;
回覆:從腳本中消除空行如果您可以接受所有註解也被刪除的事實(就像在公式編輯器中一樣),您可以使用Char或Parse的魔力:
myScript = Char(
Expr(
For( i = 1, i <= 5, i++,
// Print the value of i.
Print( i );
);
// End expression.
)
);
nw = New Window( "test", <<TYPE></TYPE>
<CODE class=" language-jsl">myScript = Parse( "/* Begin quote. */
For (i = 1, i <= 5, i++,
// Print the value of i.
Print(i);
);
// End expression.");
write(myscript)
by the way: via <CODE class=" language-jsl"><<TYPE><BR />新視窗是一個標準的腳本編輯器視窗 - 具有相同的外觀和感覺(例如用於運行腳本的播放按鈕:)</TYPE>
回覆:從腳本中消除空行我稍微改進了我的程式碼,這不是一個完美的解決方案,但它可能有效
給定

它返回

Names Default To Here( 1 );
nw = New Window( "This is a script box",
sb = Script Box( "print(\!" Hello\!");
print(\!" Hello\!");
print(\!" Hello\!");
// comment
print(\!" Hello\!");
// comment
print(\!" Hello\!");", 300, 100 );
);
sb << Save Text( "$TEMP/Test.jsl" );
nw << close window;
intText = Load Text File( "$TEMP/Test.jsl" );
substitute into(intText,hextochar("0D0D"), "\!n");
substitute into(intText,hextochar("0A0A"), " ");
substitute into(intText,hextochar("2F2F"), "\!n//");
nw = New Window( "This is a new script box",
sb = Script Box()
);
sb << Append Text( intText );
sb << reformat;回覆:從腳本中消除空行謝謝吉姆和霍吉。我很驚訝這實際上是多麼複雜。我原以為在這種情況下可以消除雙迴車的發生。也許 Regex 語句適用於 JMP 表,但不適用於腳本?
ww = New Window( (names), << Script );
ed = ww[Script Box(1)];
Regex( ed, "\n\n", "", GLOBALREPLACE )
回覆:從腳本中消除空行是的,當然,在 JMP 中總有 12 種方法可以做您想做的事...
ww = New Window( "title", << Script );
ed = ww[Script Box(1)];
new window("helper", Button Box ("clean",
mytext = ed << get text;
ed << set text(Regex( mytext, "[\n\r]{2,}", "\n", GLOBALREPLACE ))))回覆:從腳本中消除空行換行空白字元並不完全相同,這可能會導致一些問題。有時 Words() 可以是這樣的乾淨選項
Names Default To Here(1);
nw = New Window("This is a script box",
H List Box(
Panel Box("Long Script",
sb1 = Script Box(
"print(\!" Hello\!");
print(\!" Hello\!");
print(\!" Hello\!");
// comment
print(\!" Hello\!");
// comment
print(\!" Hello\!");",
600,
500
);
),
sb2 = Script Box(, 600, 500)
)
);
// You can also clear tabs if you wish to \t (regex) or \!t (jmp)
Wait(1);
sb2 << Set Text(Regex(sb1 << get text, "[\r\n]+", "\!N", GLOBALREPLACE));
sb2 << reformat;
Wait(1);
sb2 << Set Text("");
Wait(1);
sb2 << Set Text(Concat Items(Words(sb1 << get text, "\!N"), "\!N"));
sb2 << reformat;
Wait(1);
sb2 << Set Text("");
Wait(1);
lines = sb1 << get lines;
empty = Loc(ls, "");
sb2 << Set Text(Concat Items(Remove(lines, As List(empty)), "\!N"));
sb2 << reformat;
在 JMP 中

JSL 語法規則 (jmp.com)
在正規表示式中(通常)

回覆:從腳本中消除空行雅爾莫
強大!不得不稍微修改一下,似乎有一個我沒有立即識別的選項卡。這最終起作用了。
Wait(1);
sb2 << Set Text(Regex(sb1 << get text, "[\r\t]+", "\!N", GLOBALREPLACE));
sb2 << reformat;
回覆:從腳本中消除空行雅爾莫
更好的是,我不需要並行腳本視窗。我可以用這個在一個視窗中進行消除。我將當前腳本視窗指定為 ed,然後我就開始參加比賽了。感謝您的協助。
ed = ww[Script Box(1)];
Wait(1);
ed << Set Text(Regex(ed << get text, "[\r\t]+", "\!N", GLOBALREPLACE));
ed << reformat;