Re: Speeding a handler?

2009-12-01 Thread Damien Girard

Hi,

Did you locked the screen ?

lock screen
put 0 into x
repeat for each line aLine of fld someFld
 add 1 to x
 if quote is in aLine then
   set the forecolor of line x of fld someFld to red
   replace quote with empty in line x of fld someFld
 end if
end repeat
unlock screen


Regards,

Damien Girard
Dam-pro, France.
Improve your code reusability with NativeDoc! 
http://www.dam-pro.com/nativedoc


Ton Cardona a écrit :

I have a text field with 5.729 lines. 826 of them, those containing quotes, 
must appear coloured in red so the instruction would be:

put 0 into x
repeat for each line aLine of fld someFld
  add 1 to x
  if quote is in aLine then
set the forecolor of line x of fld someFld to red
replace quote with empty in line x of fld someFld
  end if
end repeat

The problem is it takes 55 seconds.

I have reduced this time to 33 seconds by recording previously the numbers of 
the lines to be coloured and storing them in a customProp, yet it still takes 
33 seconds.

Does anyone know a faster way of performing this task?

Thanks in advance,

Ton

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


  


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Speeding a handler?

2009-12-01 Thread Colin Holgate

On Dec 1, 2009, at 9:51 AM, Ton Cardona wrote:

 I have reduced this time to 33 seconds by recording previously the numbers of 
 the lines to be coloured and storing them in a customProp, yet it still takes 
 33 seconds.

In that version, were you still getting the lines from the field? What happens 
if you store the whole field into a variable, then run through the variable to 
make your list of lines to color, at the end of that do a single replace quote 
with empty, put the variable back into the field, and then color the lines.

At the moment you are accessing the field up to 17187 times in the routine. 
Transferring the field into a variable first would cut out up to 12000 of those 
accesses.


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Speeding a handler?

2009-12-01 Thread Phil Davis

Hello Ton,

This should be MUCH faster because the text is moved to a variable for 
processing. It assumes all text in the field is either red or black.


on mouseUp
  put 1 into someFld -- I used fld 1 in my test

  -- get colored text from field
  put the htmlText of fld someFld into tText
 
  -- remove quote char from html (but leave quot; entity)

  replace quote with empty in tText
 
  -- remove all red color from text

  replace font color=#FF with empty in tText
  replace /font with empty in tText
 
  -- set text line color to red if line contains a quote

  repeat for each line tLine in tText
 if quot; is in tLine -- this line contains a quote
 then -- make the text red
put font color=#FF after char 3 of tLine -- after p
put /font before char -4 of tLine -- before /p
 end if
 put tLine  cr after tNewText
  end repeat
  delete last char of tNewText
 
  -- update the field with recolored text

  lock screen
  put the vScroll of fld someFld into x
  set the htmlText of fld someFld to tNewText
  set the vScroll of fld someFld to x
  unlock screen
end mouseUp


HTH -
Phil Davis



Ton Cardona wrote:

I have a text field with 5.729 lines. 826 of them, those containing quotes, 
must appear coloured in red so the instruction would be:

put 0 into x
repeat for each line aLine of fld someFld
  add 1 to x
  if quote is in aLine then
set the forecolor of line x of fld someFld to red
replace quote with empty in line x of fld someFld
  end if
end repeat

The problem is it takes 55 seconds.

I have reduced this time to 33 seconds by recording previously the numbers of 
the lines to be coloured and storing them in a customProp, yet it still takes 
33 seconds.

Does anyone know a faster way of performing this task?

Thanks in advance,

Ton
  


--
Phil Davis

PDS Labs
Professional Software Development
http://pdslabs.net

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Speeding a handler?

2009-12-01 Thread BNig

How about something like this:

make 2 fields, field 1 has the data, field 2 will have the output

--
local tStartP, tEndP
on mouseUp
   put p into tStartP
   put /p into tEndP
   put  into tStartFont
   put  into tEndFont
   put field 1 into tData
   put  into tCollect
   put the milliseconds into tStart
   repeat for each line aLine in tData
  if quote is in aLine   then
 replace quote with  in aLine
 put putP((tStartFont  aLine  tEndFont)) after tCollect
  else
 put putP(aLine) after tCollect
  end if
   end repeat
   set the htmlText of field 2 to tCollect
   put the milliseconds - tStart
end mouseUp

private function putP what
   return tStartP  what  tEndP
end putP
--
regards
Bernd



 On Dec 1, 2009, at 9:51 AM, Ton Cardona wrote:
 
 I have reduced this time to 33 seconds by recording previously the
 numbers of the lines to be coloured and storing them in a customProp, yet
 it still takes 33 seconds.
 

-- 
View this message in context: 
http://n4.nabble.com/Speeding-a-handler-tp932254p932300.html
Sent from the Revolution - User mailing list archive at Nabble.com.
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: speeding a handler?

2009-12-01 Thread Phil Davis

Hey, I'm glad it helped!

To get another slight speed increase, you can move your new line of code 
outside the repeat loop (below the loop)  - but instead of:

  replace quot; with empty in tLine

It would say:
  replace quot; with empty in tNewText

One time for the whole list instead of once per line.

:-)

Phil


Ton Cardona wrote:

Thanks a lot, Phil. Your handler is as fast as lightning.

I've had to add a line of code to replace quotes since they still showed in the 
fld:

repeat for each line tLine in tText
 if quot; is in tLine -- this line contains a quote
 then -- make the text red
put font color=#FF after char 3 of tLine -- after p
put /font before char -4 of tLine -- before /p
 end if
 replace quot; with empty in tLine  --line added by me
 put tLine  cr after tNewText
  end repeat

I am really very grateful.

Best regards,

Ton
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

  


--
Phil Davis

PDS Labs
Professional Software Development
http://pdslabs.net

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution