Re: properties vs local variable

2014-03-15 Thread Dr. Hawkins
On Mon, Mar 10, 2014 at 9:46 AM, J. Landman Gay jac...@hyperactivesw.comwrote:

 This will be the speed bottleneck. Array access is very fast, faster than
 almost any other method. As noted here, variable access is the fastest,
 followed by access to custom properties, but the difference is so minimal
 as to be insignificant.


I don't want to hijack anything, but this is my burning issue today.

I have cards that will become output; groups are copied from them to my
output window, and then manipulated.
It's also possible that cards will be added to that stack during program
execution (there are a couple of hundred districts with their own forms).

I'm waffling between something like

if pg = 1 then
put group footer_1of   tgCrd  into tgGrp
else
put group footer_cof   tgCrd into tgGrp
end if

if exists( tgGrp ) then
copy tgGrp  to outTarget
do some other stuff with it
end if

The other approach would be to set a custom property  full of this kind of
information, and  then at program load (or when another card is added)

put the outControl of tgCrd into myTmp
split myTmp by return and space
put myTmp into outProps[the short name of tgCrd]

and then the routine becomes
if pg=1 then
put footer_1 into tgProp
else
put footer_c into tgProp
end if

if outProps[cdName][tgProp] is not empty then
copy outProps[cdName][tgProp] of tgCrd
do other stuff
end if


So if using the custom properties of a stack in memory is faster (even if
having to parse the name?), then the first should be faster, while if a
multi-dimensional array is faster, the second is faster.

And I suppose there's a third, where I copy outProps[cdNam] to theProps,
when beginning to render a form.  I recall someone discovering that under
some circumstances, it was worth the time to copy the subarray . . .

-- 
Dr. Richard E. Hawkins, Esq.
(702) 508-8462
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: properties vs local variable

2014-03-11 Thread Terence Heaford
Thanks Peter,

I think this what the data grid does.

I can see how this works having changed to colour of the group as an experiment.

How would I deal with non contiguous selections?

Create an image for each one?

This is starting to sound expensive time wise.

All the best

Terry

On 10 Mar 2014, at 21:41, Peter Haworth p...@lcsql.com wrote:

 There's another approach to this that does away with the need to set colors
 at all.
 
 Some folks on this list have shown me in the past how to create an image
 with its fillgradient set in such a way that it has alternating lines in
 the required colors at the same height as the line height you are dealing
 with, then setting it as a backgroundpattern.
 
 I've always used this in conjunction with a scrolling field with many lines
 of data but it sounds this table is made up of many text fields, probably
 grouped, so I tried it with a group of text fields..
 
 Set the group's backgroundpattern to the id of the image.  Set the group's
 opaque to true.  Set the opaque of the fields in the group to false.  All
 works fine.  Group can be resized and the backgroundpattern adjusts
 accordingly and you no longer need any code to set line colors except for
 indicating the selectedline which I'd probably do with another image with
 an appropriate background which gets positioned wherever the user clicks.
 


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


Re: properties vs local variable

2014-03-10 Thread Terence Heaford
Mark,

Thanks for your comments.

I am not having a particular problem, just trying to write efficient methods.

I have created my own text table in a group consisting of 6 cols (fields) * 20 
rows (fields) to try and speed up the scrolling when using a DG.

This has worked with a scrolling speed increase of approx. 30% when compared to 
the DG, probably because my table purely uses text and has no need for the 
remaining code that is in the DG.

The most time consuming element is loading all the fields with the data. Here 
is the displayData routine.

Can you see any areas that could me modified to speed it up?

on displayData tRecNum
   --put milliseconds() into tS
   lock screen
   lock messages
   set the uRecNum of me to tRecNum
   put the uCols of me into tCols
   put the uRows of me into tRows
   set the itemDelimiter to tab
   put 1 into tFldNum
   put 1 into tLineNum
   put line tRecNum to tRecNum + tRows - 1 of the uData of me into tData
   put line tRecNum to tRecNum + tRows - 1 of the uSelected of me into 
tSelectedData
   repeat for each line tRecData in tData
  put item 1 to tCols of tRecData into tFldData
  if line tLineNum of tSelectedData = true then
 put 62,117,215  into tBackColor
 put 255,255,255  into tForeColor
  else
 put 0,0,0  into tForeColor
 if tLineNum mod 2 = 0 then
put 244,246,250 into tBackColor
 else
