Re: AutoHotkey: Dummy File Creator
Posted: 27 Nov 2008 15:43
Okay, this is circular indeed. I give up. May others try to explain...
Forum for XYplorer Users and Developers
https://www.xyplorer.com/xyfc2/
We're obviously having a problem in communication here! Because your statements just aren't making any sense to me. If the values that are to be output are shown to you in two ways so that you can see exactly what is occuring, why would that ever affect the output? I'm totally confused at this point...that's like saying that by previewing a file, the contents of the file change...Stefan wrote:Thanks,but no, no dual fmt preview.
I just don't want that that chars get to the output, that is to say i have to remove them on my own.
Again, go back and make some tests, you'll see that there are no dots anywhere but in the Stepping window, as visual feedback used for debugging. As you said, it's done so to show non-printable characters that couldn't be shown otherwise.Stefan wrote:But they visible replacement should be dropped at the output... when i want to f.ex. create an file from it.
Code: Select all
$foo = "foo<crlf>bar";
msg $foo;
regexreplace $bar, $foo, "\r", "CR";
msg $bar;
copytext $bar;Oh right, silly me!admin wrote:By format I meant: in one line, or one argument below the other as shown in the bottom list or what? Including parentheses and semicolons ? ... etc.
msg
------------------------------------------
message being here
..continues..
the end (with a last CRLF right after, hence the empty line)
------------------------------------------
1
You are aware that variables / arguments can be huge, e.g. when coming from readfile()...jacky wrote:Oh right, silly me!admin wrote:By format I meant: in one line, or one argument below the other as shown in the bottom list or what? Including parentheses and semicolons ? ... etc.Well, I'd say if no CRLF are involved it could be as it is currently, only with everything even when there's a lot of characters (no [...])
Otherwise (or all the time, doesn't really matter), probably a simple separator line (e.g. 42 -'s) would do the trickmsg
------------------------------------------
message being here
..continues..
the end (with a last CRLF right after, hence the empty line)
------------------------------------------
1
Yeah, but I wasn't saying show the full content all the time, the basic should stay as it is currently of course. I mean there should be a way to get that full content, because sometimes to debug something you need the full variable content, not just the beginning of it... And I don't really see the use of copying parsed&resolved arguments of a command if we don't get the full thing, in that case we might as well just read it on the Stepping window, no?admin wrote:You are aware that variables / arguments can be huge, e.g. when coming from readfile()...
Okay, I agree. But there still should be a size limit to avoid unnecessary memory usage (for internal reasons I have to make a copy of the original arguments, so the used memory is doubled).jacky wrote:Yeah, but I wasn't saying show the full content all the time, the basic should stay as it is currently of course. I mean there should be a way to get that full content, because sometimes to debug something you need the full variable content, not just the beginning of it... And I don't really see the use of copying parsed&resolved arguments of a command if we don't get the full thing, in that case we might as well just read it on the Stepping window, no?admin wrote:You are aware that variables / arguments can be huge, e.g. when coming from readfile()...
I like Copy because I can paste it in EditPad which makes things easier to work with, especially when dealing lots of data, remove parts and bits, etc Plus, when trying to fix a broken regexp or something, it makes things much easier as well...admin wrote:ADD: Is "Copy" really the best action for debugging? Wouldn't it make more sense to "Show" the stuff in a Text dialog, e.g. "Show Command (Parsed and Resolved)"?
I didn't have faked my pic nether the error message.jacky wrote:Again, go back and make some tests, you'll see that there are no dots anywhere but in the Stepping window, as visual feedback used for debugging. As you said, it's done so to show non-printable characters that couldn't be shown otherwise.Stefan wrote:But they visible replacement should be dropped at the output... when i want to f.ex. create an file from it.
Why not both?admin wrote: ADD: Is "Copy" really the best action for debugging?
Wouldn't it make more sense to "Show" the stuff in a Text dialog, e.g. "Show Command (Parsed and Resolved)"?
Code: Select all
regexreplace $script, <clipboard>, "^(.+?)\r\n", 'new "$1"; ';Code: Select all
regexreplace $script, <clipboard>, "^(.+)$", 'new "$1";' ;load $script,,s;Code: Select all
regexreplace $script, <clipboard>, "^\n?(.+?)\r?$", 'new "$1";' ; load $script,,s;You're right, i had found the same solution, only an other way:Muroph wrote: i tried to fix those regex and this seems to workCode: Select all
regexreplace $script, <clipboard>, "^\n?(.+?)\r?$", 'new "$1";' ; load $script,,s;
Code: Select all
regexreplace $script, <clipboard>, "^[^.](.+)[^.]$", 'new "$1";' ;load $script,,s;this doen't work so well.Stefan wrote:You're right, i had found the same solution, only an other way:Code: Select all
regexreplace $script, <clipboard>, "^[^.](.+)[^.]$", 'new "$1";' ;load $script,,s;
i don't think it's a bug, since it was caused by a bad regex.Stefan wrote:But is this now an bug ... what it seams to me.
Or should we take this as an normal behavior? And let the user do the work around.
Code: Select all
new "asd<crlf>fgh.zxc";Code: Select all
/* Batch New Items
v0.01.0000 2009.01.18 XY v7.80.0032
+ first "new" release
*/
"Batch New File Items... " //: BatchNewItemsfiles
global $type;
$type = 'file';
sub _main;
"Batch New Folder Items... "
global $type;
$type = 'dir';
sub _main;
"_main"
global $XYS_name, $type, $names;
sub _ensureXY;
// ask for new items' names
$names = input("$XYS_name: Enter new ".$type." names, one per line:",,<clipboard>, m);
// check if user wants serialized items, if yes goto sub and come back to _execserialize
substr $serialize, $names,,3;
If ($serialize == "###") {
sub _serialize;
}
elseif ($serialize == "#A#") {
sub _serializeA;
}
else {
sub _exec;
}
"_execserialize"
global $XYS_name, $type, $names;
$names = input("We will create this serialized ".$type." items:",,$names, m);
sub _exec;
"_exec"
global $XYS_name, $type, $names;
// get last 2 bytes
substr $check, $names, -2;
// and make sure it ends with a CRLF
$names = $names . (($check == <crlf>) ? "" : <crlf>);
// replace un-valid chars \/*<>:?|"
IF ($type=="file"){
regexreplace $names, $names, "[\\|/|\*|\<|\>|:|\?\||""""]", "_";
}
else {
regexreplace $names, $names, "[/|\*|\<|\>|:|\?\||""""]", "_";
}
// remove empty lines
regexreplace $names, $names, "(\r\n){2,}", <crlf>;
// turn into a script
regexreplace $script, $names, "(.+?)\r\n", "new <curpath>.""\$1"", $type; ";
// and load it up!
load $script,,s;
-
-
" [ Batch New Items ]"
-
"_serialize"
// Usage: enter ###namepart?amount?.ext as file or ###namepart?amount as dir
// Explanation: ### = trigger to switch to serialize-mode, ? = separator-sign between name/amount/ext
// Example: ###Xyplorer_Tests?3?.txt will create three files Xyplorer_Tests_1.txt,...
// Example: ###Xyplorer_Tests?3 will create three folders Xyplorer_Tests_1,...
global $names;
// get the position of the '?'-signs
strpos $pos1, $names, "?";
strpos $pos2, $names, "?", $pos1+1;
// split the input to get the namepart from it
substr $namepart, $names, 3, $pos1 -3;
// decide if there is an second '?'-sign or not
// and get the amount- and extension-part
IF ($pos2>0){
substr $amount, $names, $pos1 +1, $pos2 -($pos1 +1);
substr $ext, $names, $pos2 +1;
}
else {
substr $amount, $names, $pos1 +1;
$ext = "";
}
//msg "Create " . $amount . " times file/folder " . quote($namepart . $ext) ;
// empty $names var
$names = "";
// build the list of items to create
$X=1;
while ($X <= $amount) {
$names = $names . $namepart . "_" . $X . $ext <crlf>;
$X++;
}
//msg $names,1;
// go back to create the items
sub "_execserialize";
"_serializeA"
// Usage: #A#?amount F.ex.: #A#?10
global $names;
// get the position of the '?'-signs
strpos $pos1, $names, "?";
strpos $pos2, $names, "?", $pos1+1;
// decide if there is an second '?'-sign or not
// and get the amount- and extension-part
IF ($pos2>0){
substr $amount, $names, $pos1 +1, $pos2 -($pos1 +1);
substr $ext, $names, $pos2 +1;
}
else {
substr $amount, $names, $pos1 +1;
$ext = "";
}
// empty $names var
$names = "";
// build the list of items to create
$X=1;
$C=65;
while ($X <= $amount) {
$names = $names . chr($C) . $ext <crlf>;
$X++;
$C++;
If ($C>26) break;
}
//msg $names,1;
// go back to create the items
sub "_execserialize";
"_ensureXY"
global $XYS_name, $XYS_file;
self $XYS_file, file;
getkey $XYS_name, "name", "Internal", $XYS_file;
getkey $xyreq, "requiredXY", "Internal", $XYS_file;
end (compare(<xyver>, $xyreq, v) >= 0),,1;
msg "WARNING: This version of $XYS_name requires XYplorer v$xyreq in order to work properly.<br><br>You are currently running an older version (<xyver>), are you sure you want to continue anyway ?<br><br>Note that this might lead to errors / unexpected results.", 1;
"&About Batch New Items : About"
global $XYS_name, $CJ_tmp;
sub _ensureXY;
self $file, file;
self $path, path;
self $base, base;
getkey $curver, "version", "Internal", $file;
getkey $xyreq, "requiredXY", "Internal", $file;
status "$XYS_name: version $curver";
//
$CJ_tmp = "_getXyauState";
sub _callCommonJacky;
$CJ_tmp = ($CJ_tmp == "_getXyauState") ? "Unable to get XYplorer Automatic Updater integration state -- requires common-jacky.xys" : $CJ_tmp;
//
msg "$XYS_name -- version $curver<br>Requires XYplorer $xyreq (Running: <xyver>)<br><br>This script: $file<br><br>$CJ_tmp";
load *;
"Change&log of Batch New Items : _AutoChangelog"
global $CJ_tmp;
sub _ensureXY;
$CJ_tmp = "_AutoChangelogHTML";
sub _callCommonJacky;
load *;
"- : _sep"
"Chec&k for updates of Batch New Items... : _CheckForAutoUpdates"
global $CJ_tmp;
sub _ensureXY;
$CJ_tmp = "_CheckForAutoUpdates";
sub _callCommonJacky;
load *;
"&Install Batch New Items support in XYplorer Automatic Updater... : _InstallInXYAU"
global $CJ_tmp;
sub _ensureXY;
$CJ_tmp = "_InstallInXYAU";
sub _callCommonJacky;
load *;
"_callCommonJacky"
global $CJ_tmp;
self $file, file;
self $path, path;
getkey $cj_req, "requiredCJ", "Internal", $file;
getkey $cj_ver, "version", "Internal", "common-jacky.xys";
end $cj_ver == "", ($CJ_tmp == '_getXyauState') ? '' : "In order to accomplish the desired operation, you need to have the ""library"" common-jacky.xys installed -- Please download the script file and put it in the same folder as this script file ($path\).", 1;
end (compare($cj_ver, $cj_req, v) == -1), "In order to accomplish the desired operation, you need to have the ""library"" common-jacky.xys v$cj_req or more installed, your current version is v$cj_ver -- Please update to the latest version.", 1;
load "common-jacky", "$CJ_tmp";
-
"Show &Full Menu... : ShowFullMenu"
load *,*;
"Show Standard &Menu... : _ShowMenu"
load *;
-
"Cancel : nothing"
"_nothing"
"_settings"
[Internal]
name="Batch New Items"
version="0.01.0000"
requiredXY="7.80.0032"
requiredCJ="0.01.0004"
CJoptional=1
Url="http://88.191.26.34/XYscripts/download/"
"Edit script : edit"
self $p, file;
Open $p,w;
"&Help : Help"
//$html = readfile("QuickGoToHelp.html");
$html =( '<HTML><TITLE>Batch New Item</TITLE><BODY>
<H2>Syntax / Usage:</H2><br><br>
First chose to create file or folder.<br>
Then enter one item per line in editor window.<br>
(Note: the current context of clipboard is already inserted for your convenience,<br>
this way you may see already an list of items; -if you have paste them before to clipboard.<br>
If you paste nothing for this issue, you may want to clear the content of the editor first.)<br>
<br>
You may edit the list as you like. If you are finished, press [OK].<br>
<br>-------------------------------------<br>
There are two advantage usage of this script:<br>
<br>
Make many same name files/folders with trailing numbers:<br>
<TABLE border="1" bgcolor="beige">
<TR><TD>Syntax:</TD><TD>###namepart?amount[?.ext]</TD><TD></TD><TR>
<TR><TD>F.ex. Folders:</TD><TD>###DVD?5</TD><TD> => DVD_1, DVD_2, DVD_3,... DVD_5</TD><TR>
<TR><TD>F.ex. Files:</TD><TD>###RenamerTestFile?20?.txt</TD><TD> ==> RenamerTestFile_1.txt, ... RenamerTestFile_20.txt</TD><TR>
</TABLE>
<br>
Create serialized items with A,B,C...<br>
<TABLE border="1" bgcolor="beige">
<TR><TD>Syntax:</TD><TD>#A#?amount[?.ext]</TD><TD></TD><TR>
<TR><TD>F.ex. Folders:</TD><TD>#A#?5</TD><TD> => A, B, C, D, E</TD><TR>
<TR><TD>F.ex. Files:</TD><TD>#A#?8?.exe</TD><TD> => A.exe, B.exe, C.exe, ..., H.exe</TD><TR>
</TABLE>
</body></html>');
html($html, 740, 650);
load *;;