Complex itemDelimiter

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9361
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Complex itemDelimiter

Post by richmond62 » Fri Apr 01, 2022 2:49 pm

Here's a side effect of my continuing development of my Devawriter Pro software:
-
Screen Shot 2022-04-01 at 4.46.21 PM.png
Screen Shot 2022-04-01 at 4.46.32 PM.png
-
Attachments
COMPLEX DELIMITER.livecode.zip
Stack
(1.27 KiB) Downloaded 57 times

Klaus
Posts: 13823
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Complex itemDelimiter

Post by Klaus » Fri Apr 01, 2022 3:51 pm

Let me guess, you scripted:

Code: Select all

...
set itemdel to (CR & "-DO NOT EDIT THIS LINE-" & CR)
...
:D

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9361
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Complex itemDelimiter

Post by richmond62 » Fri Apr 01, 2022 4:10 pm

Of course, Klaus; you're the man.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9361
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Complex itemDelimiter

Post by richmond62 » Sat Apr 02, 2022 5:38 pm

SShot 2022-04-02 at 19.35.41.png
SShot 2022-04-02 at 19.35.41.png (44.48 KiB) Viewed 3978 times
SShot 2022-04-02 at 19.35.55.png
SShot 2022-04-02 at 19.35.55.png (23.7 KiB) Viewed 3978 times
-
HOWEVER, as you can see, while the first line using

Code: Select all

set the unicodeText
works well,

the next line goes "all wonky" as it seems impossible to use set with after.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9361
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Complex itemDelimiter

Post by richmond62 » Sat Apr 02, 2022 5:52 pm

Aaaaaah, my favourite activity: answering my own posts:

Code: Select all

set the unicodeText of field "XYZ" to the unicodeText of field "ABC"
put (cr & "--Don't Mess Around--" & cr) after fld "XYZ"
set the unicodeText of field "XYZ" to ((the unicodeText of field "XYZ") & (the unicodeText of field "DEF"))
What a headache. 8)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9361
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Complex itemDelimiter

Post by richmond62 » Sat Apr 02, 2022 6:37 pm

SShot 2022-04-02 at 20.34.40.png
SShot 2022-04-02 at 20.34.40.png (24.24 KiB) Viewed 3966 times
-
Of course, sooner or later, some end-user with sticky fingers is either:

1. Going to edit that line.

2. Delete one or both of the carriage returns.

-----
Read my next rant "Idiot-proofing a GUI." :wink:
-----

Is there a way to make certain lines in a field ineditable?

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7227
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Complex itemDelimiter

Post by jacque » Sun Apr 03, 2022 5:25 pm

The easiest way would be to put the top line into a locked field and the editable text below it in an unlocked one. Then you don't need delimiters.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9361
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Complex itemDelimiter

Post by richmond62 » Sun Apr 03, 2022 6:08 pm

While that is a clever idea it will not work in this use-case as the end-user has to be able to edit ALL text before that
funky itemDelimiter, and ALL the text after it: and the itemDelimiter is used to work out where to dump the edited
sections of text once the end-user has finshed editing (i.e into 2 fields).

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7227
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Complex itemDelimiter

Post by jacque » Sun Apr 03, 2022 7:00 pm

So unlock the top field too.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9361
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Complex itemDelimiter

Post by richmond62 » Sun Apr 03, 2022 7:44 pm

The 'point', as far as there is a point, is for the EDITOR thingy to be a bog-basic single field in a bog-basic substack,
and 95% of the time it only gets the text from one source field in the main monster stack: but this case is the exception.

So, wrestling with the "continue being clever" scenario [and the inevitable 'prawn' who will end up mucking around
with the funky itemDelim and then complain] and the far more goofy (but possibly more sensible) scenario of having
2 fields . . .

Probably have to bow my head and go for the goofy solution. :(

stam
Posts: 2680
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Complex itemDelimiter

Post by stam » Sun Apr 03, 2022 11:43 pm

richmond62 wrote:
Sun Apr 03, 2022 7:44 pm
Probably have to bow my head and go for the goofy solution. :(
no need ;)

put this in your field's script:

Code: Select all

constant kSeparatorText = "do not edit this line" -- or whatever segment of text is going to be unique to the separator line
on rawKeyDown pKeyCode
     local tText
     lock screen 
     set the dontWrap of me to true
     put the text of the selectedLine into tText
     if tText contains kSeparatorText then 
          set the dontWrap of me to false
     else
          set the dontWrap of me to false
          pass rawKeyDown -- passing rawKeyDown allows text editing as normal
     end if    
end rawKeyDown
this will stop editing of the line that contains kSepartorText, but all other lines will edit as expected.

Hope that helps,
Stam

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9361
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Complex itemDelimiter

Post by richmond62 » Mon Apr 04, 2022 8:53 am

Thanks Stam, it does.

However, I chickened out:
-
SShot 2022-04-04 at 10.30.20.png

stam
Posts: 2680
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Complex itemDelimiter

Post by stam » Mon Apr 04, 2022 9:03 am

In fairness that looks like a better design...

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9361
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Complex itemDelimiter

Post by richmond62 » Mon Apr 04, 2022 9:08 am

In fairness that looks like a better design...
Thanks.

I am obviously even more mental than I realised as I spent 8 hours wide awake in bed with that
blasted thing going round and round in my head.
-
SShot 2022-04-04 at 11.56.04.png
-
Attachments
INVERT.livecode.zip
Stack.
(1.01 KiB) Downloaded 50 times

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”