Page 1 of 1

lineoffset not playing nicely with 'null' entry

Posted: Wed Jul 06, 2016 11:52 am
by jon@armasoft.co.uk
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 !

Re: lineoffset not playing nicely with 'null' entry

Posted: Wed Jul 06, 2016 12:56 pm
by Klaus
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

Re: lineoffset not playing nicely with 'null' entry

Posted: Wed Jul 06, 2016 1:20 pm
by AxWald
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!

Re: lineoffset not playing nicely with 'null' entry

Posted: Wed Jul 06, 2016 2:25 pm
by dunbarx
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

Re: lineoffset not playing nicely with 'null' entry

Posted: Fri Jul 08, 2016 1:13 pm
by jon@armasoft.co.uk
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.

Re: lineoffset not playing nicely with 'null' entry

Posted: Fri Jul 08, 2016 2:28 pm
by AxWald
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!

Re: lineoffset not playing nicely with 'null' entry

Posted: Fri Jul 08, 2016 3:23 pm
by dunbarx
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

Re: lineoffset not playing nicely with 'null' entry

Posted: Fri Jul 08, 2016 6:06 pm
by FourthWorld

Code: Select all

  get lineoffset(cr&cr, cr& MyVar )

Re: lineoffset not playing nicely with 'null' entry

Posted: Sun Jul 10, 2016 2:01 am
by Mikey
That won't find a blank ending line, so you would have to append CR to the back-end, too.

Re: lineoffset not playing nicely with 'null' entry

Posted: Sun Jul 10, 2016 5:44 am
by FourthWorld
Do blank ending "lines" exist in xTalks?

Re: lineoffset not playing nicely with 'null' entry

Posted: Sun Jul 10, 2016 1:47 pm
by Mikey
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.