Custom Property to field makes extra line?

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
bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Custom Property to field makes extra line?

Post by bogs » Sat Jan 19, 2019 3:32 pm

I was wondering if anyone has seen (and better yet, knows why) this kind of behavior might happen.

I have a custom property 'cpropTemplate' that I am putting directly into a field. When I counted the lines in a routine in the messagebox, they count correctly, but when I count them out in the field, there is a mysterious 'extra line' added.
Selection_008.png
Another WTH?! moment...
I can correct this through code, i am just not sure why that would be necessary :?
Image

AndyP
Posts: 615
Joined: Wed Aug 27, 2008 12:57 pm
Location: Seeheim, Germany (ex UK)
Contact:

Re: Custom Property to field makes extra line?

Post by AndyP » Sun Jan 20, 2019 9:18 am

Try replacing before with after in your repeat loop and see if you get the correct results.
Andy Piddock
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search

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

Re: Custom Property to field makes extra line?

Post by bogs » Sun Jan 20, 2019 11:10 am

I am afraid I must have explained the problem poorly Andy. I'll try again.

In the picture above, the list under "stkLines", I put those numbers in manually, only the text is in the custom property, which I'll post here -

Code: Select all

[ Home Folder ]


[ Path to resFolder ]


[ Is image Magick installed ]


[ Path to exe ]


[ Path to icon ]


[ Path to converted icon ]

The code I used to put it into the field is really direct, simply

Code: Select all

put the cpropTemplate of stack "stkLines" into field 1 of card 1 of stack "stkLines"
*Edit, I just found out that executing this same line of code directly from the message box results in the field having the correct number of lines. Hmmm.

The code you see in the message box was just to see if I had extra lines in there somehow, and if that was causing the extra line in the field. The only place that code exists was in the message box.

Hopefully, that makes the question clearer, when I copy / paste the custom property contents, it comes out with the correct amount of lines, no issue.

The problem I'm trying to understand is why putting that same text directly into a field causes the text in line 13 to jump to line 14 of the field? And it is always that line, too, no other.

I thought I had originally inserted an extra cr or lf somehow, so I took all that data out and manually put it back in line by line, and I still get this same result. It is a curious issue to me, that is all.

*Edit - The code I used has only 1 other statement in front of it, which puts the cprop of the stack it is running from into a field as well. I wonder if that line is somehow affecting this one, though I can't see how. This is the handler up to the line in question -

Code: Select all

on openStack
   set the toolTipDelay to 10
   // set the defaultFolder to the home folder
   
   // put the template into field 1...
   put the cpropTemplate of this stack into field 1 of this stack // stack this handler runs from
   put the cpropTemplate of stack "stkLines" into field 1 of card 1 of stack "stkLines" // second stack

*Edit 2 - I did also previously make sure that all lines terminated with LF, just in case -
Selection_001.png
LF all the way baby...
Image

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

Re: Custom Property to field makes extra line?

Post by bogs » Sun Jan 20, 2019 12:38 pm

I actually found out why after stepping through code for the bazillionth time :?

In assembling one of the lines before that line, I narrow down an object in a variable (sound familiar? I ran into this exact same thing a few days ago).

Anyway, after getting what i want into the variable, I used the line 'filter without empty'. Apparently, though, this doesn't do what I think should be happening, because even though the variable only has one line of text in it, when it is put into that field the lines following it drop down a line :shock:

I am certainly going to change that line of code to 'put line 1 of var' instead of 'filter without empty', but *now* I am curious as to what filter without empty really should be doing? Is it only supposed to take out empty lines between two points of text, or is it supposed to remove all empty lines?? :roll:
Image

AndyP
Posts: 615
Joined: Wed Aug 27, 2008 12:57 pm
Location: Seeheim, Germany (ex UK)
Contact:

Re: Custom Property to field makes extra line?

Post by AndyP » Sun Jan 20, 2019 1:36 pm

As I understand it, filter without empty will remove all empty lines.
Andy Piddock
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”