put 255,255,255 into tBackColor
 end if
  end if
  repeat for each item tCellData in tFldData
 put tCellData into fld tFldNum of me
 set the backgroundColor of fld tFldNum of me to tBackColor
 set the foregroundColor of fld tFldNum of me to tForeColor
 add 1 to tFldNum
  end repeat
  add 1 to tLineNum
   end repeat
   unlock messages
   unlock screen
  --put milliseconds() - ts into cd fld result
end displayData



All the best

Terry

On 10 Mar 2014, at 10:46, Mark Schonewille m.schonewi...@economy-x-talk.com 
wrote:

  If you explain what you're trying to do, perhaps we can find a better way to 
 do it.
 

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


Re: properties vs local variable

2014-03-10 Thread Mark Schonewille

Hi Terry,

Can you use arrays? They aren't necessarily faster, but in this case 
they might be. Although you have a repeat-for loop, you're still 
updating a counter to keep track of your second data list. Using arrays 
just might speed things up, because the engine won't need to count 
things from the beginning in every loop but can instead read the correct 
elements from both arrays directly. I suspect this solution will either 
be slower or just a little fast, but it could be worth a try.


on displayData tRecNum
   --put milliseconds() into tS
   lock screen
   lock messages
   set the uRecNum of me to tRecNum
   put the uCols of me into tCols
   put the uRows of me into tRows
   set the itemDelimiter to tab
   put 1 into tFldNum
   put 1 into tLineNum
   put line tRecNum to tRecNum + tRows - 1 of the uData of me into tData
   put line tRecNum to tRecNum + tRows - 1 of the uSelected of me into 
tSelectedData

   split tData by cr // numeric keys
   split tSelectedData by cr // same numeric keys
   repeat for each line myKey in the keys of tData // use numeric keys
  if tSelectedData[myKey] then
 put 62,117,215  into tBackColor
 put 255,255,255  into tForeColor
  else
 put 0,0,0  into tForeColor
 if myKey mod 2 = 0 then
put 244,246,250 into tBackColor
 else
put 255,255,255 into tBackColor
 end if
  end if
  put 1 into fldNum
  repeat for each item tCellData in item 1 to tCols of tData[myKey]
 put tCellData into fld tFldNum of me
 set the backgroundColor of fld tFldNum of me to tBackColor
 set the foregroundColor of fld tFldNum of me to tForeColor
 add 1 to tFldNum
  end repeat
  // add 1 to tLineNum
   end repeat
   unlock messages
   unlock screen
   --put milliseconds() - ts into cd fld result
end displayData

You might want to check that this script actually does what you want. I 
only made a few quick edits..



--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Use Color Converter to convert CMYK, RGB, RAL, XYZ, H.Lab and other 
colour spaces. http://www.color-converter.com


Buy my new book Programming LiveCode for the Real Beginner 
http://qery.us/3fi


LiveCode on Facebook:
https://www.facebook.com/groups/runrev/

On 3/10/2014 13:15, Terence Heaford wrote:

Mark,

Thanks for your comments.

I am not having a particular problem, just trying to write efficient methods.

I have created my own text table in a group consisting of 6 cols (fields) * 20 
rows (fields) to try and speed up the scrolling when using a DG.

This has worked with a scrolling speed increase of approx. 30% when compared to 
the DG, probably because my table purely uses text and has no need for the 
remaining code that is in the DG.

The most time consuming element is loading all the fields with the data. Here 
is the displayData routine.

Can you see any areas that could me modified to speed it up?

on displayData tRecNum
--put milliseconds() into tS
lock screen
lock messages
set the uRecNum of me to tRecNum
put the uCols of me into tCols
put the uRows of me into tRows
set the itemDelimiter to tab
put 1 into tFldNum
put 1 into tLineNum
put line tRecNum to tRecNum + tRows - 1 of the uData of me into tData
put line tRecNum to tRecNum + tRows - 1 of the uSelected of me into 
tSelectedData
repeat for each line tRecData in tData
   put item 1 to tCols of tRecData into tFldData
   if line tLineNum of tSelectedData = true then
  put 62,117,215  into tBackColor
  put 255,255,255  into tForeColor
   else
  put 0,0,0  into tForeColor
  if tLineNum mod 2 = 0 then
 put 244,246,250 into tBackColor
  else
 put 255,255,255 into tBackColor
  end if
   end if
   repeat for each item tCellData in tFldData
  put tCellData into fld tFldNum of me
  set the backgroundColor of fld tFldNum of me to tBackColor
  set the foregroundColor of fld tFldNum of me to tForeColor
  add 1 to tFldNum
   end repeat
   add 1 to tLineNum
