Re: How to find the offset of the last instance of a repeating character in a string? (Geoff Canyon)
Here is something... probably needs some optimization function allOffsets2 D,S,pCase local dLength, C, R -- returns a comma-delimited list of the offsets of D in S set the caseSensitive to pCase is true set the itemDel to D put length(D) into dLength put 1 - dLength into C if dLength > 1 then local n, i, j, D2, L2 put 0 into n repeat with i = 2 to dLength if char i to -1 of D is char 1 to -i of D then add 1 to n put char (1-i) to -1 of D into D2[n] put i-1 into L2[n] end if end repeat end if repeat for each item i in S if C > 0 and n > 0 then repeat with j = 1 to n if i&D begins with D2[j] then put C+L2[j],"" after R end if end repeat end if add length(i) + dLength to C put C,"" after R end repeat set the itemDel to comma delete char -1 of R if item -1 of R > len(S) then if the number of items of R is 1 then return 0 else delete item -1 of R end if end if if char -dLength to -1 of S is D then return R end if repeat with j = n down to 1 if char -len(D2[j]) to -1 of S is D2[j] then delete item -1 of R end if end repeat return R end allOffsets2 I think a couple of private functions would be good. One for 0 overlap, one for a single overlap, then a final general one for any number of overlaps (the core of the above). After the loop that generates D2/L2 I would branch based on n to avoid the additional comparisons inside the loop. On Fri, Nov 2, 2018 at 9:45 PM Alex Tweedly via use-livecode < use-livecode@lists.runrev.com> wrote: > Oh dear - answering my own posts rarely a good sign :-) > > > On 03/11/2018 02:10, Alex Tweedly via use-livecode wrote: > > > > On 03/11/2018 00:43, Geoff Canyon via use-livecode wrote: > >> One thing I don't see how to do without significantly impacting > >> performance > >> is to return all offsets if there are overlapping strings. For example: > >> > >> allOffsets("aba","abababa") > >> > >> would return 1,5, when it might be reasonable to expect it to return > >> 1,3,5. > >> Using the offset function with numToSkip would make that easy; adapting > >> allOffsets to do so would be harder to do cleanly I think. > >> > > Can I suggest changing it to "someOffsets()" :-) :-) > > > > But seriously, can you not iteratively run "allofsets" ? > > > Answer : NO. That doesn't work. > However, there is a more efficient way that does work - but it needs to > be tested before I post it. > > -- 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: How to find the offset of the last instance of a repeating character in a string? (Geoff Canyon)
Oh dear - answering my own posts rarely a good sign :-) On 03/11/2018 02:10, Alex Tweedly via use-livecode wrote: On 03/11/2018 00:43, Geoff Canyon via use-livecode wrote: One thing I don't see how to do without significantly impacting performance is to return all offsets if there are overlapping strings. For example: allOffsets("aba","abababa") would return 1,5, when it might be reasonable to expect it to return 1,3,5. Using the offset function with numToSkip would make that easy; adapting allOffsets to do so would be harder to do cleanly I think. Can I suggest changing it to "someOffsets()" :-) :-) But seriously, can you not iteratively run "allofsets" ? Answer : NO. That doesn't work. However, there is a more efficient way that does work - but it needs to be tested before I post it. -- 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: How to find the offset of the last instance of a repeating character in a string? (Geoff Canyon)
On 03/11/2018 00:43, Geoff Canyon via use-livecode wrote: I like that, changing it. Now available at https://github.com/gcanyon/alloffsets One thing I don't see how to do without significantly impacting performance is to return all offsets if there are overlapping strings. For example: allOffsets("aba","abababa") would return 1,5, when it might be reasonable to expect it to return 1,3,5. Using the offset function with numToSkip would make that easy; adapting allOffsets to do so would be harder to do cleanly I think. Can I suggest changing it to "someOffsets()" :-) :-) But seriously, can you not iteratively run "allofsets" ? something like (typed straight into email - totally untested) function allOffsets pDel, pStr repeat with c = 1 to 255 -- or some other upper limit ? if NOT pDel contains numtochar(c) then put numtochar(c) into c exit repeat end if end repeat repeat forever put someOffsets(pDel, pStr) into newR if the number of items in newR = 0 then exit repeat repeat for each item I in newR put c into char I of newR end repeat put newR after R end repeat sort items of R numeric return R end alloffsets -- 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: Continual iOS Simulator Problems
I’m sorry for not replying sooner, but yes, it was the simulator that was not working. I did as others suggested, open the simulator in Xcode and run from there with no problem. Thanks for your help! Roger > On Oct 31, 2018, at 10:46 AM, JJS via use-livecode > wrote: > > Does the emulator itself not work? > > Or does your app not run on the emulator? > > You can either hit the test button to run it on an open emulator. > > But you can also create a standalone on mac and drag the the standalone file > to the emulator (or was a real device) anyway can't remember but i did drag > it towards devices in Xcode > > But your Provisioning Profile is OK? > > > Op 30-10-2018 om 03:47 schreef Roger Guay via use-livecode: >> Hi Folks, >> >> I’m on a Mac with OS 10.14 and using LC 9.0.0 Indy, and I have the green >> square indication in LC prefs with SDK 11.2. >> >> I can’t get the simulator to work with test target set to simulator 11.2. It >> simply takes too long to open and then crashes if I persist. >> >> In fact, it seems to me that I’ve had this problem with the simulator not >> working in previous versions as well. >> >> Any help or suggestions are greatly appreciated. >> >> Thanks, >> >> Roger >> ___ >> 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: How to find the offset of the last instance of a repeating character in a string? (Geoff Canyon)
I like that, changing it. Now available at https://github.com/gcanyon/alloffsets One thing I don't see how to do without significantly impacting performance is to return all offsets if there are overlapping strings. For example: allOffsets("aba","abababa") would return 1,5, when it might be reasonable to expect it to return 1,3,5. Using the offset function with numToSkip would make that easy; adapting allOffsets to do so would be harder to do cleanly I think. gc On Fri, Nov 2, 2018 at 12:17 PM Bob Sneidar via use-livecode < use-livecode@lists.runrev.com> wrote: > how about allOffsets? > > Bob S > > > > On Nov 2, 2018, at 09:16 , Geoff Canyon via use-livecode < > use-livecode@lists.runrev.com> wrote: > > > > All of those return a single value; I wanted to convey the concept of > > returning multiple values. To me listOffset implies it does the same > thing > > as itemOffset, since items come in a list. How about: > > > > offsets -- not my favorite because it's almost indistinguishable from > offset > > offsetsOf -- seems a tad clumsy > > > > On Fri, Nov 2, 2018 at 7:41 AM Bob Sneidar via use-livecode < > > use-livecode@lists.runrev.com> wrote: > > > >> It probably should be named listOffset, like itemOffset or lineOffset. > >> > >> Bob S > >> > >> > >>> On Nov 1, 2018, at 17:04 , Geoff Canyon via use-livecode < > >> use-livecode@lists.runrev.com> wrote: > >>> > >>> Nice! I *just* finished creating a github repository for it, and adding > >>> support for multi-char search strings, much as you did. I was coming to > >> the > >>> list to post the update when I saw your post. > >>> > >>> Here's the GitHub link: https://github.com/gcanyon/offsetlist > >>> > >>> Here's my updated version: > >>> > >>> function offsetList D,S,pCase > >>> -- returns a comma-delimited list of the offsets of D in S > >>> set the caseSensitive to pCase is true > >>> set the itemDel to D > >>> put length(D) into dLength > >>> put 1 - dLength into C > >>> repeat for each item i in S > >>> add length(i) + dLength to C > >>> put C,"" after R > >>> end repeat > >>> set the itemDel to comma > >>> if char -dLength to -1 of S is D then return char 1 to -2 of R > >>> put length(C) + 1 into lenC > >>> put length(R) into lenR > >>> if lenC = lenR then return 0 > >>> return char 1 to lenR - lenC - 1 of R > >>> end offsetList > >>> > >>> On Thu, Nov 1, 2018 at 8:28 AM Niggemann, Bernd via use-livecode < > >>> use-livecode@lists.runrev.com> wrote: > >>> > Hi Geoff, > > thank you for this beautiful script. > > I modified it a bit to accept multi-character search string and also > for > case sensitivity. > > It definitely is a lot faster for unicode text than anything I have > >> seen. > > - > function offsetList D,S, pCase > -- returns a comma-delimited list of the offsets of D in S > -- pCase is a boolean for caseSensitive > set the caseSensitive to pCase > set the itemDel to D > put the length of D into tDelimLength > repeat for each item i in S > add length(i) + tDelimLength to C > put C - (tDelimLength - 1),"" after R > end repeat > set the itemDel to comma > if char -1 of S is D then return char 1 to -2 of R > put length(C) + 1 into lenC > put length(R) into lenR > if lenC = lenR then return 0 > return char 1 to lenR - lenC - 1 of R > end offsetList > -- > > Kind regards > Bernd > > > > > > > > > Date: Thu, 1 Nov 2018 00:15:37 -0700 > > From: Geoff Canyon > > To: How to use LiveCode > > Subject: Re: How to find the offset of the last instance of a > > repeating character in a string? > > > > I was curious if using the itemDelimiter might work for this, so I > >> wrote > > the below code out of curiosity; but in my quick testing with > >> single-byte > > characters it was only about 30% faster than the above methods, so I > didn't > > bother to post it. > > > > But Ben Rubinstein just posted about a terrible slow-down doing > pretty > much > > this same thing for text with unicode characters. So I ran a simple > >> test > > with 8000 character long strings that start with a single unicode > > character, this is about 15x faster than offset() with skip. For > > 100,000-character lines it's about 300x faster, so it seems to be > >> immune > to > > the line-painter issues skip is subject to. So for what it's worth: > > > > function offsetList D,S > > -- returns a comma-delimited list of the offsets of D in S > > set the itemDel to D > > repeat for each item i in S > >add length(i) + 1 to C > >put C,"" after R > > end repeat > > set the itemDel to comma > > if char -1 of S is D then return char 1 to -2 of R > > put length(C)
Re: problem with mobileSetKeyboardType
Are those commands being executed before the keyboard is displayed? Thanks, Brian On Nov 2, 2018, 4:49 PM -0500, Mike for GDC via use-livecode , wrote: > I have not been able to get the "mobileSetKeyboardType" command to work on > my android. I have tried various options, such as: > > > > on openField > > if the environment is "mobile" then > > mobileSetKeyboardType "alphabet" > > end if > > end openField > > > > and > > > > on mouseUp > > if the environment is "mobile" then > > mobileSetKeyboardType "alphabet" > > end if > > end mouseUp > > > > Neither work. All I get is the standard keyboard from the android. > > Any suggestions? > > > > Thanks. > > Mike > > > > ___ > 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: Sorting datagrid column with a tricj?
On Fri, Nov 2, 2018 at 5:16 PM Bob Sneidar via use-livecode < use-livecode@lists.runrev.com> wrote: > > What I would like to see added to the datagrid is a handler that > intercepted the population of a field so what goes into the field can be > custom formatted. This comes up a lot. Dates and numbers from an SQL query > are unformatted, and having to go through the datagrid when populating and > formatting each record's data before displaying it, and then reformatting > it before pushing it back up to the database seems like more work than > necessary. > The Data Grid already supports this. Just customize the default column behavior. Take a look at this article which truncates text that is too wide: http://lessons.livecode.com/m/datagrid/l/7327-how-do-i-override-the-default-behavior-for-rendering-data-to-a-cell -- Trevor DeVore ScreenSteps www.screensteps.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: Sorting datagrid column with a tricj?
Okay, looks like this is a no go. I read from one of the datagrid lessons in reference to populating the datagrid "by hand": Important: When using this technique properties like dgData, dgText, dgDataOfIndex, etc. will no longer return values. The data grid is just displaying records from your data source. It does not store any of that data internally. What I would like to see added to the datagrid is a handler that intercepted the population of a field so what goes into the field can be custom formatted. This comes up a lot. Dates and numbers from an SQL query are unformatted, and having to go through the datagrid when populating and formatting each record's data before displaying it, and then reformatting it before pushing it back up to the database seems like more work than necessary. Bob S > On Nov 2, 2018, at 14:42 , Bob Sneidar via use-livecode > wrote: > > In a table datagrid, can't you edit the column template so that you can > control what goes into the field for that column? I think the underlying data > will remain the same, but what goes into the field is what you put there. I > suspect the datagrid will then sort by the underlying data, not the displayed > data. > > I have a similar issue with SQL formatted dates, but I want to display them > as long dates. I'll toy around with this and see what I come up with. > > Bob S > > >> On Nov 2, 2018, at 14:26 , Klaus major-k via use-livecode >> wrote: >> >> Hi Bob, >> >>> Am 02.11.2018 um 22:14 schrieb Bob Sneidar via use-livecode >>> : >>> >>> There is no way I know of to have a datagrid sort by an invisible column >>> and still show that it is sorted by a visible one. Every time the datagrid >>> "redraws" it's going to update the appearance of the header to reflect the >>> sort. >> >> I was afraid of that. >> >>> If you want to force the sort when you populate the datagrid, then set the >>> dgProp ["sort by column"] of the datagrid to the column you want, and then >>> if the user sorts by a different column, well that's on them. >> >> We have a german app for Android and LC on Android still does not support >> "system date"! :-/ >> So I wanted to fake sorting a column with long german dates by sorting by a >> hidden column with an english date. >> Will have to roll my own with list fields. >> >> Thank you! >> >>> Bob S >> >> Best >> >> Klaus >> >> >> -- >> Klaus Major >> http://www.major-k.de >> kl...@major-k.de >> >> >> ___ >> 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
problem with mobileSetKeyboardType
I have not been able to get the "mobileSetKeyboardType" command to work on my android. I have tried various options, such as: on openField if the environment is "mobile" then mobileSetKeyboardType "alphabet" end if end openField and on mouseUp if the environment is "mobile" then mobileSetKeyboardType "alphabet" end if end mouseUp Neither work. All I get is the standard keyboard from the android. Any suggestions? Thanks. Mike ___ 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: Sorting datagrid column with a tricj?
In a table datagrid, can't you edit the column template so that you can control what goes into the field for that column? I think the underlying data will remain the same, but what goes into the field is what you put there. I suspect the datagrid will then sort by the underlying data, not the displayed data. I have a similar issue with SQL formatted dates, but I want to display them as long dates. I'll toy around with this and see what I come up with. Bob S > On Nov 2, 2018, at 14:26 , Klaus major-k via use-livecode > wrote: > > Hi Bob, > >> Am 02.11.2018 um 22:14 schrieb Bob Sneidar via use-livecode >> : >> >> There is no way I know of to have a datagrid sort by an invisible column and >> still show that it is sorted by a visible one. Every time the datagrid >> "redraws" it's going to update the appearance of the header to reflect the >> sort. > > I was afraid of that. > >> If you want to force the sort when you populate the datagrid, then set the >> dgProp ["sort by column"] of the datagrid to the column you want, and then >> if the user sorts by a different column, well that's on them. > > We have a german app for Android and LC on Android still does not support > "system date"! :-/ > So I wanted to fake sorting a column with long german dates by sorting by a > hidden column with an english date. > Will have to roll my own with list fields. > > Thank you! > >> Bob S > > Best > > Klaus > > > -- > Klaus Major > http://www.major-k.de > kl...@major-k.de > > > ___ > 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: Sorting datagrid column with a tricj?
Hi Bob, > Am 02.11.2018 um 22:14 schrieb Bob Sneidar via use-livecode > : > > There is no way I know of to have a datagrid sort by an invisible column and > still show that it is sorted by a visible one. Every time the datagrid > "redraws" it's going to update the appearance of the header to reflect the > sort. I was afraid of that. > If you want to force the sort when you populate the datagrid, then set the > dgProp ["sort by column"] of the datagrid to the column you want, and then if > the user sorts by a different column, well that's on them. We have a german app for Android and LC on Android still does not support "system date"! :-/ So I wanted to fake sorting a column with long german dates by sorting by a hidden column with an english date. Will have to roll my own with list fields. Thank you! > Bob S Best Klaus -- Klaus Major http://www.major-k.de kl...@major-k.de ___ 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: Sorting datagrid column with a tricj?
There is no way I know of to have a datagrid sort by an invisible column and still show that it is sorted by a visible one. Every time the datagrid "redraws" it's going to update the appearance of the header to reflect the sort. If you want to force the sort when you populate the datagrid, then set the dgProp ["sort by column"] of the datagrid to the column you want, and then if the user sorts by a different column, well that's on them. Bob S > On Nov 2, 2018, at 13:13 , Klaus major-k via use-livecode > wrote: > > Hi all, > > given a datagrid (table) with three columns > C1 -> visible > C2 -> visible > C3 -> invisible column > > Is it possible to sort a datagrid by column C3, although > the user has clicked the header of column C2. > Know what I mean? > > If this is possible, any hints on how to do this are highly appreciated. > > > Best > > Klaus > > -- > Klaus Major > http://www.major-k.de > kl...@major-k.de > > > ___ > 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: Sorting datagrid column with a tricj?
> Am 02.11.2018 um 21:27 schrieb Klaus major-k via use-livecode > : > > Hi all, > >> Am 02.11.2018 um 21:13 schrieb Klaus major-k via use-livecode >> : >> >> Hi all, >> >> given a datagrid (table) with three columns >> C1 -> visible >> C2 -> visible >> C3 -> invisible column >> >> Is it possible to sort a datagrid by column C3, although >> the user has clicked the header of column C2. >> Know what I mean? >> >> If this is possible, any hints on how to do this are highly appreciated. > > I tried this one, which works, but the header of column "C2" does not change > to reflect the sort direction, it looks like inactive. Know what I mean? Of course posting the script will help. 8-) -- on SortDataGridColumn pColumn if pColumn = "C2" then dispatch "SortByColumn" to me with "C3" else pass SortDataGridColumn end if end SortDataGridColumn -- Klaus Major http://www.major-k.de kl...@major-k.de ___ 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: Sorting datagrid column with a tricj?
Hi all, > Am 02.11.2018 um 21:13 schrieb Klaus major-k via use-livecode > : > > Hi all, > > given a datagrid (table) with three columns > C1 -> visible > C2 -> visible > C3 -> invisible column > > Is it possible to sort a datagrid by column C3, although > the user has clicked the header of column C2. > Know what I mean? > > If this is possible, any hints on how to do this are highly appreciated. I treid this one, which works, but the header of column "C2" does not change to reflect the sort direction, it looks like inactive. Know what I mean? So any clever hints or workaround still appreciated. Best Klaus -- Klaus Major http://www.major-k.de kl...@major-k.de ___ 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
Sorting datagrid column with a tricj?
Hi all, given a datagrid (table) with three columns C1 -> visible C2 -> visible C3 -> invisible column Is it possible to sort a datagrid by column C3, although the user has clicked the header of column C2. Know what I mean? If this is possible, any hints on how to do this are highly appreciated. Best Klaus -- Klaus Major http://www.major-k.de kl...@major-k.de ___ 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: How to find the offset of the last instance of a repeating character in a string? (Geoff Canyon)
how about allOffsets? Bob S > On Nov 2, 2018, at 09:16 , Geoff Canyon via use-livecode > wrote: > > All of those return a single value; I wanted to convey the concept of > returning multiple values. To me listOffset implies it does the same thing > as itemOffset, since items come in a list. How about: > > offsets -- not my favorite because it's almost indistinguishable from offset > offsetsOf -- seems a tad clumsy > > On Fri, Nov 2, 2018 at 7:41 AM Bob Sneidar via use-livecode < > use-livecode@lists.runrev.com> wrote: > >> It probably should be named listOffset, like itemOffset or lineOffset. >> >> Bob S >> >> >>> On Nov 1, 2018, at 17:04 , Geoff Canyon via use-livecode < >> use-livecode@lists.runrev.com> wrote: >>> >>> Nice! I *just* finished creating a github repository for it, and adding >>> support for multi-char search strings, much as you did. I was coming to >> the >>> list to post the update when I saw your post. >>> >>> Here's the GitHub link: https://github.com/gcanyon/offsetlist >>> >>> Here's my updated version: >>> >>> function offsetList D,S,pCase >>> -- returns a comma-delimited list of the offsets of D in S >>> set the caseSensitive to pCase is true >>> set the itemDel to D >>> put length(D) into dLength >>> put 1 - dLength into C >>> repeat for each item i in S >>> add length(i) + dLength to C >>> put C,"" after R >>> end repeat >>> set the itemDel to comma >>> if char -dLength to -1 of S is D then return char 1 to -2 of R >>> put length(C) + 1 into lenC >>> put length(R) into lenR >>> if lenC = lenR then return 0 >>> return char 1 to lenR - lenC - 1 of R >>> end offsetList >>> >>> On Thu, Nov 1, 2018 at 8:28 AM Niggemann, Bernd via use-livecode < >>> use-livecode@lists.runrev.com> wrote: >>> Hi Geoff, thank you for this beautiful script. I modified it a bit to accept multi-character search string and also for case sensitivity. It definitely is a lot faster for unicode text than anything I have >> seen. - function offsetList D,S, pCase -- returns a comma-delimited list of the offsets of D in S -- pCase is a boolean for caseSensitive set the caseSensitive to pCase set the itemDel to D put the length of D into tDelimLength repeat for each item i in S add length(i) + tDelimLength to C put C - (tDelimLength - 1),"" after R end repeat set the itemDel to comma if char -1 of S is D then return char 1 to -2 of R put length(C) + 1 into lenC put length(R) into lenR if lenC = lenR then return 0 return char 1 to lenR - lenC - 1 of R end offsetList -- Kind regards Bernd > > Date: Thu, 1 Nov 2018 00:15:37 -0700 > From: Geoff Canyon > To: How to use LiveCode > Subject: Re: How to find the offset of the last instance of a > repeating character in a string? > > I was curious if using the itemDelimiter might work for this, so I >> wrote > the below code out of curiosity; but in my quick testing with >> single-byte > characters it was only about 30% faster than the above methods, so I didn't > bother to post it. > > But Ben Rubinstein just posted about a terrible slow-down doing pretty much > this same thing for text with unicode characters. So I ran a simple >> test > with 8000 character long strings that start with a single unicode > character, this is about 15x faster than offset() with skip. For > 100,000-character lines it's about 300x faster, so it seems to be >> immune to > the line-painter issues skip is subject to. So for what it's worth: > > function offsetList D,S > -- returns a comma-delimited list of the offsets of D in S > set the itemDel to D > repeat for each item i in S >add length(i) + 1 to C >put C,"" after R > end repeat > set the itemDel to comma > if char -1 of S is D then return char 1 to -2 of R > put length(C) + 1 into lenC > put length(R) into lenR > if lenC = lenR then return 0 > return char 1 to lenR - lenC - 1 of R > end offsetList > ___ 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
Re: How to find the offset of the last instance of a repeating character in a string? (Geoff Canyon)
All of those return a single value; I wanted to convey the concept of returning multiple values. To me listOffset implies it does the same thing as itemOffset, since items come in a list. How about: offsets -- not my favorite because it's almost indistinguishable from offset offsetsOf -- seems a tad clumsy On Fri, Nov 2, 2018 at 7:41 AM Bob Sneidar via use-livecode < use-livecode@lists.runrev.com> wrote: > It probably should be named listOffset, like itemOffset or lineOffset. > > Bob S > > > > On Nov 1, 2018, at 17:04 , Geoff Canyon via use-livecode < > use-livecode@lists.runrev.com> wrote: > > > > Nice! I *just* finished creating a github repository for it, and adding > > support for multi-char search strings, much as you did. I was coming to > the > > list to post the update when I saw your post. > > > > Here's the GitHub link: https://github.com/gcanyon/offsetlist > > > > Here's my updated version: > > > > function offsetList D,S,pCase > > -- returns a comma-delimited list of the offsets of D in S > > set the caseSensitive to pCase is true > > set the itemDel to D > > put length(D) into dLength > > put 1 - dLength into C > > repeat for each item i in S > > add length(i) + dLength to C > > put C,"" after R > > end repeat > > set the itemDel to comma > > if char -dLength to -1 of S is D then return char 1 to -2 of R > > put length(C) + 1 into lenC > > put length(R) into lenR > > if lenC = lenR then return 0 > > return char 1 to lenR - lenC - 1 of R > > end offsetList > > > > On Thu, Nov 1, 2018 at 8:28 AM Niggemann, Bernd via use-livecode < > > use-livecode@lists.runrev.com> wrote: > > > >> Hi Geoff, > >> > >> thank you for this beautiful script. > >> > >> I modified it a bit to accept multi-character search string and also for > >> case sensitivity. > >> > >> It definitely is a lot faster for unicode text than anything I have > seen. > >> > >> - > >> function offsetList D,S, pCase > >> -- returns a comma-delimited list of the offsets of D in S > >> -- pCase is a boolean for caseSensitive > >> set the caseSensitive to pCase > >> set the itemDel to D > >> put the length of D into tDelimLength > >> repeat for each item i in S > >> add length(i) + tDelimLength to C > >> put C - (tDelimLength - 1),"" after R > >> end repeat > >> set the itemDel to comma > >> if char -1 of S is D then return char 1 to -2 of R > >> put length(C) + 1 into lenC > >> put length(R) into lenR > >> if lenC = lenR then return 0 > >> return char 1 to lenR - lenC - 1 of R > >> end offsetList > >> -- > >> > >> Kind regards > >> Bernd > >> > >> > >> > >> > >> > >>> > >>> Date: Thu, 1 Nov 2018 00:15:37 -0700 > >>> From: Geoff Canyon > >>> To: How to use LiveCode > >>> Subject: Re: How to find the offset of the last instance of a > >>> repeating character in a string? > >>> > >>> I was curious if using the itemDelimiter might work for this, so I > wrote > >>> the below code out of curiosity; but in my quick testing with > single-byte > >>> characters it was only about 30% faster than the above methods, so I > >> didn't > >>> bother to post it. > >>> > >>> But Ben Rubinstein just posted about a terrible slow-down doing pretty > >> much > >>> this same thing for text with unicode characters. So I ran a simple > test > >>> with 8000 character long strings that start with a single unicode > >>> character, this is about 15x faster than offset() with skip. For > >>> 100,000-character lines it's about 300x faster, so it seems to be > immune > >> to > >>> the line-painter issues skip is subject to. So for what it's worth: > >>> > >>> function offsetList D,S > >>> -- returns a comma-delimited list of the offsets of D in S > >>> set the itemDel to D > >>> repeat for each item i in S > >>> add length(i) + 1 to C > >>> put C,"" after R > >>> end repeat > >>> set the itemDel to comma > >>> if char -1 of S is D then return char 1 to -2 of R > >>> put length(C) + 1 into lenC > >>> put length(R) into lenR > >>> if lenC = lenR then return 0 > >>> return char 1 to lenR - lenC - 1 of R > >>> end offsetList > >>> > >> > >> > >> ___ > >> 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
Re: How to find the offset of the last instance of a repeating character in a string? (Geoff Canyon)
It probably should be named listOffset, like itemOffset or lineOffset. Bob S > On Nov 1, 2018, at 17:04 , Geoff Canyon via use-livecode > wrote: > > Nice! I *just* finished creating a github repository for it, and adding > support for multi-char search strings, much as you did. I was coming to the > list to post the update when I saw your post. > > Here's the GitHub link: https://github.com/gcanyon/offsetlist > > Here's my updated version: > > function offsetList D,S,pCase > -- returns a comma-delimited list of the offsets of D in S > set the caseSensitive to pCase is true > set the itemDel to D > put length(D) into dLength > put 1 - dLength into C > repeat for each item i in S > add length(i) + dLength to C > put C,"" after R > end repeat > set the itemDel to comma > if char -dLength to -1 of S is D then return char 1 to -2 of R > put length(C) + 1 into lenC > put length(R) into lenR > if lenC = lenR then return 0 > return char 1 to lenR - lenC - 1 of R > end offsetList > > On Thu, Nov 1, 2018 at 8:28 AM Niggemann, Bernd via use-livecode < > use-livecode@lists.runrev.com> wrote: > >> Hi Geoff, >> >> thank you for this beautiful script. >> >> I modified it a bit to accept multi-character search string and also for >> case sensitivity. >> >> It definitely is a lot faster for unicode text than anything I have seen. >> >> - >> function offsetList D,S, pCase >> -- returns a comma-delimited list of the offsets of D in S >> -- pCase is a boolean for caseSensitive >> set the caseSensitive to pCase >> set the itemDel to D >> put the length of D into tDelimLength >> repeat for each item i in S >> add length(i) + tDelimLength to C >> put C - (tDelimLength - 1),"" after R >> end repeat >> set the itemDel to comma >> if char -1 of S is D then return char 1 to -2 of R >> put length(C) + 1 into lenC >> put length(R) into lenR >> if lenC = lenR then return 0 >> return char 1 to lenR - lenC - 1 of R >> end offsetList >> -- >> >> Kind regards >> Bernd >> >> >> >> >> >>> >>> Date: Thu, 1 Nov 2018 00:15:37 -0700 >>> From: Geoff Canyon >>> To: How to use LiveCode >>> Subject: Re: How to find the offset of the last instance of a >>> repeating character in a string? >>> >>> I was curious if using the itemDelimiter might work for this, so I wrote >>> the below code out of curiosity; but in my quick testing with single-byte >>> characters it was only about 30% faster than the above methods, so I >> didn't >>> bother to post it. >>> >>> But Ben Rubinstein just posted about a terrible slow-down doing pretty >> much >>> this same thing for text with unicode characters. So I ran a simple test >>> with 8000 character long strings that start with a single unicode >>> character, this is about 15x faster than offset() with skip. For >>> 100,000-character lines it's about 300x faster, so it seems to be immune >> to >>> the line-painter issues skip is subject to. So for what it's worth: >>> >>> function offsetList D,S >>> -- returns a comma-delimited list of the offsets of D in S >>> set the itemDel to D >>> repeat for each item i in S >>> add length(i) + 1 to C >>> put C,"" after R >>> end repeat >>> set the itemDel to comma >>> if char -1 of S is D then return char 1 to -2 of R >>> put length(C) + 1 into lenC >>> put length(R) into lenR >>> if lenC = lenR then return 0 >>> return char 1 to lenR - lenC - 1 of R >>> end offsetList >>> >> >> >> ___ >> 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: Mysteries of Me
That make good sense I may use it some day. It would allow more handlers in a common back script/library that did the same thing (anything) when called from different modules (stacks) On 11/1/18 10:02 AM, Bob Sneidar via use-livecode wrote: > Well the big thing it deals with is ambiguity. I have a number of substacks > which are similar, like data entry forms for different tables in the > database, and these have many controls, properties and scripts in common, but > also some that are unique to that particular form. If only one of these > "form" stacks were allowed to be open at one time, there would be no > ambiguity, but I allow multiple "forms" to be opened at the same time, and > when I was using modal stacks, this presented a problem. So if at the > beginning of a handler I have: > > put getParentCard(the long id of me) into tParentCard -- returns the long id > of the parent card > put getParentStack(tParentCard) into tParentStack -- returns the long id of > the parent stack > > then I can make references like so: > > button "btnNew" of tParentCard > the databaseSettings of tParentStack > dispatch updateSettings to tParentStack with "true", "all" > > Even if another substack is open modally or happens to be the topstack, or if > I have an older version of the same application open in Livecode, there can > be no ambiguity because everything is resolving to long ids. I am no longer > relying on the fuzzy logic of the parser to figure out exactly which object, > card or stack I am referring to. > > Bob S -- Svasti Astu, Be Well! Brahmanathaswami Get the SivaSiva app, it's free: https://www.himalayanacademy.com/apps/sivasiva ___ 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: tree view hide key
There are two PRs currently in progress. 6764 and 6770. Neither address the custom sort (just an idea at this point, have not gotten to the code point). Thanks, Brian On Nov 2, 2018, 7:58 AM -0500, Mike Kerner via use-livecode , wrote: > what is the PR for this version? > > On Thu, Nov 1, 2018 at 7:29 PM Brian Milby via use-livecode < > use-livecode@lists.runrev.com> wrote: > > > Well, testing any of the fixes would require you to download the widget and > > build it as none of the 9.1 builds are out yet. > > > > I did have an idea about manual sorting of data in a tree view. I'll need > > to bounce it around in my head a bit to see if it would be workable. The > > basic idea would be to allow sorted lists of keys to be set for a parent > > node that would override the default sort. > > > > Double click to put data somewhere else should work - that is a message > > that is passed for leaf nodes. > > > > On Wed, Oct 31, 2018 at 6:04 PM Bob Sneidar via use-livecode < > > use-livecode@lists.runrev.com> wrote: > > > > > You and others have addressed a lot of the work I think, and thank you > > for > > > that by the way. One of the things I would like to see is something akin > > to > > > findRecord and findIndex in a datagrid. Of course, finding something > > > several levels in requires that you would need to return not just a > > number, > > > but a root node with the path to the found item, so you can reference it > > in > > > the future, getting and setting anything in the "path". > > > > > > I wanted to create a list of items with a name and value, but then I > > > realized I wanted to rearrange them, moving them up and down in the > > list. I > > > also wanted to be able to double-click an item and put the value into > > > another field. I call the feature "QuickNotes" where I have a pallette > > like > > > stack I can double click text snippets to fill in a field with text I > > type > > > often, as in a copier installation. > > > > > > In the end I used a datagrid so no big deal, but it left me wondering why > > > I would ever use a tree view. But as you mentioned a lot of work is being > > > done on it now. I cannot switch over to 9.1 yet because I made a custom > > > change in the datagrid behavior which allows me to nest behaviors, so > > until > > > that gets bundled into a release I cannot test any new changes (at least > > > not with my current project). > > > > > > Bob S > > > > > > > > > > On Oct 30, 2018, at 15:47 , Brian Milby via use-livecode < > > > use-livecode@lists.runrev.com> wrote: > > > > > > > > What kind of work? Here are a couple that I can think of that are not > > > > easily addressed: > > > > - Arbitrary sort would take significant changes (a couple options: 2 > > > part > > > > key [1,firstkey], [2,asecondkey] or restructuring the array format to > > > > something like [key][title], [key][value] where the title and > > optionally > > > > value would be displayed and keys just used for sorting). > > > > - Inline editing is something that LCB doesn't support. > > > > > > > > My goal is to submit a PR today that will facilitate keyboard > > navigation > > > (I > > > > want to add a couple properties that can be controlled from LCS which > > can > > > > handle the keypresses). > > > > > > > > Several code changes are already completed and either merged (9.1) or > > > > waiting review. > > > > - Numeric sort will now also sort the non-number entries below the > > > numbers > > > > - If you select a row that is hidden by folding, it will expand to show > > > the > > > > row > > > > - You can have the selected item scroll into view when selected > > > > - When an element is added interactively, it can be configured to > > > > auto-select the new element > > > > - You can reset the fold state to collapse the entire tree (optionally > > > > setting the arrayData at the same time) > > > > - MouseUp no longer registers as a click when the MouseDown was on a > > > > different row > > > > > > > > I don't see anything else in the QCC for the Tree Widget that I can > > > address > > > > at the moment. > > > > > > > > Thanks, > > > > Brian > > > > > > > > On Tue, Oct 30, 2018 at 5:08 PM Bob Sneidar via use-livecode < > > > > use-livecode@lists.runrev.com> wrote: > > > > > > > > > Yeah I really tried to like the tree view widget but it needs work. > > > > > > > > > > Sent from my iPhone > > > > > > > > > > > On Oct 30, 2018, at 13:38, Mike Kerner via use-livecode < > > > > > use-livecode@lists.runrev.com> wrote: > > > > > > > > > > > > In tree view can you hide the keys of the array? I was messing with > > > > > using > > > > > > it to display directory and subdirectory contents, but it seems that > > > you > > > > > > have to display the key, which makes some other things more > > difficult. > > > > > > ___ > > > > > > use-livecode mailing list > > > > > > use-livecode@lists.runrev.com > > > > > > Please visit this url to subscribe, unsubscribe an
Re: tree view hide key
what is the PR for this version? On Thu, Nov 1, 2018 at 7:29 PM Brian Milby via use-livecode < use-livecode@lists.runrev.com> wrote: > Well, testing any of the fixes would require you to download the widget and > build it as none of the 9.1 builds are out yet. > > I did have an idea about manual sorting of data in a tree view. I'll need > to bounce it around in my head a bit to see if it would be workable. The > basic idea would be to allow sorted lists of keys to be set for a parent > node that would override the default sort. > > Double click to put data somewhere else should work - that is a message > that is passed for leaf nodes. > > On Wed, Oct 31, 2018 at 6:04 PM Bob Sneidar via use-livecode < > use-livecode@lists.runrev.com> wrote: > > > You and others have addressed a lot of the work I think, and thank you > for > > that by the way. One of the things I would like to see is something akin > to > > findRecord and findIndex in a datagrid. Of course, finding something > > several levels in requires that you would need to return not just a > number, > > but a root node with the path to the found item, so you can reference it > in > > the future, getting and setting anything in the "path". > > > > I wanted to create a list of items with a name and value, but then I > > realized I wanted to rearrange them, moving them up and down in the > list. I > > also wanted to be able to double-click an item and put the value into > > another field. I call the feature "QuickNotes" where I have a pallette > like > > stack I can double click text snippets to fill in a field with text I > type > > often, as in a copier installation. > > > > In the end I used a datagrid so no big deal, but it left me wondering why > > I would ever use a tree view. But as you mentioned a lot of work is being > > done on it now. I cannot switch over to 9.1 yet because I made a custom > > change in the datagrid behavior which allows me to nest behaviors, so > until > > that gets bundled into a release I cannot test any new changes (at least > > not with my current project). > > > > Bob S > > > > > > > On Oct 30, 2018, at 15:47 , Brian Milby via use-livecode < > > use-livecode@lists.runrev.com> wrote: > > > > > > What kind of work? Here are a couple that I can think of that are not > > > easily addressed: > > > - Arbitrary sort would take significant changes (a couple options: 2 > > part > > > key [1,firstkey], [2,asecondkey] or restructuring the array format to > > > something like [key][title], [key][value] where the title and > optionally > > > value would be displayed and keys just used for sorting). > > > - Inline editing is something that LCB doesn't support. > > > > > > My goal is to submit a PR today that will facilitate keyboard > navigation > > (I > > > want to add a couple properties that can be controlled from LCS which > can > > > handle the keypresses). > > > > > > Several code changes are already completed and either merged (9.1) or > > > waiting review. > > > - Numeric sort will now also sort the non-number entries below the > > numbers > > > - If you select a row that is hidden by folding, it will expand to show > > the > > > row > > > - You can have the selected item scroll into view when selected > > > - When an element is added interactively, it can be configured to > > > auto-select the new element > > > - You can reset the fold state to collapse the entire tree (optionally > > > setting the arrayData at the same time) > > > - MouseUp no longer registers as a click when the MouseDown was on a > > > different row > > > > > > I don't see anything else in the QCC for the Tree Widget that I can > > address > > > at the moment. > > > > > > Thanks, > > > Brian > > > > > > On Tue, Oct 30, 2018 at 5:08 PM Bob Sneidar via use-livecode < > > > use-livecode@lists.runrev.com> wrote: > > > > > >> Yeah I really tried to like the tree view widget but it needs work. > > >> > > >> Sent from my iPhone > > >> > > >>> On Oct 30, 2018, at 13:38, Mike Kerner via use-livecode < > > >> use-livecode@lists.runrev.com> wrote: > > >>> > > >>> In tree view can you hide the keys of the array? I was messing with > > >> using > > >>> it to display directory and subdirectory contents, but it seems that > > you > > >>> have to display the key, which makes some other things more > difficult. > > >>> ___ > > >>> 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-livec