Page 3 of 3

Re: AutoHotkey: Dummy File Creator

Posted: 27 Nov 2008 15:43
by admin
Okay, this is circular indeed. I give up. May others try to explain...

Re: AutoHotkey: Dummy File Creator

Posted: 27 Nov 2008 16:03
by j_c_hallgren
I've only read this thread so may not have all the info, but I'm wondering if Stefan might want a dual fmt display, where the parsed/resolved line of code/variables is shown in either "printable" (as much as it can be) or also in hex, with some way of swapping display mode between the two, as is typically found on many debuggers?

Or maybe just in both formats, with some limitations, so that only first 256 chrs or such be shown in hex?

Maybe I'm way off but that would seem to solve the issue of whether it's a dot or control chr...

Re: AutoHotkey: Dummy File Creator

Posted: 27 Nov 2008 16:25
by Stefan
Thanks, :D 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.


But if others has no problem with that.... it may be only me?....
.... then i have to live with this and handle those chars on my own.
Like i have done on page 1 with
regexreplace $script, <clipboard>, "^[^.](.+)[^.]$", 'new "$1";' ;load $script,,s;

what have droped this extra dots for me.

Thanks for your all support.

Re: AutoHotkey: Dummy File Creator

Posted: 27 Nov 2008 16:40
by j_c_hallgren
Stefan wrote:Thanks, :D 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.
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...

The only problem is that (my guess) we're simply having a real hard time understanding what your issue is since, at times, you're contradicting yourself, IMHO.

Re: AutoHotkey: Dummy File Creator

Posted: 27 Nov 2008 16:41
by jacky
Stefan wrote:But they visible replacement should be dropped at the output... when i want to f.ex. create an file from it.
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.

Everywhere else, the actual characters are obviously used. Just use Try Script and look what goes on when you do execute this script

Code: Select all

  $foo = "foo<crlf>bar";
  msg $foo;
  regexreplace $bar, $foo, "\r", "CR";
  msg $bar;
  copytext $bar;
Never are there any dots (or pilcrow sign for that matter) in $foo, $bar, on the msgbox resulting from msg or copied on your clipboard, only on the debugging/Stepping window.
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.
Oh right, silly me! :roll: 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 trick
msg
------------------------------------------
message being here

..continues..

the end (with a last CRLF right after, hence the empty line)

------------------------------------------
1

Re: AutoHotkey: Dummy File Creator

Posted: 27 Nov 2008 17:45
by admin
jacky wrote:
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.
Oh right, silly me! :roll: 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 trick
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()...

Re: AutoHotkey: Dummy File Creator

Posted: 27 Nov 2008 17:53
by jacky
admin wrote:You are aware that variables / arguments can be huge, e.g. when coming from readfile()...
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?

Re: AutoHotkey: Dummy File Creator

Posted: 27 Nov 2008 19:42
by admin
jacky wrote:
admin wrote:You are aware that variables / arguments can be huge, e.g. when coming from readfile()...
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?
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).

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)"?

Re: AutoHotkey: Dummy File Creator

Posted: 27 Nov 2008 20:50
by jacky
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 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...

Re: AutoHotkey: Dummy File Creator

Posted: 27 Nov 2008 20:57
by Stefan
jacky wrote:
Stefan wrote:But they visible replacement should be dropped at the output... when i want to f.ex. create an file from it.
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.
I didn't have faked my pic nether the error message.

I have explained all in that ==> post where is the script (may buggy, OK) to reproduce this behavior and the screenshot what's happened.

I copied the script here for convenience:
regexreplace $script, <clipboard>, "^(.+)$", 'new "$1";' ;load $script,,s;

Here including test file names for easy trying:
$clip = "TestOne.txt<crlf>TestTwo.txt<crlf>TestThree.txt"; regexreplace $script, $clip, "^(.+)$", 'new "$1";' ;load $script,,s;


"^(.+)$" is an valid RegEx.
Perhaps XY see my RegEx-'$' as an var-'$'?
But Don said already he can't reproduce it :roll:

So O.K.

Re: AutoHotkey: Dummy File Creator

Posted: 27 Nov 2008 21:03
by Stefan
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)"?
Why not both?
"Show" the (maybe cropped) stuff in a Text dialog...(-may be enough most times-) ... and add an [Copy]-button for to copy the whole content?

Re: AutoHotkey: Dummy File Creator

Posted: 27 Nov 2008 22:29
by Muroph
i confess that i was completely lost when i first read this thread, but, after playing aroung with the scripts posted here, i think i finaly understand what is the problem and the cause of the confusion.

the regex

Code: Select all

  regexreplace $script, <clipboard>, "^(.+?)\r\n", 'new "$1"; ';
doesn't work because not all lines end with \r\n.

and the other regex

Code: Select all

regexreplace $script, <clipboard>, "^(.+)$", 'new "$1";' ;load $script,,s;
leaves some non-printable chars inside the argument of the command "new".
these chars are displayed as a middle dot in the filename on the step window and, since they are not valid in filenames, give an error message when creating the files.
but the middle dots are not "escaping" to the output, they are actually some \r or \n that were not removed by the regex.

i tried to fix those regex and this seems to work

Code: Select all

regexreplace $script, <clipboard>, "^\n?(.+?)\r?$", 'new "$1";' ; load $script,,s;

Re: AutoHotkey: Dummy File Creator

Posted: 28 Nov 2008 00:17
by Stefan
Hi Muroph :D
Thanks for your understanding...that's the same i try to explain.

Muroph wrote: i tried to fix those regex and this seems to work

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:

Code: Select all

regexreplace $script, <clipboard>, "^[^.](.+)[^.]$", 'new "$1";' ;load $script,,s;
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.

Re: AutoHotkey: Dummy File Creator

Posted: 28 Nov 2008 02:36
by Muroph
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;
this doen't work so well.
the [^.] will "eat" the 1st char in the 1st filename and the last char in the last file extension.
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.
i don't think it's a bug, since it was caused by a bad regex.
the command "new" did exactly what it was told to do.
try running this

Code: Select all

new "asd<crlf>fgh.zxc";
it's basically the same thing, a filename with an invalid character.

Re: AutoHotkey: Dummy File Creator

Posted: 28 Jun 2009 22:20
by Stefan
I've used jacky's script (http://88.191.26.34/XYscripts/script/batch-new-items)

to play around an make a few Proof of Concept :D

1) i dropped MSG to ask for file or folder and make two menu entries instead
2) i replace invalid chars \/*<>:?|" by _
3) i tested to add an serialize rule to make many same name files/folders with trailing numbers
Syntax: ###namepart?amount?.ext
F.ex.: ###DVD?5 => DVD_1, DVD_2, DVD_3,... DVD_5
F.ex.: ###RenamerTestFile?20?.txt ==> RenamerTestFile_1.txt, RenamerTestFile_2.txt, ... RenamerTestFile_20.txt
4) added POC code to create serialized items with A,B,C...
Syntax: #A#?amount?.ext
F.ex.: #A#?5 => A, B, C, D, E
F.ex.: #A#?8?.exe => A.exe, B.exe, C.exe, ..., H.exe
5) i add 'Edit this script'
6) found Jacky's "QuickGoTo" script with HTML help and played with this too.
(great feature Don, thanks.)
7) allow to create nested path with sub-folders


Nothing much and maybe not fully well thought, but here is it...

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 *;;