PDA

View Full Version : Posting new thread does not work



pal
February 5th, 2015, 12:58 PM
I have tried twice to post a new thread about my Python Tools, but the post does not appear.
What is wrong?
I am able to post reply to existing thread, but Post New Thread does not work.
Let's see if this one apprear at the Forum.

Scott Lambert
February 5th, 2015, 04:21 PM
I have tried twice to post a new thread about my Python Tools, but the post does not appear.
What is wrong?
I am able to post reply to existing thread, but Post New Thread does not work.
Let's see if this one apprear at the Forum.

Hi Pauli,

I had that problem with a new thread in the Keyboard forum. I think it is an anti-spam measure, new threads need to be approved before showing up. Just my theory....

Scott

pal
February 7th, 2015, 09:07 AM
Testing to see if I can post a message with a link:

My Python Tools can be found at:
http://koti.mbnet.fi/pkl/vedit/python_tools.htm

rejto12
December 2nd, 2015, 12:07 PM
Hello,

I am also having problems with starting a new thread.

So, I am posting my question here.

The On-Line-Help does list the command,
Del_Block(p,q).

I did set the Block_Begin and Block_End markers. My specific question is: Can I use the Del_Block (p,q) command with Block_Begin in place of p and Block_End in place of q ?

When I type
Del_Block(Block_Begin,Block_End)
I do get an error message.


Thanks as always,


-peter

Scott Lambert
December 3rd, 2015, 08:16 AM
Hi Peter,

I have no problem with using block_begin and block_end with del_block.

What does the error message say?

Scott

rejto12
December 3rd, 2015, 11:28 AM
Hi Peter,

I have no problem with using block_begin and block_end with del_block.

What does the error message say?

Scott

Hi Scott,

The error message does not say anything specific.

Since you have no problems with that command, I have a hunch that my problem is that I am using it in the exceptional case that the block consists of the
space characters, I believe ASCII 32.

Here are the details. I copied a block of configuration commands to my vedit.vdf file. Then of course, I ended up with some duplicates. that I wanted to remove. So, I tried the Vedit command, {Edit, Sort, Sort & remove dupes}. This Vedit command did not work. Then ChriZ pointed out that the Vedit program uses a different definition of string equality from mine. Specifically, two strings are different if they differ from each other by the space characters. Then, I manually deleted the space characters from the string. In short, the Vedit { Sort, & remove dupes } command works like a charm !

The next step was to try to automate this procedure. I came up with the following macro,

Search("|S") Block_Begin(Cur_Pos) End_Of_Line Del_Block(Block_Begin,Block_End)


The first three commands of my macro work. That is to say, the macro highlights a block of space characters. However, the last command,

Del_Block(Block_Begin,Block_End)

dos not work.


I wonder, what do I do wrong ?

Thanks as always.

-peter
-peter

Scott Lambert
December 3rd, 2015, 05:05 PM
Hi Peter,

Not entirely sure what you are looking for.

If you want to delete spaces after the last non-space character on a line, I would suggest:

save_pos
goto_pos(eol_pos) // go to end of line
search("|!|W",reverse+noerr) // search back for non-space
if(return_value>0) { // if found do
char(1) // advance 1 character
block_begin(cur_pos) // set block begin
block_end(eol_pos) // set block end
del_block(block_begin,block_end) // delete block
}
restore_pos

Or do you mean delete extra spaces between words/non-space characters?

You should check out the key_mac.lib in your HOME folder, has a few dealing with removing spaces.

Scott

rejto12
December 3rd, 2015, 08:25 PM
Hi Peter,

Not entirely sure what you are looking for.

If you want to delete spaces after the last non-space character on a line, I would suggest:

save_pos
goto_pos(eol_pos) // go to end of line
search("|!|W",reverse+noerr) // search back for non-space
if(return_value>0) { // if found do
char(1) // advance 1 character
block_begin(cur_pos) // set block begin
block_end(eol_pos) // set block end
del_block(block_begin,block_end) // delete block
}
restore_pos

