Equation Hiding using lineOffset

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
shalu
Posts: 72
Joined: Fri Mar 20, 2015 1:05 pm

Equation Hiding using lineOffset

Post by shalu » Thu Jun 18, 2015 10:13 am

I am Beginner in Livecode. I got a code for hiding equations in my Scrolling field, The equations starts with "\begin{equation}" and ends with "\end{equation}", In between these two tags equations are placed. My problem is my code is executed only once. My Scrolling field contains lots equations. Also, I want to restore these equations when I press a button. using loops how I rewrite my code :oops:
on mouseUp
put the htmlText of field "MytextField" into myHtml
put lineOffset("begin{equation}",myHtml) into tBegin
put lineOffset("end{equation}",myHtml) into tEnd
set the hidden of line tBegin to tEnd in fld "MytextField" to true

end mouseUp
--
Thanks
Shalu S

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

Re: Equation Hiding using lineOffset

Post by dunbarx » Thu Jun 18, 2015 2:09 pm

Hi.

Welcome to LC.

I had never used the "hidden" command. It is odd, in that when it hides a line, though that line is still intact in the field, the other lines fill upward as if that line was deleted. Odd command.

Anyway, are all your equations on one line? You would not need the end tag if so.

When you want to hide subsequent lines, store the line number of the previous one, and use the "lines to skip" parameter in the lineOffset function. Where might you store this value? Write back if you need more help with this.

To restore, just loop through all the lines in the field, and set the hidden of each line to "false", regardless of the current state of that line. Or test the hidden property of each line and only restore if true. Or keep a list of the hidden lines, and only restore from that list, which might be faster if you have a very long field. All are valid approaches, and you might try to work each one as an exercise. Exercise keeps you healthy.

Craig Newman

Post Reply