end repeat
unlock messages
unlock screen
   --put milliseconds() - ts into cd fld result
end displayData



All the best

Terry



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


Re: properties vs local variable

2014-03-10 Thread Terence Heaford
Hi Mark,

Thanks for your comments, will give it a try.

All the best

Terry

On 10 Mar 2014, at 14:10, Mark Schonewille m.schonewi...@economy-x-talk.com 
wrote:

 Hi Terry,
 
 Can you use arrays? They aren't necessarily faster, but in this case they 
 might be. Although you have a repeat-for loop, you're still updating a 
 counter to keep track of your second data list. Using arrays just might speed 
 things up, because the engine won't need to count things from the beginning 
 in every loop but can instead read the correct elements from both arrays 
 directly. I suspect this solution will either be slower or just a little 
 fast, but it could be worth a try.

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


Re: properties vs local variable

2014-03-10 Thread Terence Heaford
Hi Mark,

Have tried your adjustments to my script and it was a little slower than the 
original.

Could that be because of the split command?

I read the data in from an SQLite file in the return/tab delimited format.

put revDataFromQuery(tab, return, the uDB of this stack, tSQL) into tData

then I pass the data to the group

set thText of group “myTable of cd “myCard of stack “myStack to tData


I wonder if I split the data into an array and pass it directly to the group as 
an array if that would be quicker because there would be no need for the split 
to occur in the displayData routine?


All the best

Terry

On 10 Mar 2014, at 14:41, Terence Heaford t.heaf...@btinternet.com wrote:

 Hi Mark,
 
 Thanks for your comments, will give it a try.
 
 All the best
 
 Terry
 
 On 10 Mar 2014, at 14:10, Mark Schonewille m.schonewi...@economy-x-talk.com 
 wrote:
 
 Hi Terry,
 
 Can you use arrays? They aren't necessarily faster, but in this case they 
 might be. Although you have a repeat-for loop, you're still updating a 
 counter to keep track of your second data list. Using arrays just might 
 speed things up, because the engine won't need to count things from the 
 beginning in every loop but can instead read the correct elements from both 
 arrays directly. I suspect this solution will either be slower or just a 
 little fast, but it could be worth a try.
 

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


Re: properties vs local variable

2014-03-10 Thread Mark Schonewille

Hi Terry,

The split command itself doesn't slow it down, because that happens 
outside the repeat loop. However, arrays appear not to be the fastest 
way to access data and apparently in this case the removal of the 
counter was not enough to compensate for the addition of the arrays.


I see no thText in your original script. Perhaps you need to post more 
code, including the part that retrieves the data from the database all 
the way up to and including the part where it displays the data.


--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Use Color Converter to convert CMYK, RGB, RAL, XYZ, H.Lab and other 
colour spaces. http://www.color-converter.com


Buy my new book Programming LiveCode for the Real Beginner 
http://qery.us/3fi


LiveCode on Facebook:
https://www.facebook.com/groups/runrev/

On 3/10/2014 16:07, Terence Heaford wrote:

Hi Mark,

Have tried your adjustments to my script and it was a little slower than the 
original.

Could that be because of the split command?

I read the data in from an SQLite file in the return/tab delimited format.

put revDataFromQuery(tab, return, the uDB of this stack, tSQL) into tData

then I pass the data to the group

set thText of group “myTable of cd “myCard of stack “myStack to tData


I wonder if I split the data into an array and pass it directly to the group as 
an array if that would be quicker because there would be no need for the split 
to occur in the displayData routine?


All the best

Terry



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


Re: properties vs local variable

2014-03-10 Thread Terence Heaford
Mark,

Set thText is just a setProp routine in the group to receive the return/tab 
delimited data.

thText then sets a custom property of the group plus the scrollbar settings 
depending on the number of lines in the data

displayData is the only routine that places data into the fields.


All the best

Terry



On 10 Mar 2014, at 15:17, Mark Schonewille m.schonewi...@economy-x-talk.com 
wrote:

 I see no thText in your original script.

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


Re: properties vs local variable

2014-03-10 Thread dunbarx
I tried a simple test. I placed 100,000 lines of text into a custom property 
and into a variable. I timed how long it took to directly access a single line, 
10,000 times. It took 2 ticks for the custom property, and almost no time at 
all for the variable.


So the custom property is slower, but still pretty fast. What really matters is 
other stuff. For example, in the same pair of setups, if I asked for any line 
of either the prop or the variable, the process took about 30 seconds. That 
function call took its sweet time. So the lesson here is to watch carefully 
what is a first order issue, and what is a fourth order issue.



