Find Replace in Script Editor with cr

Sean Cole (Pi) sean at pidigital.co.uk
Wed Apr 7 01:16:12 EDT 2021


Hi all,
So, the semicolon example was only given as an oversimplification because
most of you didn't read the original post properly, jumped to the
wrong conclusion and then offered irrelevant answers. But then, the
oversimplification gathered the same results of people jumping to the wrong
conclusion by not reading the posts correctly. (It wasn't helped by my /n
\n typo that was jumped on and assumed to be where I was going wrong. It is
the paradox of this forum. Make it comprehensive, people get lost and lose
the point and give the wrong answer. Make it simple and they read more into
it and then equally get it wrong.

The code I deal with on a daily basis is infinitely more complex than a
simple - put the script of someThing into tscript; replace “;” with “;” &
cr in script; Set the script of someThing to tscript - and can do that kind
of thing in my sleep (as I often do, but infinitely more complex).

So, I KNOW all of these SCRIPTING techniques. I'm not interested! I can do
that. NOT A PROBLEM :)

BUT IN THE FIND/REPLACE PANEL !!!??

Can I use a return character (or a wildcard, escaped, coded form) in the
REPLACE field OF THE PANEL. - A simple question.

You CAN use RegEx in the FIND Field. In there you can SEARCH for \n ((I got
it right this time)) which refers to a line feed (or new line). BUT, you
CANNOT, it seems, as best I can find or from the comments made, use \n to
replace or insert a line feed.

In my scripts (the several thousands of them) there are NO (zero, none)
semicolons used to separate commands. It was used ONLY to help give you a
simpler idea of what I was trying to achieve without having to use too much
detail. But this kind of dialogue on a forum filled with 'clever' people
trying to demonstrate how clever they are means they often miss the point
and give answers that do not fulfil the remit! Or just answer a simple
ruddy question.

Here, then, is a 'Real World' example of what I am facing. There are many
variants and not my only issue, but a useful example, sample, demonstration.


*[code]if* field "Level" begins with "Director" and field "UserDisplay" is
not empty and field "UserDisplay" is not "All Agents" and the label of
button "Status" is "All Sales" *then* *put* pidbQueryDatabase( "SELECT *
FROM QGNew where UserID = '" & (fld "UserID" of card 17 stack "QGv3") & "'
AND DealerID = '" & (fld "DealerID" of card 1 stack "QGv3") & "' AND Status
LIKE '%" & ("Sale") & "%' OR UserID = '" & (fld "UserID" of card 17 stack
"QGv3") & "' AND DealerID = '" & (fld "DealerID" of card 1 stack "QGv3") & "'
AND Status LIKE '%" & ("Connect") & "%'") into tMsg
[/code]
That is all on a single line of a script in one of many thousand buttons.
In and of itself is not so much a problem as it is just difficult for me to
plough through when working out what the script is doing. In this button
alone there are 32 lines similar in nature to this.

To make it easier for me to go through, as I arrive at each button to
simplify and correlate and combine into much more elegant code in the card
script, I would like to be able, IN THE FIND REPLACE PANEL, not by code or
porting or anything else, just to search and replace (& ") with (\ cr & ")
(parenthesis used here just to wrap the strings), and (then put) with (then
cr put). Hence, it will look a bit more like this:

[code]
*if* field "Level" begins with "Director" and field "UserDisplay" is not
empty and field "UserDisplay" is not "All Agents" and the label of button
"Status" is "All Sales" *then*
*put* pidbQueryDatabase( "SELECT * FROM QGNew where UserID = '" & (fld
"UserID" of card 17 stack "QGv3") \
& "' AND DealerID = '" & (fld "DealerID" of card 1 stack "QGv3") \
& "' AND Status LIKE '%" & ("Sale") \
& "%' OR UserID = '" & (fld "UserID" of card 17 stack "QGv3") \
& "' AND DealerID = '" & (fld "DealerID" of card 1 stack "QGv3") \
& "' AND Status LIKE '%" & ("Connect") \
& "%'") into tMsg
[/code]

Ideally I'd want it even better than this eventually. But key to doing just
this for now was being able to use a return character in the replace field
of the find/replace panel.

My original question was 'Just wondering if there is a way of replacing
using cr in the find/replace panel of the script editor.'

A simple Yes or No would have been sufficient. Even better, a yes with a
'just use this form : x,y,z' as a sample. I just hoped someone had found a
simple method, especially as the guides and documentation are so woefully
out of date and incomplete. Something more than 'the meaning of life = 42'
and less than 'measuring gravity = the complete works of Sir Isaac Newton',
as long as it actually answers the question asked :)

(And please don't go into the simplification of the SQL requests, the 'if'
condition or any other poop. I'm FULLY aware of this to the nth degree and
is why I'm going through this poop-show of a stack. Over 10 years of
poor/bad/dirty coding that now needs cleaning and refactoring without
rebuilding from the ground up. I'm just working my way through and have
managed 6 of the 801 cards)

Stats for this behemoth:
Number of stacks = 109
   Total number of cards = 801
      Total number of controls = 82579
         Total number of buttons = 19124
         Total Number of fields = 33484
         Total number of groups = 12152
         Total number of graphics = 14359
         Total number of images = 3282
Total Lines of code = 360036

:-)
Sean

On Tue, 6 Apr 2021 at 23:42, doc hawk via use-livecode <
use-livecode at lists.runrev.com> wrote:

>
> sean slipped
>
> > For instance, suppose I have multiple commands on one line separated by ;
> > and I want to search for semicolon and replace with semicolon followed by
> > return character to drop the remaining script onto a new line.
>
> put the script of someThing into tscript
> replace “;” with “;” & cr in script
> Set the script of someTHing to tscript
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list