#11 2009-02-11 22:49

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,375

Re: Provide a case-conversion rule

narayan, you were already pointed to the right topic!

Here it is: Preset to check english misspellings

And the exact post with the working script is here:
http://www.den4b.com/forum/viewtopic.php?pid=2289#p2289

Offline

#12 2009-02-12 13:34

narayan
Senior Member
Registered: 2009-02-08
Posts: 470

Re: Provide a case-conversion rule

Look, I did see the threads.

I created two text files:
ChangeCase.pas -> I just copied the script into this text file
misspelled.txt ->list of words in the specified format
   (example- ::xml::XML)

But I do not know what to do after that.

FWIW, I did the following:
2. Changed the extension of the script file from "txt" to "pas"
3. Placed both files in the scripts folder.
4. Restarted ReNamer.  There is no change anywhere.

So now I am at a dead-end, not knowing what to do next.

Tips like the following would be useful to a Pascal programmer, but not to a common user:

There are few ways for doing this operation with just 1 rule:
1) Using single Replace rule, with multiple items delimiter *|*
2) Using single PascalScript rule, which will load those words straight from the external text file

The thread gives two different versions (word-list only; rules+word-list) on the same page, and I am a loss to know which one is correct (or better); or whether any of them will work alone; or what else is needed.

There are too many loose ends for even a user like me (I know RegEx, Java and C++).

Why not put out a clean article that shows exactly what to do step-by-step, instead of this guess-and-DIY approach?

Last edited by narayan (2009-02-12 13:44)

Offline

#13 2009-02-12 15:36

Andrew
Senior Member
Registered: 2008-05-22
Posts: 542

Re: Provide a case-conversion rule

narayan wrote:

FWIW, I did the following:
2. Changed the extension of the script file from "txt" to "pas"
3. Placed both files in the scripts folder.
4. Restarted ReNamer.  There is no change anywhere.

The scripts folder is just that, a folder. Nothing special about it, in that there is no auto-loading defined. Otherwise how will ReNamer decide which script to load out of possibly 100s in that folder?

5. Add a new PascalScript rule. In the PascalScript dialog, load the existing script using the 'Scripts' button (either from the list that display scripts in the scripts folder, else Browse if saved elsewhere). Optionally press 'Compile' to check if all is ok.
6. Add files and press Preview to run the script.

P.S. The text file might need to be placed in the folder where ReNamer's executable resides.

Last edited by Andrew (2009-02-12 21:27)

Offline

#14 2009-02-12 15:44

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,375

Re: Provide a case-conversion rule

narayan, you don't have to create any *.pas files, just add a PascalScript rule with the script from that post...

renamerscriptkk4.gif

And put the "misspelled.txt" in the same folder as ReNamer.exe.

Offline

#15 2009-02-12 18:51

narayan
Senior Member
Registered: 2009-02-08
Posts: 470

Re: Provide a case-conversion rule

Ah! Now we are getting somewhere! smile

I followed Denis' method (pasted the script in the "Configuration" pane of the PascalScript rule. Additionally, I also pressed the Scripts button and then chose the "save script..." option (last in the list). Now this script is added to my list of scripts.

BTW tip for other users: When you open the PascalScript rule, the pane shows three statements. The middle line (a comment) says "Add your script here".  So you may be tempted to paste your script between the begin and end statements. If you do that, the script won't compile. Instead, first delete all the three existing lines and only then paste the script there.

**********
More:

When the rule is used, the preview is terminated because of a critical error.

The error message says:
Line 34
Expression: TRegExpr(comp):Nested*?+pos(4).

If I use the goto facility, I find the following statement in the script:

  S := ReplaceRegEx(S, '\b'+Find+'\b', Replace, False, False);

So what's wrong?

******

Denis, my window is called "add rule"; not "edit rule" as shown in your screenshot. How do I get to THAT window?

Last edited by narayan (2009-02-12 19:04)

Offline

#16 2009-02-12 19:39

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,375

Re: Provide a case-conversion rule

The error message says: Line 34
Expression: TRegExpr(comp):Nested*?+pos(4).

This tell you that the Regular Expression engine has failed because of the incorrect Expression. In your case, it would be because of non alpha-numeric characters in the "misspelled.txt" file. Some characters are interpreted differently by RegEx, e.g. brackets, slashes, dot, star, etc.. - you would need to escape those. Or you need to code up a new replacement function without using RegEx. By the way, what does your "misspelled.txt" file look like?

The middle line (a comment) says "Add your script here"...

It actualy says "Add you code here", not the full script. It makes sense.

My window is called "add rule"; not "edit rule" as shown in your screenshot. How do I get to THAT window?

After you add a new rule, right click on it and select "Edit", or simply double-click it.

narayan, it doesn't look like you really know RegEx, Java and C++ as you say, because if you would - you wouldn't have most of these problems/questions...

Offline

#17 2009-02-13 03:38

narayan
Senior Member
Registered: 2009-02-08
Posts: 470

Re: Provide a case-conversion rule