Craig Newman


-Original Message-
From: Mark Schonewille m.schonewi...@economy-x-talk.com
To: How to use LiveCode use-livecode@lists.runrev.com
Sent: Mon, Mar 10, 2014 11:18 am
Subject: Re: properties vs local variable


Hi Terry,

The split command itself doesn't slow it down, because that happens 
outside the repeat loop. However, arrays appear not to be the fastest 
way to access data and apparently in this case the removal of the 
counter was not enough to compensate for the addition of the arrays.

I see no thText in your original script. Perhaps you need to post more 
code, including the part that retrieves the data from the database all 
the way up to and including the part where it displays the data.

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Use Color Converter to convert CMYK, RGB, RAL, XYZ, H.Lab and other 
colour spaces. http://www.color-converter.com

Buy my new book Programming LiveCode for the Real Beginner 
http://qery.us/3fi

LiveCode on Facebook:
https://www.facebook.com/groups/runrev/

On 3/10/2014 16:07, Terence Heaford wrote:
 Hi Mark,

 Have tried your adjustments to my script and it was a little slower than the 
original.

 Could that be because of the split command?

 I read the data in from an SQLite file in the return/tab delimited format.

 put revDataFromQuery(tab, return, the uDB of this stack, tSQL) into tData

 then I pass the data to the group

 set thText of group “myTable of cd “myCard of stack “myStack to tData


 I wonder if I split the data into an array and pass it directly to the group 
as an array if that would be quicker because there would be no need for the 
split to occur in the displayData routine?


 All the best

 Terry


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

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

Re: properties vs local variable

2014-03-10 Thread Alex Tweedly

On 10/03/2014 15:33, dunb...@aol.com wrote:

I tried a simple test. I placed 100,000 lines of text into a custom property 
and into a variable. I timed how long it took to directly access a single line, 
10,000 times. It took 2 ticks for the custom property, and almost no time at 
all for the variable.

The question is - *which* single line did you test with ?

with the same circumstances, accessing
line   1   takes 3 msec
line 5000   takes 349 msec



So the custom property is slower, but still pretty fast. What really matters is other 
stuff. For example, in the same pair of setups, if I asked for any line of 
either the prop or the variable, the process took about 30 seconds. That function call 
took its sweet time. So the lesson here is to watch carefully what is a first order 
issue, and what is a fourth order issue.
It's not just the any that takes the time, it's the fact that on 
average it will be equivalent to the middle line.


-- Alex.

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


Re: properties vs local variable

2014-03-10 Thread J. Landman Gay

On 3/10/14, 7:15 AM, Terence Heaford wrote:

  repeat for each item tCellData in tFldData
  put tCellData into fld tFldNum of me
  set the backgroundColor of fld tFldNum of me to tBackColor
  set the foregroundColor of fld tFldNum of me to tForeColor
  add 1 to tFldNum
   end repeat


This will be the speed bottleneck. Array access is very fast, faster 
than almost any other method. As noted here, variable access is the 
fastest, followed by access to custom properties, but the difference is 
so minimal as to be insignificant. But manipulating field content is one 
of the slowest things a script can do, for several reasons. So whenever 
possible, you need to minimize the number of times a script accesses a 
field.


Locking the screen as you did to prevent redraw lag is a good start. 
That's sometimes enough for a small number of updates. If it isn't, grab 
the field content, manipulate it all at once, and then put it back.


Since colors can only be applied directly to fields, you can't 
manipulate those in variable. But you can create htmltext and then set 
the field's htmltext at one go. In this case that's what I'd do. To get 
proper html for the field, just manually set up the field colors once 
and put the field's htmltext into the message box. Use that text as a 
template to script the changes. I frequently store template htmltext as 
a custom property of the field, with merge markers ([[tBackColor]]). 
Then when I need to update the htmltext, I use the merge command. It's a 
one-liner and very fast.


I think if you use this method you will notice a dramatic increase in speed.

--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com

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


Re: properties vs local variable

2014-03-10 Thread dunbarx
Alex. I had tried lines 3, 3000 and 7500.


I did indeed only report the first value, likely because I wanted to slant my 
point about different types of processes overwhelming others in my favor. It is 
a character flaw.



But I got very similar results with the other two:



For line 3: 0 and 2 ticks
For line 3000: 57 and 59 ticks


For line 7500: 135 and 137 ticks


The same offset, if you will, as the 0 and 2 that I got with line 3.


