scrolling list field abnormal behaviour

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
robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

scrolling list field abnormal behaviour

Post by robm80 » Wed Jun 04, 2014 11:23 am

With this script I renew the scrolling list field "index".
It worked perfectly until my "dabasbase" contents 48 lines.
From now on when clicking the button, the index freezes, gets pale and is in strike and I have to start anew, with the same result.
Why?

on mouseUp
filter fld "index" with empty
put the number of lines of fld "DB1" of cd "DB" into tNum
repeat with i = 1 to tNum
put item 1 of line i of fld "DB1" of cd "DB" &cr after fld "index"
end repeat
put number of lines of fld "index" && "namen" into field "zoeknamen"
end mouseUp

thanks, Rob

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

Re: scrolling list field abnormal behaviour

Post by Klaus » Wed Jun 04, 2014 11:54 am

Hi Rob,

the script looks OK!?

Maybe you can find WHERE exactly the freeze happens by adding some anwser dialogs,
so you can see what has been executed and what not to get a little hint:

Code: Select all

on mouseUp 
  filter fld "index" with empty
  answer "filtered"

  ## Accessing FIELDS has a lot of overhead, so better access the CONTENT directly:
  put fld "DB1" of cd "DB" into tDB1
  put the number of lines of tDB1 into tNum
  answer "got data. number of lines:" && tNum

  repeat with i = 1 to tNum

    ## Same here, so better collect the new data in a variable and 
    ## add the data "en bloc" to the field
    put item 1 of line i of tDB1 & cr after tNewIndices
  end repeat 
  put tNewIndices AFTER fld "index"
  answer "new indices" 

  put THE number of lines of fld "index" && "namen" into field "zoeknamen"
end mouseUp
Please try this and tell us what answer dialog actually appeared.


Best

Klaus

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: scrolling list field abnormal behaviour

Post by robm80 » Wed Jun 04, 2014 9:42 pm

Hi Klaus:
The script:
on mouseUp
filter fld "index" with empty
answer "filtered"

## Accessing FIELDS has a lot of overhead, so better access the CONTENT directly:
put fld "DB1" of cd "DB" into tDB1
put the number of lines of tDB1 into tNum
answer "got data. number of lines:" && tNum

repeat with i = 1 to tNum
## Same here, so better collect the new data in a variable and
## add the data "en bloc" to the field
put item 1 of line i of tDB1 & cr after tNewIndices
end repeat

SO FAR SO GOOD, BUT HERE THE FIELD FREEZES, WHOLE LIVECODE FREEZES AND HAS TO BE SHUT DOWN

put tNewIndices AFTER fld "index"
answer "new indices"

put THE number of lines of fld "index" && "namen" into field "zoeknamen"
end mouseUp


But now something awkward:
put the number of lines of tDB1=48
put NUMBER OF LINES of fld "index"=46
and clicking the last line of field "index" gives 44


What can I do to repear this?

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: scrolling list field abnormal behaviour

Post by robm80 » Wed Jun 04, 2014 9:50 pm

PS:
when I add the line where the trouble begon,in the content, to add it as the last line of field index' it responds normally and gives as linenumber 45 :!: :!: :?: :?:

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: scrolling list field abnormal behaviour

Post by robm80 » Thu Jun 05, 2014 2:47 am

Very simple repair.
Thinking all over, it must have been that I had added some empty lines in fld "DB1".
So with "filter fld "DB1" without empty" the abnormal behaviour became normal again.

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

Re: scrolling list field abnormal behaviour

Post by Klaus » Thu Jun 05, 2014 1:13 pm

Hi Rob,

so no more FREEZEing of Livecode?


Best

Klaus

Post Reply