Denis, my knowledge of the RegEx, Java and C++ has nothing to do with the ability to guess how your program behaves under specific circumstances. So please do not be judgmental about users' knowledge level and provide a clear guideline instead.

Where have you said that the word-list file has to follow RegEx rules?? It is supposed to be a pair of words, each starting with ::.  And I did that exactly as required.

Now it has just two lines-

::html::HTML
::xml::XML

So tell me, if it is not working, how do I bring in RegEx, Java and C++ into this?? Which of those rules would apply here?

*****
The "Edit rule" window is accessible from the list of rules in the main window, but not directly from the main GUI. How intuitive is that?

If I want to edit an existing rule (or edit a new copy of an existing rule), which of the following is more intuitive method?
(a) Add the old rule first as if I am going to apply it to a file (only there is no file here), and then right-click that rule and edit it.
(b) In the "Add rule" window, right click on a rule and edit it or create a copy.
(c) Use a option from the menu system to launch the "Edit rule" window.

My answer: (a) is convoluted, (b) is a bit more easy to guess, and (c) is the most intuitive.

Why? Because when you are thinking of editing a rule, you do not think of adding it first.

When I tinker with my car, I do it in my garage. I do NOT take it on the road first.

******

It actually says "Add you code here", not the full script. It makes sense.

Again, my tip is for the average user, who may not have programming knowledge.
What makes sense to you may not even occur to them even if they tried.
A non-programmer does not even know what he is doing. He just follows the directions.
So oversimplification sometimes avoids a lot of heartburn for those users.

In any case, any help text should be written in "ReNamer for the Complete Idiot" style.
That way, all types of users can benefit from just one help document.
The more knowledgeable users can just skip such mundane details.

Offline

#18 2009-02-13 03:51

prologician
Member
Registered: 2009-01-30
Posts: 84

Re: Provide a case-conversion rule

@narayan: You know, you could simply double-click the rule in the Rules pane in the main GUI window, and it'll let you edit. <Suspects den4b is getting frustrated with the endless barrage of questions...>

And... although I previously never played with Pascal/Delphi either, it's not THAT hard to pick up, if you've had experience with either C or Java (my Iconv script was my first real meaty PascalScript, for example, and my first experience with Pascal or derivatives). Some fiddling, wandering around Delphi Basics (website in the PDF manual), you can learn quite a bit. It's not nearly as hard as you're making it out to be.

I don't know how exactly you're perceiving what ReNamer should be, but I find it quite intuitive, even having not read the PDF manual. You fire it up, you rename, you go on your merry way. Personally, I'm not sure how much simpler the interface really needs to be. Or, if nothing else, simply wandering around the program and trying out stuff... learning via hands on is the best way. smile

Offline

#19 2009-02-13 10:55

Andrew
Senior Member
Registered: 2008-05-22
Posts: 542

Re: Provide a case-conversion rule

1. Copied script from here - http://www.den4b.com/forum/viewtopic.php?pid=2289#p2289 (Changed nothing except name of text file)

2. SpellCheck.txt contents:

::html::HTML
::xml::XML

3. Ran on a bunch of files I created specifically for this test and got this output:

2qui6bd.png

Now, where's the error?

narayan wrote:

Denis, my knowledge of the RegEx, Java and C++ has nothing to do with the ability to guess how your program behaves under specific circumstances.

narayan, if you really know RegEx, Java and C++ like you claim to do, then frankly IMO you ought to be able to figure out any problems with the script quite easily. The error you've described seems to stem from either not copying the script properly, or incorrect input. I don't see it as being symptomatic of a problem with the program's behaviour in any way. PEBKAC! wink

P.S. I wanted to comment on what prologician said, but the reply might have been constituted as being off-topic. So I posted it here.

Offline

#20 2009-02-14 07:42

narayan
Senior Member
Registered: 2009-02-08
Posts: 470

Re: Provide a case-conversion rule

Andrew, I do not know why you find it enjoyable to make offensive comments on a particular visitors' knowledge. Probably that's the only source of joy in your life.

But why mess up a forum like that? You must consider the other visitors who will come to this thread (by searching for the same solution) and have to plod through this needless quibbling before they see the real answer (if any).

Anyhow, while you commented on my knowledge, you have not answered just HOW those rules are applicable here. 

And WHY should I waste time figuring it out? Am I not entitled to treating this application as a black box and use it? Must I tinker with its innards?

Remember- Your answer is not meant for ME alone: They are for even the other non-techie users who may not have the capability to  start with. And they are not concerned with your belief system. So stick to solving issues (if you CAN). Please.

***********
Prologocian,

You have pointed out double-clicking method, which is applicable only after you ADD a rule, as if it is going to be used on some file(s). But when I am in "Maintenance" mode, I will never think of adding a rule there, because at that time I have no files to rename.

Suppose you have an air-travel ticket, and you want to change your seat from window seat to aisle seat. The logical place to change your seat is at the airline's counter; not an aircraft that is on the runway, ready to take off.

Similarly, the most logical place to edit a rule is NOT from the "Rules" pane.

Last edited by narayan (2009-02-14 08:12)

Offline

Board footer

Powered by FluxBB