Re: Faster way to get tabStops?
Hi Dan, I ran into the same problem and figured that acessing the field and ask for formattedWidth is slow. So I tried to minimize that. I took each tab delimited item an stuffed it into an array. For each column one key. You end up with each key holding the data of one column worth of data Then I put that column into a field that has the same properties as the original field and get the formattedWidth. This tells me the space I need to set the tabstops. That way I only access the field column times. This speeds up the whole process tremendously. To see it in action you can have a look: --- http://runtime-revolution.278305.n4.nabble.com/ANN-modified-Table-Field-0-2-9-td4683338.html#a4683384 -- watch for line breaks. look at the script of field fData handler mtfAdjustToWidthOfContent. Kind regards Bernd -- View this message in context: http://runtime-revolution.278305.n4.nabble.com/Faster-way-to-get-tabStops-tp4689049p4689064.html Sent from the Revolution - User mailing list archive at Nabble.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: Faster way to get tabStops?
Wow. Nice Bernd. On Thu, Feb 19, 2015 at 1:47 AM, BNig bernd.niggem...@uni-wh.de wrote: Hi Dan, I ran into the same problem and figured that acessing the field and ask for formattedWidth is slow. So I tried to minimize that. I took each tab delimited item an stuffed it into an array. For each column one key. You end up with each key holding the data of one column worth of data Then I put that column into a field that has the same properties as the original field and get the formattedWidth. This tells me the space I need to set the tabstops. That way I only access the field column times. This speeds up the whole process tremendously. To see it in action you can have a look: --- http://runtime-revolution.278305.n4.nabble.com/ANN-modified-Table-Field-0-2-9-td4683338.html#a4683384 -- watch for line breaks. look at the script of field fData handler mtfAdjustToWidthOfContent. Kind regards Bernd -- View this message in context: http://runtime-revolution.278305.n4.nabble.com/Faster-way-to-get-tabStops-tp4689049p4689064.html Sent from the Revolution - User mailing list archive at Nabble.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: Faster way to get tabStops?
Thanks Mike, you can load the field with 5000 lines worth of data via the Helper stack - Examples - choose 5000 - click button fill with n lines of random data, then move the lines by moving the dividers and then control-click into the field. This triggers the recalculation of the column widths via mtfAdjustToWidthOfContent It is quite fast. Kind regards Bernd Mike Bonner wrote Wow. Nice Bernd. On Thu, Feb 19, 2015 at 1:47 AM, BNig lt; bernd.niggemann@ gt; wrote: Hi Dan, I ran into the same problem and figured that acessing the field and ask for formattedWidth is slow. So I tried to minimize that. I took each tab delimited item an stuffed it into an array. For each column one key. You end up with each key holding the data of one column worth of data Then I put that column into a field that has the same properties as the original field and get the formattedWidth. This tells me the space I need to set the tabstops. That way I only access the field column times. This speeds up the whole process tremendously. To see it in action you can have a look: --- http://runtime-revolution.278305.n4.nabble.com/ANN-modified-Table-Field-0-2-9-td4683338.html#a4683384 -- watch for line breaks. look at the script of field fData handler mtfAdjustToWidthOfContent. Kind regards Bernd -- View this message in context: http://runtime-revolution.278305.n4.nabble.com/Faster-way-to-get-tabStops-tp4689049p4689067.html Sent from the Revolution - User mailing list archive at Nabble.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: Faster way to get tabStops?
Datagrids… GOOD! Bob S On Feb 19, 2015, at 24:47 , BNig bernd.niggem...@uni-wh.de wrote: Hi Dan, I ran into the same problem and figured that acessing the field and ask for formattedWidth is slow. So I tried to minimize that. I took each tab delimited item an stuffed it into an array. For each column one key. You end up with each key holding the data of one column worth of data Then I put that column into a field that has the same properties as the original field and get the formattedWidth. This tells me the space I need to set the tabstops. That way I only access the field column times. This speeds up the whole process tremendously. To see it in action you can have a look: --- http://runtime-revolution.278305.n4.nabble.com/ANN-modified-Table-Field-0-2-9-td4683338.html#a4683384 -- watch for line breaks. look at the script of field fData handler mtfAdjustToWidthOfContent. Kind regards Bernd -- View this message in context: http://runtime-revolution.278305.n4.nabble.com/Faster-way-to-get-tabStops-tp4689049p4689064.html Sent from the Revolution - User mailing list archive at Nabble.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: Faster way to get tabStops?
Hi Dan, Don't use repeat loops. Just sort the lines by the number of chars of item x and get the lineoffset for that line. When you know the line number, you can get the formattedWidth of the longest item in that line and base the tabstops on that. If you use a clever function, you should also be able to sort lines directly by the formattedWidth of their respective items, but that might be a little slow again. -- Best regards, Mark Schonewille Economy-x-Talk Consulting and Software Engineering Homepage: http://economy-x-talk.com Twitter: http://twitter.com/xtalkprogrammer KvK: 50277553 Installer Maker for LiveCode: http://qery.us/468 Buy my new book Programming LiveCode for the Real Beginner http://qery.us/3fi LiveCode on Facebook: https://www.facebook.com/groups/runrev/ On 2/19/2015 00:50, Dan Friedman wrote: Greetings! I am trying to set the tabStops to fit the data a field. The script below works great! However, ask it to process a few thousand lines with 10 or so columns, and you'll have time to get a cup of coffee! Any ideas on how to speed this up? Maybe there is some magical property I don't about? Thanks in advance, -Dan on formatData set the itemDel to tab put into theTabs put 0 into l repeat for each line tLine in fld myField add 1 to l put 0 into i repeat for each item tItem in tLine add 1 to i if the formattedWidth of item i of line l of fld myField item i of theTabs then put the formattedWidth of item i of line l of fld myField into item i of theTabs end if end repeat end repeat put into fTabs put 0 into i put 0 into tTotal repeat for each item tItem in theTabs add 1 to i add tItem+20 to tTotal put tTotal into item i of fTabs end repeat replace tab with , in fTabs set the tabStops of fld myField to fTabs end formatData ___ 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: Faster way to get tabStops?
number if items not tabs. DOH. Delimiter on the brain. On Wed, Feb 18, 2015 at 5:40 PM, Mike Bonner bonnm...@gmail.com wrote: Ah, here. If you're looking for the longest formatted line, you can do the formattedwidth of field... whatever. Then, if you're looking for the maximum number of tabs, you can cycle through the lines with for each, and look for the line with the most items. (if the number of items in tLine tCurrentItems then put the number of items in tLine into tCurrentItems) Does this get you close to what you want to do? On Wed, Feb 18, 2015 at 5:30 PM, Mike Bonner bonnm...@gmail.com wrote: The problem here is that even though you use the for each form, you are still using chunking (line x of field y) to do your checks. I don't know if there is a way to put the formatted text into a variable in such a way that when you use for each you can check the formattedwidth of tLine Since you're cycling through every line, with your current method, using with i = 1 to the number of lines... would work just as well and obviate the need for a self run counter. On Wed, Feb 18, 2015 at 4:50 PM, Dan Friedman d...@clearvisiontech.com wrote: Greetings! I am trying to set the tabStops to fit the data a field. The script below works great! However, ask it to process a few thousand lines with 10 or so columns, and you'll have time to get a cup of coffee! Any ideas on how to speed this up? Maybe there is some magical property I don't about? Thanks in advance, -Dan on formatData set the itemDel to tab put into theTabs put 0 into l repeat for each line tLine in fld myField add 1 to l put 0 into i repeat for each item tItem in tLine add 1 to i if the formattedWidth of item i of line l of fld myField item i of theTabs then put the formattedWidth of item i of line l of fld myField into item i of theTabs end if end repeat end repeat put into fTabs put 0 into i put 0 into tTotal repeat for each item tItem in theTabs add 1 to i add tItem+20 to tTotal put tTotal into item i of fTabs end repeat replace tab with , in fTabs set the tabStops of fld myField to fTabs end formatData ___ 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: Faster way to get tabStops?
The problem here is that even though you use the for each form, you are still using chunking (line x of field y) to do your checks. I don't know if there is a way to put the formatted text into a variable in such a way that when you use for each you can check the formattedwidth of tLine Since you're cycling through every line, with your current method, using with i = 1 to the number of lines... would work just as well and obviate the need for a self run counter. On Wed, Feb 18, 2015 at 4:50 PM, Dan Friedman d...@clearvisiontech.com wrote: Greetings! I am trying to set the tabStops to fit the data a field. The script below works great! However, ask it to process a few thousand lines with 10 or so columns, and you'll have time to get a cup of coffee! Any ideas on how to speed this up? Maybe there is some magical property I don't about? Thanks in advance, -Dan on formatData set the itemDel to tab put into theTabs put 0 into l repeat for each line tLine in fld myField add 1 to l put 0 into i repeat for each item tItem in tLine add 1 to i if the formattedWidth of item i of line l of fld myField item i of theTabs then put the formattedWidth of item i of line l of fld myField into item i of theTabs end if end repeat end repeat put into fTabs put 0 into i put 0 into tTotal repeat for each item tItem in theTabs add 1 to i add tItem+20 to tTotal put tTotal into item i of fTabs end repeat replace tab with , in fTabs set the tabStops of fld myField to fTabs end formatData ___ 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: Faster way to get tabStops?
Ah, here. If you're looking for the longest formatted line, you can do the formattedwidth of field... whatever. Then, if you're looking for the maximum number of tabs, you can cycle through the lines with for each, and look for the line with the most items. (if the number of items in tLine tCurrentItems then put the number of items in tLine into tCurrentItems) Does this get you close to what you want to do? On Wed, Feb 18, 2015 at 5:30 PM, Mike Bonner bonnm...@gmail.com wrote: The problem here is that even though you use the for each form, you are still using chunking (line x of field y) to do your checks. I don't know if there is a way to put the formatted text into a variable in such a way that when you use for each you can check the formattedwidth of tLine Since you're cycling through every line, with your current method, using with i = 1 to the number of lines... would work just as well and obviate the need for a self run counter. On Wed, Feb 18, 2015 at 4:50 PM, Dan Friedman d...@clearvisiontech.com wrote: Greetings! I am trying to set the tabStops to fit the data a field. The script below works great! However, ask it to process a few thousand lines with 10 or so columns, and you'll have time to get a cup of coffee! Any ideas on how to speed this up? Maybe there is some magical property I don't about? Thanks in advance, -Dan on formatData set the itemDel to tab put into theTabs put 0 into l repeat for each line tLine in fld myField add 1 to l put 0 into i repeat for each item tItem in tLine add 1 to i if the formattedWidth of item i of line l of fld myField item i of theTabs then put the formattedWidth of item i of line l of fld myField into item i of theTabs end if end repeat end repeat put into fTabs put 0 into i put 0 into tTotal repeat for each item tItem in theTabs add 1 to i add tItem+20 to tTotal put tTotal into item i of fTabs end repeat replace tab with , in fTabs set the tabStops of fld myField to fTabs end formatData ___ 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: Faster way to get tabStops?
Or what mark S said, though if you have styled text, the number of chars in the line the formattedwidth, so that may not work, but neither will mine. SO yep, interesting problem. Ah. Got it. If the last line of text is a fast chunk (or the first for that matter) you can set the htmltext of a hidden field to the htmltext of the field you're working with then.. repeat until field whatever is empty repeat with i = 1 to the number of items in the last line of field... Check the width of each item of the line as you do above. (this can be the first line too if that works for you) then delete the last line of field... end repeat end repeat Using this method you avoid the whole counting up through the lines of the field.. issue, and still end up with valid data. On Wed, Feb 18, 2015 at 5:40 PM, Mark Schonewille m.schonewi...@economy-x-talk.com wrote: Hi Dan, Don't use repeat loops. Just sort the lines by the number of chars of item x and get the lineoffset for that line. When you know the line number, you can get the formattedWidth of the longest item in that line and base the tabstops on that. If you use a clever function, you should also be able to sort lines directly by the formattedWidth of their respective items, but that might be a little slow again. -- Best regards, Mark Schonewille Economy-x-Talk Consulting and Software Engineering Homepage: http://economy-x-talk.com Twitter: http://twitter.com/xtalkprogrammer KvK: 50277553 Installer Maker for LiveCode: http://qery.us/468 Buy my new book Programming LiveCode for the Real Beginner http://qery.us/3fi LiveCode on Facebook: https://www.facebook.com/groups/runrev/ On 2/19/2015 00:50, Dan Friedman wrote: Greetings! I am trying to set the tabStops to fit the data a field. The script below works great! However, ask it to process a few thousand lines with 10 or so columns, and you'll have time to get a cup of coffee! Any ideas on how to speed this up? Maybe there is some magical property I don't about? Thanks in advance, -Dan on formatData set the itemDel to tab put into theTabs put 0 into l repeat for each line tLine in fld myField add 1 to l put 0 into i repeat for each item tItem in tLine add 1 to i if the formattedWidth of item i of line l of fld myField item i of theTabs then put the formattedWidth of item i of line l of fld myField into item i of theTabs end if end repeat end repeat put into fTabs put 0 into i put 0 into tTotal repeat for each item tItem in theTabs add 1 to i add tItem+20 to tTotal put tTotal into item i of fTabs end repeat replace tab with , in fTabs set the tabStops of fld myField to fTabs end formatData ___ 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 ___ 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: Faster way to get tabStops?
On 2/18/2015 6:50 PM, Dan Friedman wrote: Greetings! I am trying to set the tabStops to fit the data a field. The script below works great! However, ask it to process a few thousand lines with 10 or so columns, and you'll have time to get a cup of coffee! Any ideas on how to speed this up? Maybe there is some magical property I don't about? If you are using LC 6.5 or above, look at the measureText(text,object reference,[mode]) function in the dictionary. It may (or may not) be faster than the formattedWidth of a chunk of the field. ___ 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
Faster way to get tabStops?
Greetings! I am trying to set the tabStops to fit the data a field. The script below works great! However, ask it to process a few thousand lines with 10 or so columns, and you'll have time to get a cup of coffee! Any ideas on how to speed this up? Maybe there is some magical property I don't about? Thanks in advance, -Dan on formatData set the itemDel to tab put into theTabs put 0 into l repeat for each line tLine in fld myField add 1 to l put 0 into i repeat for each item tItem in tLine add 1 to i if the formattedWidth of item i of line l of fld myField item i of theTabs then put the formattedWidth of item i of line l of fld myField into item i of theTabs end if end repeat end repeat put into fTabs put 0 into i put 0 into tTotal repeat for each item tItem in theTabs add 1 to i add tItem+20 to tTotal put tTotal into item i of fTabs end repeat replace tab with , in fTabs set the tabStops of fld myField to fTabs end formatData ___ 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