Not sure why yours are so different. I had, with my 100,000 line list in the 
testProp of the card:


on mouseUp --test variable
   get the ticks
put the testProp of this cd into temp
   repeat 1
  put line 7500 of  temp into xyz
  --put any line of temp into xyz --that other process
   end repeat
   answer the ticks - it
end mouseUp


on mouseUp --test custom Prop
   get the ticks
   repeat 1
  put line 7500 of the testProp of this cd into temp
  --put any line of the testprop of this cd into temp  --that other 
process
   end repeat
   answer the ticks - it
end mouseUp


Craig




-Original Message-
From: Alex Tweedly a...@tweedly.net
To: use-livecode use-livecode@lists.runrev.com
Sent: Mon, Mar 10, 2014 12:45 pm
Subject: Re: properties vs local variable


On 10/03/2014 15:33, dunb...@aol.com wrote:
 I tried a simple test. I placed 100,000 lines of text into a custom property 
and into a variable. I timed how long it took to directly access a single line, 
10,000 times. It took 2 ticks for the custom property, and almost no time at 
all 
for the variable.
The question is - *which* single line did you test with ?

with the same circumstances, accessing
line   1   takes 3 msec
line 5000   takes 349 msec


 So the custom property is slower, but still pretty fast. What really matters 
is other stuff. For example, in the same pair of setups, if I asked for any 
line of either the prop or the variable, the process took about 30 seconds. 
That function call took its sweet time. So the lesson here is to watch 
carefully 
what is a first order issue, and what is a fourth order issue.
It's not just the any that takes the time, it's the fact that on 
average it will be equivalent to the middle line.

-- Alex.

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

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


Re: properties vs local variable

2014-03-10 Thread Terence Heaford
I’m trying to understand your solution but having looked at htmlText of field I 
am not getting it.

I follow that changing the colour of the field is time consuming.

Are you suggesting I can change the colour of the field using the htmlText and 
the merge command?

A sample line would be useful because I am not familiar with using the 
htmlText. I am familiar with merge.

Can you provide a sample line that would place some text in a field and change 
the backgroundColor of the field.

All the best

Terry


On 10 Mar 2014, at 16:46, J. Landman Gay jac...@hyperactivesw.com wrote:

 Since colors can only be applied directly to fields, you can't manipulate 
 those in variable. But you can create htmltext and then set the field's 
 htmltext at one go. In this case that's what I'd do. To get proper html for 
 the field, just manually set up the field colors once and put the field's 
 htmltext into the message box. Use that text as a template to script the 
 changes. I frequently store template htmltext as a custom property of the 
 field, with merge markers ([[tBackColor]]). Then when I need to update the 
 htmltext, I use the merge command. It's a one-liner and very fast.
 
 I think if you use this method you will notice a dramatic increase in speed.

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


Re: properties vs local variable

2014-03-10 Thread J. Landman Gay

On 3/10/14, 2:29 PM, Terence Heaford wrote:

Are you suggesting I can change the colour of the field using the
htmlText and the merge command?


Yes.


A sample line would be useful because I am not familiar with using
the htmlText. I am familiar with merge.


Okay. Usually I set up styling, colors, etc. manually one time just so I 
can get the htmltext easily. Since you're iterating over a longish list, 
just set up the styling of a single line. Then I put the htmltext of the 
field into the message box, just so I have something to copy. Say it 
gives me this:


pThis is text with an font color=redemphasized/font word./p

I copy/paste that somewhere I can edit it and replace the literal text 
with merge markers:


pThis is text with a font color=[[tColor]]emphasized/font word./p

I save that as a custom property of the field, or whatever. Say it's 
called cHTML.


In the handler:

put blue into tColor -- load the variable that merge will use
set the htmltext of fld 1 to merge(the cHTML of fld 1)

And it pops in all formatted.

In your handler you'd want to loop through all the lines in the data, 
changing the color variables as you go, and append a merge of the 
template line until you've got them all done. Then set the htmltext of 
the field to the variable.


I wrote the above without testing, so it may need tweaking. But that's 
the idea.


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com

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


Re: properties vs local variable

2014-03-10 Thread Mark Schonewille

Hi Terry,

Since the arrays don't add any efficiency in this case (as expected), 
perhaps it is a good idea to use a different approach. I understand that 
even fields should always have backColor 62,117,215 and white as the 
foreColor, unless line tLineNum of tSelectedData is not true. If line 
tLineNum of tSelectedData is not true, then you want even end odd fields 
to have different colours. There are a few ways to increase speed here.