Or do you mean delete extra spaces between words/non-space characters?

You should check out the key_mac.lib in your HOME folder, has a few dealing with removing spaces.

Scott

Hi Scott,

Your macro works like a charm.

Actually, my problem was only a model problem.

My real problem was to eliminate the duplicates in my vedit_pr.vdf file. I have changed the extension to .txt and I am uploading it.

Thanks as always,

-peter

Scott Lambert
December 4th, 2015, 10:31 AM
Hi Peter,

The attached remdupes.vdm does NOT sort, but will remove dupes regardless of the number of spaces at end of line.

It seems to work on your file for me.

Let me know how it works for you.

Scott

chriz
December 4th, 2015, 11:44 AM
From the file key-mac.lib, Scott mentioned above:



**********
Remove all trailing spaces from the current file.
**********

This is the "Remove trailing spaces" function in the supplied {USER} menu.

[VISUAL EXIT] Replace("|W|>","",BEGIN+ALL+NOERR)


So:

1.) {User, Remove trailing spaces}
2.) {Edit, Sort, Sort & remove dupes}

rejto12
December 4th, 2015, 08:10 PM
Hi Peter,

The attached remdupes.vdm does NOT sort, but will remove dupes regardless of the number of spaces at end of line.

It seems to work on your file for me.

Let me know how it works for you.

Scott

Hi Scott,
It works like a charm for me too. I used it on an enhanced vedit_pr.vdf file. I no longer remember the number of items in the file that I have uploaded previously. The present file, to be uploaded has 981 items. OOPs, I lost that file !

For the benefit of other Vedit users, it would be nice if you could use your macro to enhance the supplied sortdupe.vdm macro to treat files which have
"number of spaces at the end of the line". Then, I would keep the present sortdupe.vdm in my MACRO directory and put your enhancement in my
USER_MACRO directory. At the same time, I do hope that Ted will distribute your enhanced macro in the next update of Vedit. You and Christian mention another , similar macro, in the USER_MAC.LIB file I do not know how it is related to your macro. It would be even nicer to have a common enhancement to this macro too.

I find it difficult to keep track of hidden assumptions, like the space requirement of the current sortdupe.vdm macro that implements the {Edit, Sort, Sort & remove dupes} command. So, I am really looking forward to getting your enhanced macro.

-peter.

rejto12
December 4th, 2015, 08:39 PM
From the file key-mac.lib, Scott mentioned above:



So:

1.) {User, Remove trailing spaces}
2.) {Edit, Sort, Sort & remove dupes}

Thanks Christian,

I missed that simple and powerful command. I just learned that the {Edit, Sort, Sort & remove dupes } menu command is implemented by the supplied sortdupe.vdm macro. Is it possible that just adding the command, Replace("|W|>","",BEGIN+ALL+NOERR) from the mentioned KEY-MAC.LIB file to the beginning of that macro would have solved my problem ?

Thanks as always,

-peter

rejto12
December 4th, 2015, 11:15 PM
Thanks Christian,

I missed that simple and powerful command. I just learned that the {Edit, Sort, Sort & remove dupes } menu command is implemented by the supplied sortdupe.vdm macro. Is it possible that just adding the command, Replace("|W|>","",BEGIN+ALL+NOERR) from the mentioned KEY-MAC.LIB file to the beginning of that macro would have solved my problem ?

Thanks as always,

-peter


Hi Christian,

I went ahead and added the "Remove trailing spaces" command from the KEY_MAC.LIB file to the sortdupe.vdm Vedit distribution macro. Then, I created a "space" on my file vedit_pr.vdf and ran the Vedit {Edit, Sort, Sort & remove dupes} menu command on it. It worked like a charm.

I take, if I would have added Scotts's macro to the beginning of that macro, I would have gotten the same result. Since I can not compare the "Remove trailing spaces" command to Scotts's macro, that is also short, I am waiting to hear from him.

Thanks again for your suggestion.

-peter

