[Solved] Option for wrapping Code Editor text and how to remove spaces in field ??

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

ValiantCuriosity
Posts: 128
Joined: Thu Jun 30, 2016 3:08 am

[Solved] Option for wrapping Code Editor text and how to remove spaces in field ??

Post by ValiantCuriosity » Tue Mar 12, 2019 6:55 pm

Your friendly Noob here again!

I have two more questions for the LC gurus:

1. In 2011 this post was written https://forums.livecode.com/viewtopic.php?f=6&t=8616
By now, I'm hoping that an option to wrap text in the script editor window has been added to LC, but...I can't find it. The "/" doesn't always work for me and it is a "royal pain" (no offense meant to any royal members of this forum). As the previous forum user mentioned, an option in preferences is a common feature in every IDE that I've ever used. Is there someplace in LC to set this option. If not, is there a current workaround that doesn't have problems?

2. This one is a tricky question for me that is related to coding:

When I save some text and mix it up with some variables to display in a field, the field adds a bunch of returns. How do I make everything flow in one line without the big spaces.

My code (as well as the code process that was shared with me by others):

Code: Select all

...
//field name2
   put gDollName & " had just come to live with a seamstress named " & gSeamstress & "." & gDollName&" wanted a new dress. Hers was tattered and worn." into field "name2"
When run, the field looks like this:
ExtraReturnsInField.png
ExtraReturnsInField.png (4.9 KiB) Viewed 8263 times
More efficient ways to do this that would be understood by a noob are also encouraged.
As always,
TIA for your encouragement and help.
-Rachel
Last edited by ValiantCuriosity on Tue Mar 12, 2019 8:18 pm, edited 1 time in total.
May I never be cured of my curiosity! :D

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Option for wrapping Code Editor text and how to remove spaces in field ??

Post by dunbarx » Tue Mar 12, 2019 7:17 pm

Hello Rachel.

The script editor does not, as of v8 at least, but I bet also in v.9, wrap text. The "\" is a control character that allows you to break logical lines of code into multiple physical lines for readability. It has never given me any trouble at all.

I pasted your line of code into a button script and got only a single line in the field. This is as it should be, since you did not have any explicit return constants in that line. Are you sure this is what you ran? It appears that there are at least two or three empty lines between the two displayed.

I dn not suppose that the word ".Theodora" would cause the field to wrap, and that the line spacing is so large that there are really only two physical lines in that field? You can test this with a new field right out of the tool palette, and make it really wide.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Option for wrapping Code Editor text and how to remove spaces in field ??

Post by dunbarx » Tue Mar 12, 2019 7:20 pm

Hi.

I do not suppose that there are any returns in the variable "gSeamstress"? Those returns would format the output to multiple lines. You must check that variable.

Craig

ValiantCuriosity
Posts: 128
Joined: Thu Jun 30, 2016 3:08 am

Re: Option for wrapping Code Editor text and how to remove spaces in field ??

Post by ValiantCuriosity » Tue Mar 12, 2019 7:31 pm

Hi Craig,
Thank you for looking at this.

Yes, making the field big is how I discovered what was going on. At first, I thought it was a problem with my actual code. (Naw, that would never happen) :wink:
Finally, I made the field box bigger ... and, there it was, the entire text with the big spaces (maybe 3 return spaces)

When the program runs, it always inserts the returns after the variable.

Just saw your second note. Good idea! I never thought of that, but I reentered the variable text into it's field and there was no change to the program when run. I wonder, does a return get automatically entered when typing into a field? Somewhere in my reading I found a reference to removing the return with code, but I don't remember where I read that.

I have no clue how to fix this. I have been head banging over it since you guys helped me last.

-Rachel
May I never be cured of my curiosity! :D

Klaus
Posts: 14197
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Option for wrapping Code Editor text and how to remove spaces in field ??

Post by Klaus » Tue Mar 12, 2019 7:42 pm

Hi Rachel,
When the program runs, it always inserts the returns after the variable.
LOL, good one! :D

LC does not these things, I bet the user can hit ENTER or RETURN after entering text, that's how the extra CRs come into play!

Check "autotab" (Tab on return) for your single line text entry fields, so hitting TAB, ENTER or RETURN will bring the user to the next text entry field.
I wonder, does a return get automatically entered when typing into a field?
No Ma'am! 8)
ISomewhere in my reading I found a reference to removing the return with code, but I don't remember where I read that.
You can remove empty lines in variables/fields with:

Code: Select all

...
filter fld "a field with many CRs in it" without EMPTY
filter aVariableWithManyCRsInIT without EMPTY
...

Best

Klaus

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Option for wrapping Code Editor text and how to remove spaces in field ??

Post by richmond62 » Tue Mar 12, 2019 7:57 pm

At least one reason why the LiveCode 9 scriptEditor cannot wrap text is because there
is NO LiveCode 9 scriptEditor as I found out when I had a "poke around" just now:
-
Screenshot 2019-03-12 at 20.54.17.png
-
Screenshot 2019-03-12 at 20.57.25.png
Screenshot 2019-03-12 at 20.57.25.png (9.42 KiB) Viewed 8239 times
Last edited by richmond62 on Tue Mar 12, 2019 8:31 pm, edited 1 time in total.

Klaus
Posts: 14197
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Option for wrapping Code Editor text and how to remove spaces in field ??