First of all, you can make a group with colorized fields. Depending on 
how often line tLineNum of tSelectedData is true or false, you can give 
fields the required colours and only set the foreColor and backColor of 
a field if it has to change. This could increase speed by almost 50%, 
again depending on the values of line tLineNum of tSelectedData.


You can also change the repeat loop, using constants instead of 
variables. If I'm not mistaken, your repeat loop should now look like this:


   repeat for each line tRecData in tData
  put item 1 to tCols of tRecData into tFldData
  put 1 into tFldNum
  if line tLineNum of tSelectedData = true then
 // commenting out the following lines,
 // assuming fields have these colours by default
 // put 62,117,215  into tBackColor
 // put 255,255,255  into tForeColor
 repeat for each item tCellData in tFldData
put tCellData into fld tFldNum of me
// the next two lines should no longer be necessary
// set the backgroundColor of fld tFldNum of me to
// tBackColor
// set the foregroundColor of fld tFldNum of me to
// tForeColor
add 1 to tFldNum
 end repeat
  else
 if tLineNum mod 2 = 0 then
repeat for each item tCellData in tFldData
   put tCellData into fld tFldNum of me
   set the backgroundColor of fld tFldNum of me to \
  244,246,250
   set the foregroundColor of fld tFldNum of me to black
   add 1 to tFldNum
end repeat
 else
repeat for each item tCellData in tFldData
   put tCellData into fld tFldNum of me
   set the backgroundColor of fld tFldNum of me to white
   set the foregroundColor of fld tFldNum of me to black
   add 1 to tFldNum
end repeat
 end if
  end if
  add 1 to tLineNum
   end repeat

This could be a little faster.

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Use Color Converter to convert CMYK, RGB, RAL, XYZ, H.Lab and other 
colour spaces. http://www.color-converter.com


Buy my new book Programming LiveCode for the Real Beginner 
http://qery.us/3fi


LiveCode on Facebook:
https://www.facebook.com/groups/runrev/

On 3/10/2014 16:30, Terence Heaford wrote:

Mark,

Set thText is just a setProp routine in the group to receive the return/tab 
delimited data.

thText then sets a custom property of the group plus the scrollbar settings 
depending on the number of lines in the data

displayData is the only routine that places data into the fields.


All the best

Terry




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


Re: properties vs local variable

2014-03-10 Thread Peter Haworth
A sample line would be:

font color=#colorspec bgcolor=#bgcolorspec your text /font

colorspec and bgcolor spec are a hash mark followed by three hex numbers
representing the rgb color.  I think you can use a color name too but not
sure.

So using one of your examples you would set the htmltext of field x to
font color=#255,255,255 bgcolor=#62,117,215 this is my text /font


Pete
lcSQL Software http://www.lcsql.com
Home of lcStackBrowser http://www.lcsql.com/lcstackbrowser.html and
SQLiteAdmin http://www.lcsql.com/sqliteadmin.html


On Mon, Mar 10, 2014 at 12:29 PM, Terence Heaford
t.heaf...@btinternet.comwrote:

 I'm trying to understand your solution but having looked at htmlText of
 field I am not getting it.

 I follow that changing the colour of the field is time consuming.

 Are you suggesting I can change the colour of the field using the htmlText
 and the merge command?

 A sample line would be useful because I am not familiar with using the
 htmlText. I am familiar with merge.

 Can you provide a sample line that would place some text in a field and
 change the backgroundColor of the field.

 All the best

 Terry


 On 10 Mar 2014, at 16:46, J. Landman Gay jac...@hyperactivesw.com wrote:

  Since colors can only be applied directly to fields, you can't
 manipulate those in variable. But you can create htmltext and then set the
 field's htmltext at one go. In this case that's what I'd do. To get proper
 html for the field, just manually set up the field colors once and put the
 field's htmltext into the message box. Use that text as a template to
 script the changes. I frequently store template htmltext as a custom
 property of the field, with merge markers ([[tBackColor]]). Then when I
 need to update the htmltext, I use the merge command. It's a one-liner and
 very fast.
 
  I think if you use this method you will notice a dramatic increase in
 speed.

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

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


Re: properties vs local variable

2014-03-10 Thread Terence Heaford
Hi Mark,

Thanks once again. All your comments are valid and there is certainly no need 
to change the field colour unless tSelectedData is not true.

So, I think your method is marginally quicker but is probably held back from 
being even quicker by the extra if then constructs.

I will now explore the htmlText solution to see what that results in. Bit more 
time needed with this one to modify my routine and get my head around it 
because I have not used htmlText before.

