RE: [Clip] Dialog for processing Perl RegExp Replacements on open documents
- Hi Sheri
Excellant and thankyou
From: Sheri <silvermoonwoman@...>
Sent: 06 February 2003 04:36
Subject: [Clip] Dialog for processing Perl RegExp Replacements on open
Well, I did it.
I hope some of you will try it. In addition to having Perl installed,
you will probably need to install at least one package/module (Config-
Inifiles). Installation instructions are included.
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.449 / Virus Database: 251 - Release Date: 27/01/2003
[Non-text portions of this message have been removed]
- Hi Alan,
At 12:30 AM 2/6/03 -0800, Alan wrote:
>So, you wrote a software application that integrates with NoteTab. Congratulations! There's power to be had with Perl.Hahaha. <grinning ear to ear>
>You're over my head with the Perl stuff at this point. I'm just begin to get into array and hash let alone your reference, object oriented, namespaces, scalability that Perl has, and whatever elseYou always say that. I'm not over your head, I just persisted until it worked. The subs are pretty similar, reading from or writing to the ini file. Some things, like getting it to run on top and use an icon, came from searching Google groups.
>Does it write to disk/ini each time the replace button is clicked? Or does it only write it if the value(s) have changed from the last button click?Yes, it writes it every time. The trigger event is clicking the Replace button. I'm not sure how I would detect if there has actually been a change in values. I guess if it were worthwhile, I could retrieve the ini values and compare them before deciding to update. But then I would have to declare a whole 'nother bunch of variables. It could probably be done efficiently using arrays, but as you've probably noticed, I've not tried to economize on lines lol.
>Mostly just merely comments follow--no reply needed, ignore portions or all of them if you choose.Actually I appreciate your observations.
>A lot of if elseif if if in a row in that one sub. dunno, but my teacher might recommend a switching or emulated case statement instead (not that it needs be changed--it works good and there's more than one way to do it--teach's reason probly or might be the self documenting code sort of thing--ease 4 a different programmer to step right into, access your codeI'm painfully aware there were better ways to structure things if I really knew what I was doing. hehehe. I think use of if - elsif (doesn't work spelled with an e) is the tip of the iceberg. Hey at least I didn't use Goto's <g>. That would have been my personal preference <G>, more like clipcode.
>Your code works very good. A bit hard to follow though (what does it do along the way) without pseudo codeThis is good to know. I never had a problem with resources while using it, but I didn't run any utilities to check resources either. Sometimes the TK dialog didn't pop up as fast as I'd like, but probably only the first time accessed in a session.
>It's rather efficient with my system resources, that's cool, very cool!
>Took me a moment to catch on to click the taskbar minimizes the dialogDo you mean, to keep it running constantly, or just to get it out of the way? Also has a Windows style minimize button. Neat, when you alt
>Probably capability of, in addition to works on current doc, a replace in files feature and a word boundary feature. While I'm at it: a perl/tk visual displayer feature so as to: in a tk widget, display the text and searched for words, the searched for words show up highlighted in color (bright yellow)--the Vim or Gvim editor has such a feature.Replacing in all open files would be a simple matter. Bring up my own editor window highlighting changes? Sigh. Makes me tired just thinking about trying to figure that out. BTW, when changing in a Notetab outline, "Entire File" is only the current topic.
>I see you made your own dialog instead of using tk::searchdialog module.Yes, and here's a little secret: I used this guy's http://www.alex-adam.de/ visual tool to lay out the widgets. TK::Searchdialog is uses a dialog widget. Dialog widgets can't be packed into a Main Window. They need to be called from some other menu or button, which didn't suit our purpose.
>In addition to Config::IniFiles module that I'd previously installed, I also needed to install Win32::API module. Win 2k latest build of ActiveState Perl 5.61 (not yet the Perl 5.8 -- I need more round toits every day). dunno if W2k any different default module(s) than your OS.Hmmn. I hope everyone who needs it knows now how to get it. Use of the API is what allows the "dialog" to run on-top. Folks, run PPM search API to see the exact name of the installable module. Then PPM Install Win32-API
BTW, I discovered an alternate Perl Gui besides TK called Win32::GUI. Its controls are more Windows-style. I might have discarded TK and tried to use it, except that I couldn't troubleshoot some textual problems with it. For example, I put made a text label, that had the letter "p" in it and couldn't see the descending part of the "p".
>I wish I had more time. I want to learn Perl/Tk when I the time. My Linux/Unix class going well--after month or two gets into basics of C programming and some PerlI stumbled over many parts of my TK and (normal) Perl. I didn't think I'd ever figure out how to tell what was selected in the listboxes. I understand Perl "references" in theory but find it very difficult to put them into practice. I also had a lot of trouble with the static perl script. Variables are fine for Search and Replace texts, but not for Regexp modifiers (g - global and i - case insensitive). Had to use Eval, check it out.
>I can only handle so much learning at once. If I attempt too much all at once I get fragmented.
I'm glad its all finally working. I don't like to give up, so I just kept plugging away at it, and have ignored more important things I need to deal with. When I get ambitious again, I may try to allow for naming and saving searches through the dialog, and loading a named search. I would do it with different section names in the ini. I can see it now, a scrollable combo box showing the section names from the ini ...
I never did figure out how to put a scrollbar under the entry boxes. I'm thankful you can scroll by dragging in the fields.
- At 08:38 AM 2/6/03 -0500, I wrote:
>Neat, when you altSorry, got distracted and didn't finish the sentence. Meant to say, when you Alt+Tab you get to see my icon instead of the TK default icon.
- Hi Sheri,
Thank you! for sharing your accomplishment. It's useful and it'll also help my understanding as I (slowly) learn higher levels of Perl.
>Hey at least I didn't use Goto's <g>. That would have been my personal preference <G>, more like clipcode.Likely you already know that Perl will let you do it that way.
I think that some languages are meant for one kind of structuring (goto) while other languages are meant for structured programming (without using goto)
Yes it still somewhat (to say the least) confuses me to think structured programming (loop is a native thing to a block of code) seems to help to think in levels ie top level and further down level(s) whereby only if certain conditions are met does processing occur in the further down level(s) then it comes back up and out of there ultimately gravitating upward and outward (but down a level(s) again only if needed to do so) and upward and outward towards the end of script where no more code exists. (almost not unlike a maze in certain ways) when the script is running it seeks its way out to the end but it's forced to route and process along the way
>>Took me a moment to catch on to click the taskbar minimizes the dialogThe latter. I run 800 X 600 screen resolution I found the dialog a bit large. So, to see Ntab text, I minimized the dialog. I might prefer it to not stay on top
>Do you mean, to keep it running constantly, or just to get it out of the way?
> Also has a Windows style minimize button. Neat, when you altAs you said, alt + tab. I like the icon! Cool icon.
>Replacing in all open files would be a simple matter. Bring up my own editor window highlighting changes? Sigh. Makes me tired just thinking about trying to figure that out.I didn't mean to wish it on you. What I meant was that if I were to bet on it as to whether or not Perl/Tk has such ability, I would place my bet that yes it does and to do so without relying on any certain editor. I see highlighted or set off by being colored found words as useful--can visual scroll to see what, how much and where they occur in a doc. But I mostly forgot how to use Gvim and certainly haven't used its search highight for long long time--but it can yellow color each and every found word in a doc which I think be useful
My query readout hadn't looked like yours which is the reason I installed win32::api module
But i just query net::smtp turned up nothing so as to lead me believe I'd need install it. But then I did perldoc net/smtp and voilla up comes the doc which means it's installed. And I looked in site\lib and there it is in the net folder, SMTP.pm
I still don't know how to determine all (Perl) packages currently installed. Maybe i do--that is, just search my hard drive for *.pm since I guess a .pm is a Perl Module or at least it's a file for a Perl module.
Ok, i see a bit more on how your latest works. I see the RunStaticPerlRepl.pl clip runs the last or former instance of what I had replaced. And that it pulls values from the ini then runs it on current doc.
(If a person didn't need the visual tk dialog to show) I guess if a person wanted to they could create a Ntab clip wizard that would set their search items and options, save those to ini then have the RunStaticPerlRepl.pl clip run
>Variables are fine for Search and Replace texts, but not for Regexp modifiers (g - global and i - case insensitive). Had to use Eval, check it out.Hmm, I didn't know that. So, a scalar variable works in the match or substitution operator but not outside of it such as you say, in the "option". I saw your eval. perldoc -f eval i guess it sort of forces the processing to happen and can trap error as well- the doc on it be deeper than I currently had time for.
>you can scroll by dragging in the fields.I got lost there on that one.