copy search results of emeditor macro output to clipboard and send it to potplayer - emeditor

i am using the emeditor macro code ExtractLinesContain.jsee (downloaded from emeditor macro library) to search text file for certain text. this code is perfectly working. it is pasting the results to new file. but i want the result to be copied to clipboard and also should be sent to potplayer.
three modifications are required in the above code.
multiple texts are entered using separator '|'. i want to use ',' in place of '|'.
search results to be automatically copied to search results.
the following code to be appeneded to the above macro code.
editor.ExecuteCommandByID(4445);
WshShell = new ActiveXObject( "WScript.Shell" );
WshShell.Run ( "PotPlayerMini64.exe /clipboard" );
please help me.

The ExtractLinesMulti.jsee macro is very old, and I rewrote the macro using the Batch Find/Extract feature of EmEditor instead. Here is the macro that extracts lines that do contain any of the specified multiple strings separated by |:
if( !editor.EnableTab ){
editor.EnableTab = true;
alert( "Please run this macro again." );
Quit();
}
sFind = prompt( "This macro extracts lines that do contain any of the specified multiple strings separated by |:", "" );
if( sFind == "" ){
Quit();
}
var sArr = sFind.split("|");
batch_list = editor.filters;
for( i = 0; i < sArr.length; ++i ) {
batch_list.AddFind(sArr[i],eeFindReplaceCase,0);
}
document.selection.BatchFind(batch_list, eeFindExtract | eeFindLineOnly,0);
document.selection.SelectAll(); // select all text
document.selection.Copy(eeCopyUnicode); // copy the seleciton to the Clipboard
You can add any code you want to the end of this macro.
References: http://www.emeditor.org/en/macro_selection_batch_find.html

Related

How is CTRL-R (reverse-i-search) is implemented in bash terminal?

Example of the reverse search:
(reverse-i-search)`grep': git log | grep master
What is the algorithm used to find a suggestion?
Where does its search space come from ?
A pointer to its source code would be greatly appreciated.
Reverse-i-search is part of GNU Readline Library. The Readline Library facilitates reading line along with editing facilities. The entire source code can be found here.
Source of search space
Following code snippet from the source shows how the source file for history is determined :
/* Return the string that should be used in the place of this
filename. This only matters when you dont specify the
filename to read_history (), or write_history (). */
static char *
history_filename (filename)
const char *filename;
{
char *return_val;
const char *home;
int home_len;
return_val = filename ? savestring (filename) : (char *)NULL;
if (return_val)
return (return_val);
home = sh_get_env_value ("HOME");
#if defined (_WIN32)
if (home == 0)
home = sh_get_env_value ("APPDATA");
#endif
if (home == 0)
return (NULL);
else
home_len = strlen (home);
return_val = (char *)xmalloc (2 + home_len + 8); /* strlen(".history") == 8 */
strcpy (return_val, home);
return_val[home_len] = '/';
#if defined (__MSDOS__)
strcpy (return_val + home_len + 1, "_history");
#else
strcpy (return_val + home_len + 1, ".history");
#endif
return (return_val);
}
savestring() is defined in savestring.c which simply copies the string filename if it is defined.
sh_get_env_value() function is implemented using getenv() function ( provided by <stdlib.h> ) used to get an environment value ( Refer man page getenv(3) ).
As shown, .bash_history or .history ( this is the file that is used in case the function returns NULL ) will be used as source for implementing the search on a Linux system.
Source : histfile.c
How history is stored
The searchable history is stored in a HIST_ENTRY( history list ) array. The data from .bash_history is added to this array. Source : history.c
The record of the commands entered in current session are saved in _rl_saved_line_for_history.
These two are combined into a _rl_search_cxt instance member array ( cxt->lines[] ) using which the search is performed.
Algorithm
The actual search is performed using _rl_isearch_dispatch() and _rl_search_getchar() function.
Short Summary :
The algorithm reads character by character the input deciding what it should do. In case of no interrupts, it adds the character to the search string searching for it in the array. If the string is not found, it moves to next element skipping over same string found again and strings shorter in length than current length of search string. ( Read default : in switch for exact details in _rl_isearch_dispatch() )
In case the string is not found, the bell is dinged. Else, it displays the string but doesn't actually moves there in history list till user accepts the location.

textpad syntax highlighting confused by apostrophe

I'd like to know what to put in textpad's syntax file to fix the issue where, say, in an html file, you're writing a paragraph and an apostrophe creates syntax highlighting until the next aspostrophe.
Ex:
<p>Hi, I'm an example.
lol text here placeholder lorem ipsum I've died.</p>
I've placed in bold what would be color highlighted in textpad, for lack of stackoverflow coloring knowledge. :P It would be seen as similar to <a href='http://string.lol'> where you would normally use a pair of apostrophes or quotes. I realize that the issue may be in the way the syntax file is set up, where it's matching for any apostrophe instead of matching for an apostrophe not separated by a space. Ideally it would also need to match for equal signs and other common characters that would be seen directly next to an apostrophe or quote.
Here's where I believe it could be found inside the syntax file:
[Syntax]
Namespace1 = 6
IgnoreCase = No
InitKeyWordChars = A-Za-z_
KeyWordChars = A-Za-z0-9_
OperatorChars = -+*/!~%^&|=#`.,;:
KeyWordLength =
BracketChars = {[()]}
PreprocStart = #
HexPrefix = 0x
SyntaxStart =
SyntaxEnd =
CommentStart = /*
CommentEnd = */
CommentStartAlt = <!--
CommentEndAlt = -->
SingleComment = //
SingleCommentCol =
SingleCommentAlt =
SingleCommentColAlt =
SingleCommentEsc =
StringsSpanLines = Yes
StringStart = "
StringEnd = "
StringAlt = '
StringEsc = \
CharStart = '
CharEnd = '
CharEsc = \
You have your String options at the bottom, but is textpad capable of accepting some kind of expression matching or regex, and if so, how would I best do this? I've looked on google and here, and the keywords are just too vague to find anything that does exist on the topic, if anything does.
Thank you for any help you can provide.
I fixed this problem by editing the line in perl5.syn that reads
StringAlt = '
to instead be
; StringAlt = '
(the leading semi-colon comments out the StringAlt setting on that line; or you could just delete that line outright).
You need to use
SyntaxStart = <
SyntaxEnd = >
This will restrict syntax highlighting to only be within tags, and it's the best you can do with TextPad.