Post by Klaus » Tue Mar 12, 2019 8:03 pm

richmond62 wrote:
Tue Mar 12, 2019 7:57 pm
At least one reason why the LiveCode 9 scriptEditor cannot wrap text is because there
is [b]NO[/b] LiveCode 9 scriptEditor as I found out when I had a "poke around" just now:
-
Screenshot 2019-03-12 at 20.54.17.png
-
Screenshot 2019-03-12 at 20.57.25.png
OMFG! :shock:

So we are just lucky that the LC 8 script editor is compatible with version 9, right? 8)

ValiantCuriosity
Posts: 128
Joined: Thu Jun 30, 2016 3:08 am

Re: Option for wrapping Code Editor text and how to remove spaces in field ??

Post by ValiantCuriosity » Tue Mar 12, 2019 8:18 pm

You saved the day again guys. :D

It looks like the auto tab checkbox "thingie" worked. :mrgreen:

I'll be back...

BTW, one of the most irritating things about working in the Code Editor, is the lack of a decent word wrap option. Of all the things to leave out of a professional environment... Blah, grumble, grumble...

-Rachel
Last edited by ValiantCuriosity on Tue Mar 12, 2019 9:52 pm, edited 1 time in total.
May I never be cured of my curiosity! :D

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: [Solved] Option for wrapping Code Editor text and how to remove spaces in field ??

Post by richmond62 » Tue Mar 12, 2019 8:33 pm

OMFG!
"A pain in the bum is worth 2 in the bush."
-
gadfly2.png
gadfly2.png (8.18 KiB) Viewed 8216 times

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: [Solved] Option for wrapping Code Editor text and how to remove spaces in field ??

Post by jacque » Wed Mar 13, 2019 5:05 pm

Autotab will prevent you from entering wrapped text in fields, so you won't get natural paragraphs. That's not a great solution. If there are no actual returns in the text, check the textheight of the field as Craig mentioned. It may be set to use very tall spacing, which would give the visual impression of extra lines.

If that isn't the problem then do this in the message box:

Code: Select all

put the number of lines in field "story field" 
That will tell you if there are really more carriage returns than you expect.

I've never had any issues with the backslash line continuation, but there is one rule. Don't break lines of code inside a quoted literal. LC gets confused when you do that.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

ValiantCuriosity
Posts: 128
Joined: Thu Jun 30, 2016 3:08 am

Re: [Solved] Option for wrapping Code Editor text and how to remove spaces in field ??

Post by ValiantCuriosity » Wed Mar 13, 2019 9:45 pm

Thanks @jacque. I am using the &return in the script and also found the bit about the line size. That tripped me up for a while. I couldn't figure out why my field was looking like it was two fields overplayed with one another.

Yes "/" works, but it is not at all what I'm used to in professional IDEs. Though I'm not much of a coder, I have used a lot of IDEs and dabbled in a number of languages. "Dabbled" is the operant word here. :wink: IMHO, it is much simpler to set an option for wrap text in the IDE and never have to worry about it again....and, "yes", I was also tripped up by the rule that you mentioned for "/". That took some time to figure out as well. I'm certain that it is documented someplace...

Another thing I've wondered about is how to set the first char of a word to a capitol letter. I haven't found that yet. I'm searching for that in my many references now.

The only thing keeping me going with LC is this forum and its members. What a supportive group you all are.

Have a great day. I'm really getting my gray matter exercise with LC.
-Rachel
May I never be cured of my curiosity! :D

Klaus
Posts: 14197
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: [Solved] Option for wrapping Code Editor text and how to remove spaces in field ??

Post by Klaus » Wed Mar 13, 2019 9:52 pm

Yes "/" works,...
BACKSLASH, It is the BACKSLASH -> \
8)

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: [Solved] Option for wrapping Code Editor text and how to remove spaces in field ??

Post by bogs » Wed Mar 13, 2019 10:35 pm

ValiantCuriosity wrote:
Wed Mar 13, 2019 9:45 pm
Another thing I've wondered about is how to set the first char of a word to a capitol letter. I haven't found that yet.
Probably toUpper would do it for you.

http://lessons.livecode.com/m/4071/l/26 ... characters
Image

Klaus
Posts: 14197
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: [Solved] Option for wrapping Code Editor text and how to remove spaces in field ??

Post by Klaus » Wed Mar 13, 2019 10:44 pm

bogs wrote:
Wed Mar 13, 2019 10:35 pm
ValiantCuriosity wrote:
Wed Mar 13, 2019 9:45 pm
... how to set the first char of a word to a capitol letter.
Probably "toUpper" would do it for you.
Ah, yes, and not only in Washington D.C. :D

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: [Solved] Option for wrapping Code Editor text and how to remove spaces in field ??

Post by bogs » Wed Mar 13, 2019 10:53 pm

Klaus wrote:
Wed Mar 13, 2019 10:44 pm
Ah, yes, and not only in Washington D.C. :D
Yah, both sides of that place could use a little "toUpper'ing" :P

Here is a shorter example for you Rachel :)

Code: Select all

on mouseUp
   put field 1 into tmpField
   repeat with x = 1 to the number of lines of tmpField
      put toUpper(the first character of line x of tmpField) into character 1 of line x of field 1
   end repeat
end mouseUp
Image

Post Reply