× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 3/29/2010 2:42 PM, Duane wrote:

If I have a line that looks like the below, where the carrot is the cursor):
Before - "Text to ^ edit."
After - "Text to edit."

The deleteWhiteSpace deletes all the white space between the two string segments, which means I have to insert a blank space. Not bad in this case, but when I want more than one space it starts getting more cumbersome.

It's not Lpex because I'm too stupid to know how to do it in every
version of Lpex (not to mention that I'm on 7.0.0.8 and far, far behind
the rest of the universe due to cost concerns.)

I wrote a little CODE/400 macro to do this. I called it delWhite:

/* delete white space between words */
/* place cursor on line where white space is to be compressed out */
/* given 123 456 789 */
/* cursor ^ */
/* yields 123 456 789 */

/* pull the current line from the buffer */
'extract content'
/* where is the cursor? */
'extract cursorcol'

lineLen = length(content)

/* if cursor at end of line, no white space to compress */
if (cursorCol = lineLen) then return

/* split the line into two parts at the cursor */
rightLen = lineLen-cursorCol+1
left = substr(content, 1, cursorcol-1)
right = substr(content, cursorcol, rightLen)

/* reassemble the line, stripping off leading blanks from the right side */
work = left || strip(right,L,' ')

/* put the modified line back into the buffer */
'set content' work
return

Create a directory on your PC (I ingeniously call mine \buck), create a
new file in it called delWhite.lx CODE/400 will let you edit it by
clicking on it with Windows Explorer.

You'll need to enable macros (a one time process) by issuing the editor
command: extras on \buck

To execute this particular macro, position the cursor in the line, press
ESC and issue the command: macro delWhite Press ESC again and you're
back editing, with the spaces compressed out. That can get old fast, so
it can be assigned to a command key such as alt-x by issuing the editor
command set action.a-x macro delWhite

If you like it enough to use it a lot, you can create a profile, whereby
the assignment is done every time you start CODE/400. Create a
directory on your PC where you will store macros (I call mine
\buck\macros) and create a file named profint.lxu. Make the contents of
that file:
/* profinit.lxu */
/* assign alt-x to compress white space */
'set action.a-x macro delWhite'

None of that ESC command ESC nonsense this way.

An analysis of the macro shows how simple it is to extend CODE/400 to
perform chores that aren't already in the repertoire. It took me a half
hour to write and debug and to write up this email to describe it to the
list.

This probably doesn't help the OP but I have an ulterior motive: I would
like to see Rational expose at least 'set' and 'extract' to an external
scripting language. I'll stop the editorial here and note only that it
was very easy to create and test a Rexx macro / script and it's not at
all easy to do it in WDSC Lpex.

I would love nothing more than for someone to call me a blithering idiot
and show me an Lpex reference that gives me similar functionality.
--buck

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.