All the best

Terry


On 10 Mar 2014, at 20:00, Mark Schonewille m.schonewi...@economy-x-talk.com 
wrote:

 Since the arrays don't add any efficiency in this case (as expected), perhaps 
 it is a good idea to use a different approach. I understand that even fields 
 should always have backColor 62,117,215 and white as the foreColor, unless 
 line tLineNum of tSelectedData is not true. If line tLineNum of tSelectedData 
 is not true, then you want even end odd fields to have different colours. 
 There are a few ways to increase speed here.
 
 First of all, you can make a group with colorized fields. Depending on how 
 often line tLineNum of tSelectedData is true or false, you can give fields 
 the required colours and only set the foreColor and backColor of a field if 
 it has to change. This could increase speed by almost 50%, again depending on 
 the values of line tLineNum of tSelectedData.
 
 You can also change the repeat loop, using constants instead of variables. If 
 I'm not mistaken, your repeat loop should now look like this:

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


Re: properties vs local variable

2014-03-10 Thread Mark Schonewille

Hi Terry,

Keep us posted. I'm really curious which solution appears to be 
significantly faster.



--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Use Color Converter to convert CMYK, RGB, RAL, XYZ, H.Lab and other 
colour spaces. http://www.color-converter.com


Buy my new book Programming LiveCode for the Real Beginner 
http://qery.us/3fi


LiveCode on Facebook:
https://www.facebook.com/groups/runrev/

On 3/10/2014 21:38, Terence Heaford wrote:

Hi Mark,

Thanks once again. All your comments are valid and there is certainly no need 
to change the field colour unless tSelectedData is not true.

So, I think your method is marginally quicker but is probably held back from 
being even quicker by the extra if then constructs.

I will now explore the htmlText solution to see what that results in. Bit more 
time needed with this one to modify my routine and get my head around it 
because I have not used htmlText before.

All the best

Terry



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


Re: properties vs local variable

2014-03-10 Thread Terence Heaford
Thanks for your help.

It did not work initially but a bit of google identified the # is not required 
with RGB colours.

However, when using this it only colours the bgcolor behind the text and not 
the whole field.

Here is my test script.

 put 255,255,255 into tFontColor
 put 62,117,215 into tBackColor
 put This is my text into tText
 put merge(font color=[[quote]][[tFontColor]][[quote]] 
bgcolor=[[quote]][[tBackColor]][[quote]] [[tText]] /font) into tHTML
 set the htmlText of fld result to tHTML

As it’s HTML I am assuming it’s not possible to colour the whole field using 
this method?

All the best

Terry

On 10 Mar 2014, at 20:04, Peter Haworth p...@lcsql.com wrote:

 So using one of your examples you would set the htmltext of field x to
 font color=#255,255,255 bgcolor=#62,117,215 this is my text /font

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


Re: properties vs local variable

2014-03-10 Thread Peter Haworth
There's another approach to this that does away with the need to set colors
at all.

Some folks on this list have shown me in the past how to create an image
with its fillgradient set in such a way that it has alternating lines in
the required colors at the same height as the line height you are dealing
with, then setting it as a backgroundpattern.

I've always used this in conjunction with a scrolling field with many lines
of data but it sounds this table is made up of many text fields, probably
grouped, so I tried it with a group of text fields..

Set the group's backgroundpattern to the id of the image.  Set the group's
opaque to true.  Set the opaque of the fields in the group to false.  All
works fine.  Group can be resized and the backgroundpattern adjusts
accordingly and you no longer need any code to set line colors except for
indicating the selectedline which I'd probably do with another image with
an appropriate background which gets positioned wherever the user clicks.

Pete
lcSQL Software http://www.lcsql.com
Home of lcStackBrowser http://www.lcsql.com/lcstackbrowser.html and
SQLiteAdmin http://www.lcsql.com/sqliteadmin.html
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: properties vs local variable

2014-03-10 Thread Peter Haworth
If I remember the genesis of all this correctly, Terence wants to use a
table made up of individual fields for each column because, amongst other
things, you can't right justify data within a tabstop.

Pete
lcSQL Software http://www.lcsql.com
Home of lcStackBrowser http://www.lcsql.com/lcstackbrowser.html and
SQLiteAdmin http://www.lcsql.com/sqliteadmin.html


