Re: getting rid of multiple consecutive blanks ?

John Markley <[email protected]> Tue, 27 Oct 2009 21:15:31 -0400
Newsgroups gmane.comp.handhelds.palm.peditors
Message-ID <[email protected]>
Quoting Voytek Eymont <[email protected]>:


> many thanks for your efforts !

   You are most welcome. I'm not done yet!

> I'll send you via pm a copy of unadultered web snip memo

   Got it.  Comments at the end of this.

> I tried again with the LFdelete, that seems to work well, apart from
> ocassional 'Ad', last time after getting 'Ad', I didn't need to reboot, I
> think ? just quitting pEdit and restart got it 'fixed'

   OK.  There is the potential for the 'Ad' problem with SPdelete  
also, but I have now improved both LFdelete and SPdelete to eliminate  
the only controllable cause I can think of.  The new pScripts are at  
the end of this email.  Delete completely the old versions and paste  
these in instead.  What happens to cause 'Ad' to print is that the  
find'n'replace gets turned off or becomes unresponsive before the  
AllReplace command 'A' and the Done command 'd' come through the event  
queue.  Then when they come through they are treated as ordinary text  
and get printed.  One way this can happen is if there are no  
two-or-more-spaces, nor two-or-more-LF, for SPdelete or LFdelete to  
find.  Then the f&r reports "no match", which derails the process, and  
the A and d characters left hanging in the event queue then print as  
text.  I have fixed this in the new versions so that if there is a no  
match/no find event the pScript just stops, leaving you with the  
untouched original memo.  Due to a difference in the way the REGEXP  
and the no-REGEXP versions work, it was a little more tricky for  
LFdelete than for SPdelete, so the new LF is a bit more complex and  
longer than the new SP.  Now, this only fixes the 'Ad' occurrence if  
the script is run on text where there is nothing for it to find.  If  
you still get it with the new pScripts, something is happening to  
screw up the process.  So if you continue to see it, try to observe  
what is happening and let me know.  If may need to give you a  
debuggerized version to try to figure it out. (This is like beta  
testing of tiny programs with a very small group of testers)!
   I think the SPdelete should now be completely ok for what you want  
(yes/no?). But there remains a potential problem with LFdelete.   
Because SPdelete can run as a REGEXP find, it will identify  
two-or-more spaces and will leave single spaces alone.  So if you run  
it on text that has only single spaces, nothing will happen.  *But*,  
if you run LFdelete on text that only has single LineFeeds, it will  
delete some of those, because even though the find field has two LF's,  
that is processed as "one-or-two", non-REGEXP, rather than  
two-or-more. The reason I say "some of those" is that you don't always  
see LFs in Palm text as empty lines.  They can also be whitespace at  
the end of a line.  So, you can have a line of text with whitespace at  
its end, then only one blank line below that, and then another line of  
text, but the f&r will read this as two contiguous LFs, because it is,  
and delete one resulting in disappearance of the single blank line  
that you really didn't want deleted!  I don't think I can fix this.   
We can't use a REGEXP find because LineFeeds are prohibited, and it  
might not help anyway. I looked into Paul's idea to use the  
visibilator, but that generated some really troublesome issues when  
de-visibilating and I gave it up.  As a consequence, so far all I can  
come up with is either don't run LFdelete on text that has only/mostly  
only single blank lines between lines of text, or do it manually  
rather than by pScript.

> the Colondelete seems more problematic, I seem to get 'mixed results' and,
> my apologies, I now noticed that I have two instances of time, as in, say
> '09:30'....

   I received you sample memo.  I may be able to make it so that  
numeral strings containg a colon are left alone and only letter text  
is processed, but not sure yet.  Would that do it, or are there other  
issues?  The problem I cannot fix is the possibility that a memo might  
contain some alphabetic text containing a colon that you would not  
want cut.  If it 'sees' a colon it'll cut it and the line of text  
preceding it whether you like it or not.

   Here are the new, improved LFdelete and SPdelete:


{LFdelete::
/&runtimeInit[]
/xEpro f
/xEpro T/xEpro W/xEpro R/xEpro r
/p10/p10
/xEpro f
/&script$[@@LFd0@@]}
{LFd0::
/&ifAbort@[$&==0]
/&ifScript@[$&>0,@@LFd1@@]}
{LFd1::
/xEpro f
/xEpro T/xEpro W/xEpro R/xEpro r
/p10/p10
/&script$[@@LFd2@@]}
{LFd2::
/&tap i[080,080]
/&script$[@@LFd3@@]}
{LFd3::
/p10
/xEpro f
/&script$[@@LFd4@@]}
{LFd4:: A
/&script$[@@LFd5@@]}
{LFd5:: d}



{SPdelete::
/&runtimeInit[]
/xEpro f
/xEpro T/xEpro W/xEpro R
/xs/xs
*
/&script$[@@SPd2@@]}
{SPd2::
/&tap i[080,080]
/&script$[@@SPd3@@]}
{SPd3::
/p32
/xEpro f
/&script$[@@SPd4@@]}
{SPd4::
/&ifAbort@[$&==0]
/&ifScript@[$&>0,@@SPd5@@] }
{SPd5::A
/&script$[@@SPd6@@]}
{SPd6:: d}





------------------------------------

Latest pedit/pToolSet/LapTopHack at http://www.osuweb.net/~pc/pca/pc_all.zip
pedit/pToolSet/LapTopHack scripting info/resources at http://www.peditors.com
Peditors Forum http://groups.yahoo.com/group/peditors
Unsubscribe by writing to peditors-unsubscribe-hHKSG33Tihh4sT85+ipIM4ckdKdSAMto@public.gmane.org! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/peditors/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/peditors/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[email protected] 
    mailto:[email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/