Reading line by line from one file and Writing to another file using VBScript

I am trying to split a tab delemeted file into pieces with similar header. I have my logic in place. However, I am trying to read input file line by line and writing it to another file. When I open the outptut file it doesn't contain any data. Here is my code.
Can some one help me whats going wrong here?
Note: The below code doesn't contain actual logic of splitting the file
Wscript.Echo "Begin"
InputFile = "test.txt"
Set InputFSO = CreateObject("Scripting.FileSystemObject")
Set InputFileObject = InputFSO.OpenTextFile(InputFile)
HeaderLine = InputFileObject.ReadLine
Do While InputFileObject.AtEndOfStream <> True
strTemp = InputFileObject.SkipLine
Loop
TotalLines = InputFileObject.Line-1
Set OutputFSO = CreateObject("Scripting.FileSystemObject")
Set OutputFileObject = OutputFSO.CreateTextFile("out.txt")
#Code for reading line by line and writing it to another file
Do While not InputFileObject.AtEndOfStream
line = InputFileObject.Readline
OutputFileObject.WriteLine(line)
Loop
Set InputFileObject = Nothing
Set OutputFileObject = Nothing
Wscript.Echo "Completed"
You're looping through the entire input file in the first Do loop when you are trying to get the line count. So the InputFileObject is already "AtEndOfStream" when you hit the second Do loop. Therefore, none of the code inside the second loop is executing.
Consider eliminating the first Do loop and count the lines in the file at the end of the other loop (unless in your real program the logic in the first loop is required?).
The alternative is to close the input file and reopen it. The problem in this case is that you'll wind up reading the file twice.
'Close and reopen the file from the top...
InputFileObject.Close
Set InputFileObject = InputFSO.OpenTextFile(InputFile)

Use wordlist for Codeigniter captcha

I have a wordlist of dictionary words in .txt format. How can I use this with the captcha_helper instead of random characters? I've already extended the captcha_helper file but am having issues integrating my wordlist.txt file for use.
After doing some poking, I found a solution:
// This is the modified version in captcha_helper.php
if($word == ''){
$wordsfile = '../words.php';
$fp = fopen($wordsfile, 'r');
$length = strlen(fgets($fp));
$line = rand(1, (filesize($wordsfile)/$length)-2);
if(fseek($fp, $length*$line) == -1) return FALSE;
$word = trim(fgets($fp));
fclose($fp);
}
But I noticed that sometimes the last letter would get cut off. Is there a way to make sure that the first and last letter never get placed outside of the bounding box?
in this case you can use one function which pass your words randomly to the script to display..
i think this is better option.
instead to work wit

How to strip out particular text using VBScript

I have got below text as string
test = "<span class='convert'>USD 30</span>"
I need to write a function in VBSCript which will take above string as input and will return USD 30 as output.
Please suggest
output = Replace (Replace(test , "<span class='convert'>",""),"</span>","")
If your input text is more complicated than the example you've given, I would recommend using an XML library such as MSXML to parse the text. Otherwise, you can use a regex
Const test = "<span class='convert'>USD 30</span>"
dim regex: set regex = new RegExp
regex.pattern = ">([^<]*)"
dim matches: set matches = regex.execute(test)
dim output: output = Empty
if matches.Count <> 0 then
output = matches(0).submatches(0)
end if
Response.Write output

Resources