lineoffset not playing nicely with 'null' entry

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jon@armasoft.co.uk
Posts: 20
Joined: Mon Apr 18, 2016 10:31 am

lineoffset not playing nicely with 'null' entry

Post by jon@armasoft.co.uk » Wed Jul 06, 2016 11:52 am

I'm trying to use lineoffset to return the correct line from a variable, but if the first entry is 'null' I'm unable to match to the second entry no matter what it contains. All other entries behave as expected. Is this a bug, or am I missing something?

Sample variable below (quotes added to highlight null entry)

""
"Dr"
"Mr"
"Mrs"

lineoffset("Mr",tVar) = 3
lineoffset("Dr",tVar) = 1 !

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

Re: lineoffset not playing nicely with 'null' entry

Post by Klaus » Wed Jul 06, 2016 12:56 pm

Hi Jon,

what version of LC are you using? Just made a test on my Mac with LC 8.01 and got:
lineoffset("Mr",tVar) = 3
lineoffset("Dr",tVar) = 2 !
as exspected!?

Best

Klaus

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: lineoffset not playing nicely with 'null' entry

Post by AxWald » Wed Jul 06, 2016 1:20 pm

Hi,

tested on Win, 6.7.10:

Code: Select all

on mouseUp
   put empty & cr & "Dr" & cr & "Mr" & cr & "Mrs" into MyVar
   ask "What?"
   put lineoffset(it,MyVar)
end mouseUp
Works. Besides that this doesn't find line 1 ;-)

Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

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

Re: lineoffset not playing nicely with 'null' entry

Post by dunbarx » Wed Jul 06, 2016 2:25 pm

Hi.

Not sure what you mean by
Besides that this doesn't find line 1
Did you mean that you cannot FIND empty? If so, even though line 1 is empty, you are correct, and the function will return 0.

Craig Newman

jon@armasoft.co.uk
Posts: 20
Joined: Mon Apr 18, 2016 10:31 am

Re: lineoffset not playing nicely with 'null' entry

Post by jon@armasoft.co.uk » Fri Jul 08, 2016 1:13 pm

Looks like this was a case of LiveCode doing odd things after being open a few days. I've since rebooted my PC and there no longer appears to be a problem with a null entry in the array.

Thanks to all for your input.

As an aside, I also had 4 fields in a datagrid that I could not edit the values of. I eventually deleted the offending fields and recreated them and they now behave perfectly!

Note to self - shut down & restart the PC if suffering from strange behaviour.

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: lineoffset not playing nicely with 'null' entry

Post by AxWald » Fri Jul 08, 2016 2:28 pm

Hi,
dunbarx wrote:Did you mean that you cannot FIND empty? If so, even though line 1 is empty, you are correct, and the function will return 0.
That's what I meant - searching for "" (empty) doesn't find line 1, the empty line ;-)

jon@armasoft.co.uk wrote:As an aside, I also had 4 fields in a datagrid [...]
After trying to understand datagrids, and failing, I decided to clasify 'em as "This isn't fun!" and threw 'em in a coffin together with emacs, regexps, arrays and similar atrocities.
I use to have table fields, they're good enough for me. And when I need to work with the data & sheer text manipulating doesn't do the job, I throw 'em into a db table and have the sql engine sort out the good and the bad ;-)
jon@armasoft.co.uk wrote:Note to self - shut down & restart the PC if suffering from strange behaviour.
Relogging can do this, too, more quickly ;-)

Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

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

Re: lineoffset not playing nicely with 'null' entry

Post by dunbarx » Fri Jul 08, 2016 3:23 pm

Hi.

I do not think one can find nothing directly, though I see what you tried to do. The only way around this is to loop through each line and determine if that line is indeed empty. The upside to that process is that you will find ALL the empty lines.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: lineoffset not playing nicely with 'null' entry

Post by FourthWorld » Fri Jul 08, 2016 6:06 pm

Code: Select all

  get lineoffset(cr&cr, cr& MyVar )
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: lineoffset not playing nicely with 'null' entry

Post by Mikey » Sun Jul 10, 2016 2:01 am

That won't find a blank ending line, so you would have to append CR to the back-end, too.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: lineoffset not playing nicely with 'null' entry

Post by FourthWorld » Sun Jul 10, 2016 5:44 am

Do blank ending "lines" exist in xTalks?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: lineoffset not playing nicely with 'null' entry

Post by Mikey » Sun Jul 10, 2016 1:47 pm

We go round and round on this one. When you query a DB, if the last value is null or empty, the last char in the container will be a CR. The Tao Of LC would specify that you must take that behavior into account.

Post Reply