On Mon, Mar 10, 2014 at 3:12 PM, J. Landman Gay jac...@hyperactivesw.comwrote:

 On 3/10/14, 4:41 PM, Peter Haworth wrote:

 Some folks on this list have shown me in the past how to create an image
 with its fillgradient set in such a way that it has alternating lines in
 the required colors at the same height as the line height you are dealing
 with, then setting it as a backgroundpattern.


 Somewhere along the way I missed the idea that we're only setting line
 colors. Is that all we're doing? It could all be a single field if that's
 the case and the entire content could be updated in one go.

 If that's the goal, it can all be scripted in a single field. You don't
 need the background image hack any more. The new field properties can
 handle it. I've got a handler somewhere that does it, but I have to go dig
 it up.


 --
 Jacqueline Landman Gay | jac...@hyperactivesw.com
 HyperActive Software   | http://www.hyperactivesw.com

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

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


Re: properties vs local variable

2014-03-10 Thread J. Landman Gay

On 3/10/14, 5:43 PM, Peter Haworth wrote:

If I remember the genesis of all this correctly, Terence wants to use a
table made up of individual fields for each column because, amongst other
things, you can't right justify data within a tabstop.


Oh, okay. Then yes, he needs fields.

--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com

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


Re: properties vs local variable

2014-03-10 Thread Alex Tweedly

On 10/03/2014 22:43, Peter Haworth wrote:

If I remember the genesis of all this correctly, Terence wants to use a
table made up of individual fields for each column because, amongst other
things, you can't right justify data within a tabstop.


So he does need fields.

He can take advantage of inheritance for backgroundColor and foregroundCoor
   - create a group per line of display, with the fields for each 
column within it


   - set the colors for the overall group, and only modify those for 
lines which need it (as Mark did earlier)


   - set colors for those lines that need it (and inherit those 
settings for all the columns in that line


I suspect that (along with other improvements earlier) would be enough 
to make any further changes academic - and Terence should be wary of 
spending mor effort on diminishing and unneeded returns.


But if there is still a real performance issue that is visible and 
troubling, then we can start on harder measures.


The original problem was stated in the context of scrolling speed. If 
that is scrolling by page, or to arbitrary scroll settings, that's 
probably as good as we can do. But if the real problem shows up when 
scrolling line-by-line, then we could consider a different approach. Use 
the group per line of display as above, but instead of re-writing all 
the lines of data just to scroll one line, simply re-position each 
line-group, and write in new text values for the one line that has to be 
newly displayed.


-- Alex.

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


Re: properties vs local variable

2014-03-10 Thread Peter Haworth
And pretty soon, he'll back to what the datagrid does :-)  Not that there's
anything wrong with that but there's a crying need for something that fits
between LC's basic table object and the datagrid when the requirements
warrant it.

Pete
lcSQL Software http://www.lcsql.com
Home of lcStackBrowser http://www.lcsql.com/lcstackbrowser.html and
SQLiteAdmin http://www.lcsql.com/sqliteadmin.html


On Mon, Mar 10, 2014 at 5:09 PM, Alex Tweedly a...@tweedly.net wrote:

 On 10/03/2014 22:43, Peter Haworth wrote:

 If I remember the genesis of all this correctly, Terence wants to use a
 table made up of individual fields for each column because, amongst other
 things, you can't right justify data within a tabstop.

  So he does need fields.

 He can take advantage of inheritance for backgroundColor and foregroundCoor
- create a group per line of display, with the fields for each column
 within it

- set the colors for the overall group, and only modify those for lines
 which need it (as Mark did earlier)

- set colors for those lines that need it (and inherit those settings
 for all the columns in that line

 I suspect that (along with other improvements earlier) would be enough to
 make any further changes academic - and Terence should be wary of spending
 mor effort on diminishing and unneeded returns.

 But if there is still a real performance issue that is visible and
 troubling, then we can start on harder measures.

 The original problem was stated in the context of scrolling speed. If that
 is scrolling by page, or to arbitrary scroll settings, that's probably as
 good as we can do. But if the real problem shows up when scrolling
 line-by-line, then we could consider a different approach. Use the group
 per line of display as above, but instead of re-writing all the lines of
 data just to scroll one line, simply re-position each line-group, and write
 in new text values for the one line that has to be newly displayed.

 -- Alex.


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

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


Re: properties vs local variable

2014-03-10 Thread J. Landman Gay

On 3/10/14, 5:43 PM, Peter Haworth wrote:

If I remember the genesis of all this correctly, Terence wants to use a
table made up of individual fields for each column because, amongst other
things, you can't right justify data within a tabstop.


I'd like to see an image of what it's supposed to be, so at least I'd 
know what to aim for. Picture, thousand words, etc.


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com

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