chriz
December 5th, 2015, 05:03 AM
For the benefit of other Vedit users, it would be nice if you could use your macro to enhance the supplied sortdupe.vdm macro to treat files which have
"number of spaces at the end of the line". Then, I would keep the present sortdupe.vdm in my MACRO directory and put your enhancement in my
USER_MACRO directory. At the same time, I do hope that Ted will distribute your enhanced macro in the next update of Vedit.
...
I find it difficult to keep track of hidden assumptions, like the space requirement of the current sortdupe.vdm macro that implements the {Edit, Sort, Sort & remove dupes} command.

No, I don't think it would be a good idea to have sortdupe.vdm removing trailing spaces on its own!

Peter, in your case those spaces are not relevant, but other users with different data might need them in their data and sort/dupes!

So it is best to keep both functions separate in the distribution. IMHO.

Scott Lambert
December 5th, 2015, 09:25 AM
Hi Peter,

Attached is a version of remdupes that also sorts the file after removing the dupes.

Scott

rejto12
December 5th, 2015, 01:29 PM
No, I don't think it would be a good idea to have sortdupe.vdm removing trailing spaces on its own!

Peter, in your case those spaces are not relevant, but other users with different data might need them in their data and sort/dupes!

So it is best to keep both functions separate in the distribution. IMHO.


Dear Christian, DEar Scott,

So, I have renamed sortdupe.vdm in my USER_MACRO directory to sortdupeW.vdm Here W stands for the Pattern Matching Code W, which is the argument of the Sort function in the added command. Also, I have renamed sortdupe_old.vdm in my MACRO directory to the original sortdupe.vdm

Incidentally, doing these editing/renaming I noticed that you have two Statline messages in your macro. It is certainly nice for the user to know that the macro is working and did not hang up. I also noticed that you use the REGEXPRESIION argument for the Search() command. At present, have no incentive to learn these fancy Search() command arguments. I plan to use it later as a tutorial, when I need it.

A week or so ago, I was struggling with one macro to do this job. Now I have two macros. The other one is the one by Scott who does not use REGULAREXPRESSIONS in the argument of his Secrch() command.

Once again, a big thank you to both of you.

-peter

rejto12
December 6th, 2015, 12:31 AM
Hi Peter,

Attached is a version of remdupes that also sorts the file after removing the dupes.

Scott

Hi Scott,

Your macro works like a charm.

Here are the details: I did run your Vedi Command Extractor, Vecomex.vdm on your Remdupes2.vdm. So, I ended up with a list of Vedit commands of that macro. This gave me the output file, Remdupes.lst. I already had a file, vedit_pr.vdf. So, I merged Remdupes.list into vedit_pr.vdf. Then I wanted to eliminate the duplicates. So, I ran Remdupes2.vdm on the merged file. Then I merged sortdupeW.list into the result. Again, I ran Remdupes.vdm on the result Again, it worked like a charm.

I am going to upload the resulting file, vedit_pr.vdf.

.
-peter

pal
December 13th, 2015, 09:17 AM
Hi Peter,
Attached is a version of remdupes that also sorts the file after removing the dupes.
Scott

I found two problems with your macros.

1. It exits when the first empty line is found, so the rest of the file is not processed.

2. If there is a line like "Quick brown fox jumps" and later there is a line like "Quick brown fox jumps over the lazy dog", the latter line is deleded even if it is not a duplicate.

Further, I think there is no point sorting the file after removing the duplicates. If the file is sorted first, you do not search the entire file for duplicates since they are already on consecutive lines. This may be significant on larger files.
The advantage of your original macro is that the file needs not to be sorted.

Scott Lambert
December 14th, 2015, 08:38 AM
Hi Peter,

Will look into it, when I get a moment.

Scott

rejto12
December 14th, 2015, 03:22 PM
Hi Peter,

Will look into it, when I get a moment.

Scott

Thanks Scott,

This is not a high priority item for me.

Also, since I posted it, I made some progress on my own.

Once again, thanks for considering it.


-peter

Alexander T. Craig
November 1st, 2016, 05:03 AM
I have the same bag