Re: Math problem
On Sun, Feb 19, 2012 at 12:58 AM, Kay C Lan lan.kc.macm...@gmail.comwrote: I've tweaked your solution only slightly as you solution only worked for quarter hour increment, whilst both mine and Paul's would work for any required increment . I simply replace your fixed 4 with the 3600/increment that both Paul and I were using. Bother -- I saw the optimization for my own routine but forgot to apply it to the other two. With this correction it seems Paul slips into the lead: For 100 cycles K's solution = 2378ms Paul's solution = 2021ms Geoff's solution = 2283ms I'm surprised that a div isn't faster than a /, but since (on checking) a div seems to work perfectly well with non-integers -- 4.5 div 1.5 = 3, for example -- I have to think that within the engine it's really just a / with the results trunc'd. To include a variable increment I've used an array rather than the simple list you used in your script, which seems to have slowed things down, as I got similar times to your original output, but still I'm surprised it's twice as slow. repeat for each line is incredibly fast, so I'm not surprised that it beats an array. Interestingly, I was able to speed up all three solutions by doing this: get aTime[i][Increment] and then using it in the math makes things faster. Arrays aren't just slow, they're slow every time. Here's my latest optimization. All three options are similar. Here are a couple runs: For 100 cycles K's solution = 1643ms Paul's solution = 1496ms Geoff's solution = 1533ms For 100 cycles K's solution = 1618ms Paul's solution = 1544ms Geoff's solution = 1577ms For 100 cycles K's solution = 1667ms Paul's solution = 1584ms Geoff's solution = 1530ms I tried longer tests, but they're still really close. on mouseUp put 100 into tRepeats put 1329494400 into tStartTime --create an array of variable end times and increments repeat with i = 1 to tRepeats put (1329494400 + random(36000)) into aTime[i][End] put 300 * random(6) into aTime[i][Increment] end repeat --K solution put the millisec into tStartClock repeat for each key i in aTime get aTime[i][Increment] put round(((aTime[i][End] + (it/2) - 1 - \ tStartTime)/it),0) * it /3600 cr after tStore2 end repeat put the millisec - tStartClock into tTotalTime1 --Paul's maxless solution put the millisec into tStartClock repeat for each key i in aTime get aTime[i][Increment] put round(((aTime[i][End] -tStartTime)/it)+\ 0.4999,0) * it /3600 cr after tStore3 end repeat put the millisec - tStartClock into tTotalTime2 if (tStore2 tStore3) then put Paul's solution doesn't = K's cr after tErrors end if --Geoff's revised any increment solution put the millisec into tStartClock repeat for each key i in aTime get aTime[i][Increment] put (aTime[i][End] - tStartTime + it - 1) \ div it * it / 3600 cr after tStore4 end repeat put the millisec - tStartClock into tTotalTime3 if (tStore2 tStore4) then put Geoff's solution doesn't = K's cr after tErrors end if if (tStore3 tStore4) then put Geoff's solution doesn't = Paul's cr after tErrors end if put For tRepeats cycles cr into R put K's solution = tTotalTime1 ms cr after R put Paul's solution = tTotalTime2 ms cr after R put Geoff's solution = tTotalTime3 ms cr after R put R tErrors end mouseUp ___ 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: 6 Is A Mystery Number
Fair point -- no clue here. On Sun, Feb 19, 2012 at 1:02 AM, J. Landman Gay jac...@hyperactivesw.comwrote: I was wondering if the engine counts it regardless of its visibility. ___ 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: Math problem
On Sun, Feb 19, 2012 at 4:48 PM, Geoff Canyon Rev gcanyon+...@gmail.comwrote: repeat for each line is incredibly fast, so I'm not surprised that it beats an array. Interestingly, I was able to speed up all three solutions by doing this: get aTime[i][Increment] and then using it in the math makes things faster. Arrays aren't just slow, they're slow every time. That is very interesting. I appreciate the general rule is 'repeat for each... is the fastest repeat, but I didn't appreciate the difference between item/line and key. Here's my latest amendment, which is getting a bit silly. It no longer amends any of the offered solutions, just the method of feeding them numbers. No more arrays, just nested repeat for each loops. For 100 cycles K's solution = 12730ms Paul's solution = 11707ms Geoff's solution = 12064ms For 100 cycles K's solution = 12767ms Paul's solution = 11755ms Geoff's solution = 12136ms For 100 cycles K's solution = 12759ms Paul's solution = 11709ms Geoff's solution = 12073ms on mouseUp put 100 into tRepeats put 1329494400 into tStartTime --create a list of end times repeat with i = 1 to tRepeats put (1329494400 + random(36000)) cr after tStore end repeat put 300,600,900,1200,1500,1800 into tAllIncrements --K solution put the millisec into tStartClock repeat for each line tEndTime in tStore repeat for each item tIncrement in tAllIncrements put round(((tEndTime + (tIncrement/2) - 1 - \ tStartTime)/tIncrement),0) * tIncrement /3600 cr after tStore2 end repeat end repeat put the millisec - tStartClock into tTotalTime1 --Paul's maxless solution put the millisec into tStartClock repeat for each line tEndTime in tStore repeat for each item tIncrement in tAllIncrements put round(((tEndTime - tStartTime)/tIncrement)+\ 0.4999,0) * tIncrement /3600 cr after tStore3 end repeat end repeat put the millisec - tStartClock into tTotalTime2 if (tStore2 tStore3) then put Paul's solution doesn't = K's cr after tErrors end if --Geoff's revised any increment solution put the millisec into tStartClock repeat for each line tEndTime in tStore repeat for each item tIncrement in tAllIncrements put (tEndTime - tStartTime + tIncrement - 1) \ div tIncrement * tIncrement / 3600 cr after tStore4 end repeat end repeat put the millisec - tStartClock into tTotalTime3 if (tStore2 tStore4) then put Geoff's solution doesn't = K's cr after tErrors end if if (tStore3 tStore4) then put Geoff's solution doesn't = Paul's cr after tErrors end if put For tRepeats cycles cr into R put K's solution = tTotalTime1 ms cr after R put Paul's solution = tTotalTime2 ms cr after R put Geoff's solution = tTotalTime3 ms cr after R put R tErrors end mouseUp ___ 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
Does 'quit' have a place in iOS apps?
AFAICS, iOS apps don't have an overt 'quit' button, since simply pressing the physical button on the device (I forgot its name) quits whatever is running. However this isn't quite right is it, since apps can go on being present and maybe actually running in the background. And then there is the question of what happens when your app gets itself into an unexpected state and has no alternative but to exit, which presumably would mean using a 'quit' command. Again, from the slender evidence I have, an explicit 'quit' may cause iOS to restart your app, tho not apparently in all circumstances. I have not yet found out the difference between stopping and leaving the app running in the background and really killing the app. Has anyone a clearer picture of how and why one would use 'quit' in the script of an iOS app? TIA Graham ___ 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: Math problem
On Sun, Feb 19, 2012 at 5:32 PM, Kay C Lan lan.kc.macm...@gmail.com wrote: put For tRepeats cycles cr into R Oopps. That should read For (6 * tRepeats) cycles cr into R Because of the nested repeat it's really doing 600 cycles. ___ 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: Math problem
Once I put 17 into tRepeats so I do 102 cycles, I get very similar: For 102 cycles K's solution = 1657ms Paul's solution = 1453ms Geoff's solution = 1536ms For 102 cycles K's solution = 1638ms Paul's solution = 1455ms Geoff's solution = 1533ms For 102 cycles K's solution = 1642ms Paul's solution = 1449ms Geoff's solution = 1531ms Now I think it's gone beyond silly to pointless... sorry. ___ 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: Does 'quit' have a place in iOS apps?
LC iOS apps don't stay alive when you quit them with the Home button. You can save and restore things to give the impressions of a quit and resume, but the app itself is killed when you quit. In my experience the on shutdown command is the best place to put stuff you want to do when the app quits. Gerry On 19/02/2012, at 8:39 PM, Graham Samuel wrote: AFAICS, iOS apps don't have an overt 'quit' button, since simply pressing the physical button on the device (I forgot its name) quits whatever is running. However this isn't quite right is it, since apps can go on being present and maybe actually running in the background. And then there is the question of what happens when your app gets itself into an unexpected state and has no alternative but to exit, which presumably would mean using a 'quit' command. Again, from the slender evidence I have, an explicit 'quit' may cause iOS to restart your app, tho not apparently in all circumstances. I have not yet found out the difference between stopping and leaving the app running in the background and really killing the app. Has anyone a clearer picture of how and why one would use 'quit' in the script of an iOS app? TIA Graham ___ 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: [OT] HyperCard and the Interactive Web
I saw one version where they built a robot arm (using LEGO, I think) to turn the pages. The process had thereby been completely automated. I also understand there is a Japanese company that does such scanning (and reasonably priced). Last time I looked, they had a backlog of months. I feel I am still caught in the past, as in so many ways I still prefer physical books. It's clear that my interest in books is something of a notoriety in the neighbourhood, as I found out that people used my house as a reference point (turn left at the library). I was kind of embarrassed when I heard that. Bernard On Sun, Feb 19, 2012 at 7:43 AM, Richmond richmondmathew...@gmail.com wrote: Really fascinating stuff..now how can I find the free time? ___ 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: Strange Tooltip behavior
Hi Pete, Am 17.02.2012 um 17:46 schrieb Pete: I have some code that sets the tooltip of a control to either some text or empty depending on a condition. If the code to set the tooltip to empty is executed, the tooltip is still displayed with its previous values. How can I get rid of the tooltip? ... set the toolTipDelay to 0 ## = no tooltip ... -- Pete Molly's Revenge http://www.mollysrevenge.com Best Klaus -- Klaus Major http://www.major-k.de kl...@major.on-rev.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: Strange Tooltip behavior
Thanks Klaus, good to know.. Pete On Sat, Feb 18, 2012 at 11:46 PM, Kay C Lan lan.kc.macm...@gmail.comwrote: As per the Dictionary: set the toolTipDelay to 0 -- no tooltip HTH On Sat, Feb 18, 2012 at 12:46 AM, Pete p...@mollysrevenge.com wrote: I have some code that sets the tooltip of a control to either some text or empty depending on a condition. If the code to set the tooltip to empty is executed, the tooltip is still displayed with its previous values. How can I get rid of the tooltip? -- Pete Molly's Revenge http://www.mollysrevenge.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 -- Pete Molly's Revenge http://www.mollysrevenge.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: [OT] HyperCard and the Interactive Web
On 02/19/2012 05:24 PM, Bernard Devlin wrote: I saw one version where they built a robot arm (using LEGO, I think) to turn the pages. The process had thereby been completely automated. I also understand there is a Japanese company that does such scanning (and reasonably priced). Last time I looked, they had a backlog of months. I feel I am still caught in the past, as in so many ways I still prefer physical books. It's clear that my interest in books is something of a notoriety in the neighbourhood, as I found out that people used my house as a reference point (turn left at the library). I was kind of embarrassed when I heard that. Bernard I wouldn't worry about that. In our flat one cannot see the living-room walls (in some places 3 books deep). Far more worrying, to my mind, are those who never read at all. On Sun, Feb 19, 2012 at 7:43 AM, Richmondrichmondmathew...@gmail.com wrote: Really fascinating stuff..now how can I find the free time? ___ 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
Visual effect problems in iOS
Folks, I have been trying to use 'visual effect' to make transitions between cards and between stacks on an iPad app and I am not getting anywhere. Firstly I can't get the transition between stacks to do anything. The syntax shown in the dictionary seems a bit ambiguous (I just want to move to another stack in the same window) but I am not seeing any transitions. So I decided to confine my effects to a single stack, just switching between cards. I built a tiny stack that just moves between cards using buttons that do this kind of thing: on mouseUp visual effect flip left go cd second end mouseUp This works fine in the simulator: but when I put the same bit of code into my actual app, the 'go' works but not the visual effect. Here is the actual code, copied from the app on mouseUp visual effect flip left go cd Diagram end mouseUp The card exists and is in the current stack. What can I possibly have done to stop the effect working? Beats me. FWIW, I'm using LC 5.0.2 on MacOS Lion 10.7.3 with version 4.2.1 of Xcode and version 5.0 of the simulator. The alwaysBuffer of the relevant stack is set to true. Puzzled Graham ___ 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
How to use an array to solve the following...
Having limited experience with arrays I thought this might be a good question to ask the group. Is the use of arrays to solve this appropriate? Efficient? Fast? If the answers are yes then it will help with the bigger problem that I am trying to address but for now I am looking for advice or help on how to do this using arrays... just a note the size that the solution would need to work on would involve a couple of hundred thousand rows. I have the following text field example with data Pacer xswt 104 207 40 22 60 71 12099 20012 I need to be able to ensure that between wt values that there is no more than 10 between xs values (this includes before and after a wt value). If there is then a new xs value must be added with a wt value of 0 This is what the solution should look like (ignoring the -- added comments). Pacer xswt 104 207 300 ---added because of wt =7 at 20 so a xs 0 value is added after 40 22 500 ---added because of wt =22 at 40 so a xs 0 value is added after ***but this then solves the problem of wt 71 at 60??!! 60 71 700 ---added because of wt =71 at 60 so a xs 0 value is added after 110 0 ---added because of wt =99 at 120 so a xs 0 value is added before 12099 130 0 ---added because of wt =99 at 120 so a xs 0 value is added after 190 0 ---added because of wt =12 at 200 so a xs 0 value is added before 20012 I look forward to comments and suggestions. regards, Glen ___ 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: Does 'quit' have a place in iOS apps?
Gerry, thanks for replying. That's what happens to my simple little app, but what about my favourite radio app, TuneIn Radio? It's feeding the BBC to me as I write this, but I could only access Mail by pressing the Home button after getting my radio station started, and it was definitely not killed. I'm sure there are lots of other examples... what is going on in these cases? Graham Sent from my iPad On Sun, 19 Feb 2012 21:44:09 +1100, Gerry Orkin gerry.or...@gmail.com LC iOS apps don't stay alive when you quit them with the Home button. You can save and restore things to give the impressions of a quit and resume, but the app itself is killed when you quit. In my experience the on shutdown command is the best place to put stuff you want to do when the app quits. Gerry On 19/02/2012, at 8:39 PM, Graham Samuel wrote: AFAICS, iOS apps don't have an overt 'quit' button, since simply pressing the physical button on the device (I forgot its name) quits whatever is running. However this isn't quite right is it, since apps can go on being present and maybe actually running in the background. And then there is the question of what happens when your app gets itself into an unexpected state and has no alternative but to exit, which presumably would mean using a 'quit' command. Again, from the slender evidence I have, an explicit 'quit' may cause iOS to restart your app, tho not apparently in all circumstances. I have not yet found out the difference between stopping and leaving the app running in the background and really killing the app. Has anyone a clearer picture of how and why one would use 'quit' in the script of an iOS app? TIA Graham ___ 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
How to manage user alerts from apps when in the background
Hi folks, Can LiveCode alert the user of things such as inbound message when the app is in the background? I'm guessing this is all about OS-specific features - notifications on iOS, maybe Growl for OSX and whatever those system tray icons and 'tooltips' are on windows. If it's possible, where should I start my studying - what's LiveCode feature am I looking for? Best, Keith.. ___ 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 manage user alerts from apps when in the background
Hi Keith, Just a note about iOS... As of this moment LiveCode apps running on iOS aren't capable of running in the background. They quit. Todd Keith Clarke mailto:keith.cla...@clarkeandclarke.co.uk February 19, 2012 11:49 AM Hi folks, Can LiveCode alert the user of things such as inbound message when the app is in the background? I'm guessing this is all about OS-specific features - notifications on iOS, maybe Growl for OSX and whatever those system tray icons and 'tooltips' are on windows. If it's possible, where should I start my studying - what's LiveCode feature am I looking for? Best, Keith.. ___ 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 manage user alerts from apps when in the background
...thanks Todd. I wasn't aware that any apps could run in the background in iOS - so I was assuming notifications 'to' iOS 'for' the registered app there. I didn't find any non-iOS notification entries in the dictionary, so I assume this means OSX and Windows don't support generic notifications (or they are called something else). So, for OSX, I guess I'd need to use Growl - perhaps with Monte Goulding's Growl plugin http://goulding.ws/2010/10/29/livecode-growl-plugin/ For Windows, I've found STSTray http://www.sonsothunder.com/products/ststray/ststray.htm but I'm not sure if this works beyond Vista - is anyone using it on Windows 7? Before I go further, am I correct in assuming that my app would have to manage the notification mechanism for each target platform's stand-alone and that there are no higher-level cross-platform notification mgt functions hiding under a different title? Best, Keith.. On 19 Feb 2012, at 19:55, Todd Geist wrote: Hi Keith, Just a note about iOS... As of this moment LiveCode apps running on iOS aren't capable of running in the background. They quit. Todd Keith Clarke mailto:keith.cla...@clarkeandclarke.co.uk February 19, 2012 11:49 AM Hi folks, Can LiveCode alert the user of things such as inbound message when the app is in the background? I'm guessing this is all about OS-specific features - notifications on iOS, maybe Growl for OSX and whatever those system tray icons and 'tooltips' are on windows. If it's possible, where should I start my studying - what's LiveCode feature am I looking for? Best, Keith.. ___ 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: Valentina 5 Platform Announced; Reports, Valentina Studio forPostgre, Valentina DB and SQLite
On 2/19/12 2:21 AM, Michael Chean mp.ch...@gmail.com wrote: On another more direct note, I could not find the download link for the version you announced above. And my attempts to download the prior version kept getting a corrupt copy. Could you post the download link if it's available for he Valentina Studio? Hi Mike, 1) announced version is not on FTP yet . I think we will upload first betas of 5.0 next week then we will inform again, 2) you can try download 4.9.1 here using direct links: http://www.valentina-db.com/download/release -- Best regards, Ruslan Zasukhin VP Engineering and New Technology Paradigma Software, Inc Valentina - Joining Worlds of Information http://www.paradigmasoft.com [I feel the need: the need for 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: 6 Is A Mystery Number
Hi Scott, as of version 4.6 and later this does seem to give the same of the max scroll whether your force it by setting the scroll to a very large number or use this script: --- on mouseUp put the formattedHeight of field 1 into tFormat put the height of field 1 into tHeight put the borderwidth of field 1 into tBorder put 0 into tBorderKorr if tBorder 0 then put 5 into tBorderKorr if tBorder 2 then add 1 to tBorderKorr end if if not the showBorder of field 1 then if the hScrollbar of field 1 then add 2 to tBorderKorr else add 4 to tBorderKorr end if end if else -- borderwidth = 0 put 5 into tBorderKorr end if if the hScrollbar of field 1 then add 1 to tBorderKorr end if put tFormat - tHeight - tBorderKorr into tSum set the scroll of field 1 to tSum --- end of calculation of the max scroll set the scroll of field 1 to 10 -- let it update, not necessary but who knows unlock screen wait 5 milliseconds with messages put the scroll of field 1 into tScroll put calculated max scroll tSum cr actual max scroll tScroll cr difference tSum - tScroll into field 2 -- if the difference is 0 then you found a flaw in this end mouseUp --- I don't know the reason why this is the way it is. This works for me for many different combinations of borderwidths/visibility/scrollbars. I might have forgotten some combination though. If you scroll manually to the max there at times is a 1 pixel difference and at other times not. Prior to 4.6 you had to account for the height of the hScrollBar if it was shown. Prior to 4.5 on a Mac only you also had to take into account the focusedBorder if set to true and active. Kind regards Bernd -- View this message in context: http://runtime-revolution.278305.n4.nabble.com/6-Is-A-Mystery-Number-tp4399193p4402679.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: How to use an array to solve the following...
Glen. I sort of get what you are trying to do, and yes, arrays will be the most compact way to do it, though regular variables can work as well. But what happens if you already have the xs values in conecutive by 10 order? Are you allowed to bump later values by 10? In other words, are you required to insert values at certain places in the list? Does this matter? I don't see the rationale behind where you inserted new values in your example. Or in yet other words, why can't new data be appended to the list, incremented by 10 in the xs portion? This is something I need to know to even start thinking about a method. Craig Newman -Original Message- From: Glen Bojsza gboj...@gmail.com To: How to use LiveCode use-livecode@lists.runrev.com Sent: Sun, Feb 19, 2012 1:56 pm Subject: How to use an array to solve the following... Having limited experience with arrays I thought this might be a good question to ask the group. Is the use of arrays to solve this appropriate? Efficient? Fast? If the answers are yes then it will help with the bigger problem that I am trying to address but for now I am looking for advice or help on how to do this using arrays... just a note the size that the solution would need to work on would involve a couple of hundred thousand rows. I have the following text field example with data Pacer xswt 104 207 40 22 60 71 12099 20012 I need to be able to ensure that between wt values that there is no more than 10 between xs values (this includes before and after a wt value). If there is then a new xs value must be added with a wt value of 0 This is what the solution should look like (ignoring the -- added comments). Pacer xswt 104 207 300 ---added because of wt =7 at 20 so a xs 0 value is added after 40 22 500 ---added because of wt =22 at 40 so a xs 0 value is added after ***but this then solves the problem of wt 71 at 60??!! 60 71 700 ---added because of wt =71 at 60 so a xs 0 value is added after 110 0 ---added because of wt =99 at 120 so a xs 0 value is added before 12099 130 0 ---added because of wt =99 at 120 so a xs 0 value is added after 190 0 ---added because of wt =12 at 200 so a xs 0 value is added before 20012 I look forward to comments and suggestions. regards, Glen ___ 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
Socket reading problem
I'm trying to read data from a socket. The data is Modbus/TCP. The first routine I tried is read from socket pSock for 3 uInt2s This gives me no data (both it and the result are empty). I know the packet has been received and there is data after these 3 numbers. If I change this to: read from socket for 6 chars put it into tData put binaryDecode(m3, tData, tSeq, tProto, tBytes) then tSeq, tProto, and tBytes get the right data in them. I have tried the first method with and without a callback message to no avail. Am I missing something? len morgan ___ 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
binaryDecode with variable number of parameters
Related to my problem with reading binary data from a socket, how do I handle a variable number of numbers that will come in with binaryDecode? To explain, I get a number in the packet header that tells me there are x number of bytes to follow in this packet. I know the first byte is a remote ID and the second is a function code. Based on the function code, the number of two byte integers that follows is going to be (the number of bytes in the message / 2) - 1 (for the function code and remote ID). One time there might be 2 integers to follow, another there might be 10. There is a number of words number that is part of the command so I know how many words there will be but the binaryDecode function requires that I specify a name for each variable that is going to get a value. Ideally, I'd like to put all of these words in an array so I can process them, but this doesn't seem to be an option for the binaryDecode command. Should I build up a string that has ...,var[0],var[1],...,var[x] in it to account for all the variables and then use a do or dispatch to actually do the binaryDecode? Also, if I use var[0], var[1], etc., do I need to create ALL of the indexes first (for binaryDecode) or will just creating the first one (var[0]) be sufficient? Thanks, len morgan ___ 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
ButtonGadget2
Is anyone still using ButtonGadget2? If so, is it still being supported? If not, what happened to Altuit? ___ 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: ButtonGadget2
Cal- Sunday, February 19, 2012, 4:09:40 PM, you wrote: Is anyone still using ButtonGadget2? If so, is it still being supported? If not, what happened to Altuit? ButtonGadget has its own website now. http://www.buttongadget.com/buttongadget2/default.htm As you might have discovered if you had looked at www.altuit.com. -- -Mark Wieder mwie...@ahsoftware.net ___ 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: Socket reading problem
Len- Sunday, February 19, 2012, 3:34:41 PM, you wrote: I'm trying to read data from a socket. The data is Modbus/TCP. The first routine I tried is read from socket pSock for 3 uInt2s LC doesn't know from uints. Your best bet is to read them as chars (or more precisely as bytes), as you're doing in your second example. -- -Mark Wieder mwie...@ahsoftware.net ___ 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: binaryDecode with variable number of parameters
Len- Sunday, February 19, 2012, 4:08:24 PM, you wrote: Related to my problem with reading binary data from a socket, how do I handle a variable number of numbers that will come in with binaryDecode? To explain, I get a number in the packet header that tells me there are x number of bytes to follow in this packet. I know the first byte is a remote ID and the second is a function code. Based on the function code, the number of two byte integers that follows is going to be (the number of bytes in the message / 2) - 1 (for the function code and remote ID). One time there might be 2 integers to follow, another there might be 10. There is a number of words number that is part of the command so I know how many words there will be but the binaryDecode function requires that I specify a name for each variable that is going to get a value. Ideally, I'd like to put all of these words in an array so I can process them, but this doesn't seem to be an option for the binaryDecode command. Should I build up a string that has ...,var[0],var[1],...,var[x] in it to account for all the variables and then use a do or dispatch to actually do the binaryDecode? Also, if I use var[0], var[1], etc., do I need to create ALL of the indexes first (for binaryDecode) or will just creating the first one (var[0]) be sufficient? I think I'd do something like: read from socket for 1 bytes put it into tRemoteID read from socket for 1 bytes put it into tFunctionCode switch tFunctionCode case kFunc1 put 2 into tWordCount break case kFunc2 put 10 into tWordCount break case -- ok - you get the idea break end switch read from socket for (2*tWordCount) bytes put it into tData put binaryDecode(m3, tData, tSeq, tProto, tBytes) into tActual if tActual is not tWordCount then -- oops end if ...and yes, you do need to have the maximum number of variables already defined. There's no penalty for having extra compartments in the binaryDecode line, but you don't want to have too few. -- -Mark Wieder mwie...@ahsoftware.net ___ 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
[ANN] mergXattr iOS extended file attribute external
Hi Everyone There's a new external up on mergext.com (mergXattr) to set the do not backup and file protection attributes of files. There is also a poll for you to vote on what external you would most like added to the mergExt suite. If something you need isn't listed then please email me. Right now movie picking is in the lead with game kit a close runner up. Cheers Monte ___ 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 use an array to solve the following...
The xs values should only be bumped if the preceding xs value is not the one in sequence using 10 as the increment. No xs value (other than the very first one or the very last one cannot have a neighboring xs value within the increment range. for example xs wt 10 6 80 7 13023 staring with the first xs value we see that the nearest neighbor is more than one 10 increment away so a neighbor must be added and the wt value will always be 0 when adding a neighbor. xs wt 10 6 20 0 this is added 80 7 13023 now we look at the original sequence at the next xs value (we do not start over at the first xs value) so the next xs value is 80 which will need a neighbor to be added on both sides since the closest xs value on either side the lower one is 20 (yes in comparing the nearest neighbor you need to consider new ones added) and upper one is 130. xs wt 10 6 20 0 this is added 70 0 this is added 80 7 90 0 this is added 13023 and now we look at the next xs value from the original sequence which is 130 and since it is the last value it only needs a lower neighbor to be added since 90 is the closest one xs wt 10 6 20 0 this is added 70 0 this is added 80 7 90 0 this is added 1200 this is added 13023 This is now solved! Hopefully this makes the earlier example easier to follow. I am trying to avoid repeat with loops since this may make large data sets very slow verses repeat for statements. Again, maybe with arrays this can be done via keys? The bigger picture will be trying to do this where there may be 3 or more columns. On Sun, Feb 19, 2012 at 4:20 PM, dunb...@aol.com wrote: Glen. I sort of get what you are trying to do, and yes, arrays will be the most compact way to do it, though regular variables can work as well. But what happens if you already have the xs values in conecutive by 10 order? Are you allowed to bump later values by 10? In other words, are you required to insert values at certain places in the list? Does this matter? I don't see the rationale behind where you inserted new values in your example. Or in yet other words, why can't new data be appended to the list, incremented by 10 in the xs portion? This is something I need to know to even start thinking about a method. Craig Newman -Original Message- From: Glen Bojsza gboj...@gmail.com To: How to use LiveCode use-livecode@lists.runrev.com Sent: Sun, Feb 19, 2012 1:56 pm Subject: How to use an array to solve the following... Having limited experience with arrays I thought this might be a good question to ask the group. Is the use of arrays to solve this appropriate? Efficient? Fast? If the answers are yes then it will help with the bigger problem that I am trying to address but for now I am looking for advice or help on how to do this using arrays... just a note the size that the solution would need to work on would involve a couple of hundred thousand rows. I have the following text field example with data Pacer xswt 104 207 40 22 60 71 12099 20012 I need to be able to ensure that between wt values that there is no more than 10 between xs values (this includes before and after a wt value). If there is then a new xs value must be added with a wt value of 0 This is what the solution should look like (ignoring the -- added comments). Pacer xswt 104 207 300 ---added because of wt =7 at 20 so a xs 0 value is added after 40 22 500 ---added because of wt =22 at 40 so a xs 0 value is added after ***but this then solves the problem of wt 71 at 60??!! 60 71 700 ---added because of wt =71 at 60 so a xs 0 value is added after 110 0 ---added because of wt =99 at 120 so a xs 0 value is added before 12099 130 0 ---added because of wt =99 at 120 so a xs 0 value is added after 190 0 ---added because of wt =12 at 200 so a xs 0 value is added before 20012 I look forward to comments and suggestions. regards, Glen ___ 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: Does 'quit' have a place in iOS apps?
On Feb 19, 2012, at 1:43 PM, Graham Samuel wrote: Gerry, thanks for replying. That's what happens to my simple little app, but what about my favourite radio app, TuneIn Radio? It's feeding the BBC to me as I write this, but I could only access Mail by pressing the Home button after getting my radio station started, and it was definitely not killed. I'm sure there are lots of other examples... what is going on in these cases? Graham, there are certain services that iOS allows to run in the background - phone, music, and a few others. All other operations are suspended and then resumed when the application is restored. But that only works for apps that understand the 'suspend/resume' implementation that came about with iOS 4; prior to that, apps were closed and relaunched. This still happens with apps that aren't designed to understand 'suspend/resume', which I assume is the case with LC apps. Ken Ray Sons of Thunder Software, Inc. Email: k...@sonsothunder.com Web Site: http://www.sonsothunder.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: How to manage user alerts from apps when in the background
For Windows, I've found STSTray http://www.sonsothunder.com/products/ststray/ststray.htm but I'm not sure if this works beyond Vista - is anyone using it on Windows 7? It works on Windows 7, but the icon in the tray is stuck at 256 colors at the moment… I just tested the demo on Win 7 and it works fine. Ken Ray Sons of Thunder Software, Inc. Email: k...@sonsothunder.com Web Site: http://www.sonsothunder.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: binaryDecode with variable number of parameters
Related to my problem with reading binary data from a socket, how do I handle a variable number of numbers that will come in with binaryDecode? To explain, I get a number in the packet header that tells me there are x number of bytes to follow in this packet. I know the first byte is a remote ID and the second is a function code. Based on the function code, the number of two byte integers that follows is going to be (the number of bytes in the message / 2) - 1 (for the function code and remote ID). One time there might be 2 integers to follow, another there might be 10. There is a number of words number that is part of the command so I know how many words there will be but the binaryDecode function requires that I specify a name for each variable that is going to get a value. Ideally, I'd like to put all of these words in an array so I can process them, but this doesn't seem to be an option for the binaryDecode command. Should I build up a string that has ...,var[0],var[1],...,var[x] in it to account for all the variables and then use a do or dispatch to actually do the binaryDecode? Also, if I use var[0], var[1], etc., do I need to create ALL of the indexes first (for binaryDecode) or will just creating the first one (var[0]) be sufficient? I think I'd do something like: read from socket for 1 bytes put it into tRemoteID read from socket for 1 bytes put it into tFunctionCode switch tFunctionCode case kFunc1 put 2 into tWordCount break case kFunc2 put 10 into tWordCount break case -- ok - you get the idea break end switch read from socket for (2*tWordCount) bytes put it into tData put binaryDecode(m3, tData, tSeq, tProto, tBytes) into tActual if tActual is not tWordCount then -- oops end if ...and yes, you do need to have the maximum number of variables already defined. There's no penalty for having extra compartments in the binaryDecode line, but you don't want to have too few. Thanks for the reply Mark but it's not quite the problem. The order that the data comes in is: tSequence, tProto, tBytes (all 16 bit), tRemoteID, tFunctionCode, x After the function code, if you are doing a write multiple registers for example, you will have a beginning register, and the count of registers, followed by the actual data you are trying to write. This is where things start to fall down for me because of this variable number of items and the requirement to have a predefined variable for each possible answer. I know when I get to the data portion exactly how many registers I'm going to have to read (and therefore how many variables I'm going to need). Based on your last paragraph though, it appears that I'll have to either have a separate case for each possible number of data words, or read them one at a time in a loop and assign them to a variable in the loop. Neither of those is the optimal way to go but one must do what one must do. :-) Also, do you happen to know about using an array with only one index assigned and a N* for example in the format string? Since the array exists already (and the first element I'd be assigning to) could I get away with passing an array NAME and have it create the extra elements or will that doom me to writing an oops handler? I'm grabbing at straws here. :-) len morgan ___ 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: Socket reading problem
On 2/19/2012 6:29 PM, Mark Wieder wrote: Len- Sunday, February 19, 2012, 3:34:41 PM, you wrote: I'm trying to read data from a socket. The data is Modbus/TCP. The first routine I tried is read from socket pSock for 3 uInt2s LC doesn't know from uints. Your best bet is to read them as chars (or more precisely as bytes), as you're doing in your second example. I thought this was true until I looked it up in the dictionary. It states that those are valid chunkTypes. Has that changed from 4.5 to 5.0? To be honest, I don't remember seeing that there before today and it would have been handy. Also available: int, int2, int4, uInt, uInt2, uInt4 - at least according to the dictionary. len ___ 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: binaryDecode with variable number of parameters
Hi Len, You could use a repeat loop, similar to repeat with x = 1 to myNrOfWords get binaryDecode(h*,word x of myData,myTempVar) put myTempVar into myArray[x] end repeat -- Kind regards, Mark Schonewille Economy-x-Talk Http://economy-x-talk.com Share the clipboard of your computer over a local network with Clipboard Link http://clipboardlink.economy-x-talk.com Op 20 feb. 2012 om 01:08 heeft Len Morgan len-mor...@crcom.net het volgende geschreven: Related to my problem with reading binary data from a socket, how do I handle a variable number of numbers that will come in with binaryDecode? To explain, I get a number in the packet header that tells me there are x number of bytes to follow in this packet. I know the first byte is a remote ID and the second is a function code. Based on the function code, the number of two byte integers that follows is going to be (the number of bytes in the message / 2) - 1 (for the function code and remote ID). One time there might be 2 integers to follow, another there might be 10. There is a number of words number that is part of the command so I know how many words there will be but the binaryDecode function requires that I specify a name for each variable that is going to get a value. Ideally, I'd like to put all of these words in an array so I can process them, but this doesn't seem to be an option for the binaryDecode command. Should I build up a string that has ...,var[0],var[1],...,var[x] in it to account for all the variables and then use a do or dispatch to actually do the binaryDecode? Also, if I use var[0], var[1], etc., do I need to create ALL of the indexes first (for binaryDecode) or will just creating the first one (var[0]) be sufficient? Thanks, len morgan ___ 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 use an array to solve the following...
On Mon, Feb 20, 2012 at 2:53 AM, Glen Bojsza gboj...@gmail.com wrote: Is the use of arrays to solve this appropriate? Efficient? Fast? From another recent thread, using arrays is slower than repeat for each line, and if the values you give are realistic (not lines with 1 chars) then even if you have a million lines, repeat for each will be fast and efficient. My script below I creat a list of: 10 6 80 7 130 23 140 2 150 22 and the script produces: 106 200 700 807 900 1200 13023 1402 1500 16022 Throw this into a button and see if it works for you: on mouseUp --create a list to start with put 10 tab 6 cr \ 80 tab 7 cr \ 130 tab 23 cr \ 140 tab 2 cr \ 160 tab 22 into tStore --actual work done here set the itemDelimiter to tab put first into tLastItem repeat for each line tLine in tStore put item 1 of tLine into tCheck switch case (tLastItem = first) --don't do anything break case (tCheck - tLastItem 20) put tLastItem + 10 tab 0 cr after tStore2 put tCheck - 10 tab 0 cr after tStore2 break case (tCheck - tLastItem 10) put tCheck - 10 tab 0 cr after tStore2 break end switch put tLine cr after tStore2 put tCheck into tLastItem end repeat put tStore2 into msg end mouseUp HTH ___ 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 use an array to solve the following...
Whoops typo, the start dummy list is 10 6 80 7 130 23 140 2 160 22 --- 160, not 150 ___ 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: binaryDecode with variable number of parameters
Hi Mark, It looks like that's what I'm going to have to do. In looking at your code though, the word x part (where the binary data is) won't that only work on real words that have spaces between them? This is actually a chunk of binary data where I'm using word in the sense of 2 8 bit bytes together. Wouldn't I need to whack off the first two characters of myData each time through the loop or does binaryDecode keep track of where it last stopped converting? len On 2/19/2012 8:05 PM, Mark Schonewille wrote: Hi Len, You could use a repeat loop, similar to repeat with x = 1 to myNrOfWords get binaryDecode(h*,word x of myData,myTempVar) put myTempVar into myArray[x] end repeat -- Kind regards, Mark Schonewille Economy-x-Talk Http://economy-x-talk.com Share the clipboard of your computer over a local network with Clipboard Link http://clipboardlink.economy-x-talk.com Op 20 feb. 2012 om 01:08 heeft Len Morganlen-mor...@crcom.net het volgende geschreven: Related to my problem with reading binary data from a socket, how do I handle a variable number of numbers that will come in with binaryDecode? To explain, I get a number in the packet header that tells me there are x number of bytes to follow in this packet. I know the first byte is a remote ID and the second is a function code. Based on the function code, the number of two byte integers that follows is going to be (the number of bytes in the message / 2) - 1 (for the function code and remote ID). One time there might be 2 integers to follow, another there might be 10. There is a number of words number that is part of the command so I know how many words there will be but the binaryDecode function requires that I specify a name for each variable that is going to get a value. Ideally, I'd like to put all of these words in an array so I can process them, but this doesn't seem to be an option for the binaryDecode command. Should I build up a string that has ...,var[0],var[1],...,var[x] in it to account for all the variables and then use a do or dispatch to actually do the binaryDecode? Also, if I use var[0], var[1], etc., do I need to create ALL of the indexes first (for binaryDecode) or will just creating the first one (var[0]) be sufficient? Thanks, len morgan ___ 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 use an array to solve the following...
Here's the same solution, but with 101 records. On my machine, over 3 runs I get, 4924 millisec, 4932 ms, 4914 ms. I'm sure others will now improve on that. There are a couple of extra lines to do the timing which you'd remove for your solution. on mouseUp --create the dummy list put 100 into tRepeat put 10 tab 5 cr after tStore put 10 into tLast repeat tRepeat times put (10 * random(5) + tLast) into tLast put tLast tab random(30) cr after tStore end repeat --do the work here set the itemDelimiter to tab put the millisec into tStartTime put first into tLastItem repeat for each line tLine in tStore put item 1 of tLine into tCheck switch case (tLastItem = first) --don't do anything break case (tCheck - tLastItem 20) put tLastItem + 10 tab 0 cr after tStore2 put tCheck - 10 tab 0 cr after tStore2 break case (tCheck - tLastItem 10) put tCheck - 10 tab 0 cr after tStore2 break end switch put tLine cr after tStore2 put tCheck into tLastItem end repeat put the millisec into tEndTime put (tEndTime - tStartTime) ms into msg end mouseUp ___ 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 use an array to solve the following...
Hi Kay, This looks very good mainly the use of case with the decision being the switch... never thought about that. Also, I didn't realize that arrays would be slower... I will test this with some of the data sets ... currently up to 80,000 lines but with values I have indicated... but I like the simplicity. I posted the bigger picture but it got jammed due to size so I just pasted the new info here... The biggest picture would be having 10 lists with each list having the xs column but a different ?t column (wt, gt, st, mt, qt, ... etc) The first and last xs value for each list will always be the same and can start at 10 and go to 100,000+ but other than that there will be randomness in the step increments. The goal would be the same but towards building a master list where each associated column would meet the neighbor criteria with the xs column. You can see the xs column increments grow and the already established column values (in this case wt) get a value of 0 for the new xs increments. Given this and the possible number of columns and values is there still a good approach in using arrays? For example... we see from Pacer List xs wt 10 6 80 7 13023 we got Master list xs wt 10 6 20 0 this is added 70 0 this is added 80 7 90 0 this is added 1200 this is added 13023 Train List xs gt 10 32 40 67 130 55 new master list would be xs wtgt 10 632 20 0 0 30 0 0 -- added to xs updated wt value 40 0 67 -- added to xs updated wt value 50 0 0 -- added to xs updated wt value 70 0 0 80 7 0 90 0 0 1200 0 1302355 ___ 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: Socket reading problem
Len- Sunday, February 19, 2012, 5:25:32 PM, you wrote: LC doesn't know from uints. Your best bet is to read them as chars (or more precisely as bytes), as you're doing in your second example. I thought this was true until I looked it up in the dictionary. It states that those are valid chunkTypes. Has that changed from 4.5 to 5.0? To be honest, I don't remember seeing that there before today and it would have been handy. Also available: int, int2, int4, uInt, uInt2, uInt4 - at least according to the dictionary. Well whaddya know about that! I'm gonna have to rtfm one of these days. Grasping at straws here, you specified uInt2s rather than uint2 ... it's possible that the plural form doesn't work. -- -Mark Wieder mwie...@ahsoftware.net ___ 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: binaryDecode with variable number of parameters
Len- Sunday, February 19, 2012, 5:23:11 PM, you wrote: Related to my problem with reading binary data from a socket, how do I handle a variable number of numbers that will come in with binaryDecode? To explain, I get a number in the packet header that tells me there are x number of bytes to follow in this packet. I know the first byte is a remote ID and the second is a function code. Based on the function code, the number of two byte integers that follows is going to be (the number of bytes in the message / 2) - 1 (for the function code and remote ID). One time there might be 2 integers to follow, another there might be 10. There is a number of words number that is part of the command so I know how many words there will be but the binaryDecode function requires that I specify a name for each variable that is going to get a value. Ideally, I'd like to put all of these words in an array so I can process them, but this doesn't seem to be an option for the binaryDecode command. Should I build up a string that has ...,var[0],var[1],...,var[x] in it to account for all the variables and then use a do or dispatch to actually do the binaryDecode? Also, if I use var[0], var[1], etc., do I need to create ALL of the indexes first (for binaryDecode) or will just creating the first one (var[0]) be sufficient? I think I'd do something like: read from socket for 1 bytes put it into tRemoteID read from socket for 1 bytes put it into tFunctionCode switch tFunctionCode case kFunc1 put 2 into tWordCount break case kFunc2 put 10 into tWordCount break case -- ok - you get the idea break end switch read from socket for (2*tWordCount) bytes put it into tData put binaryDecode(m3, tData, tSeq, tProto, tBytes) into tActual if tActual is not tWordCount then -- oops end if ...and yes, you do need to have the maximum number of variables already defined. There's no penalty for having extra compartments in the binaryDecode line, but you don't want to have too few. Thanks for the reply Mark but it's not quite the problem. The order that the data comes in is: tSequence, tProto, tBytes (all 16 bit), tRemoteID, tFunctionCode, x After the function code, if you are doing a write multiple registers for example, you will have a beginning register, and the count of registers, followed by the actual data you are trying to write. This is where things start to fall down for me because of this variable number of items and the requirement to have a predefined variable for each possible answer. I know when I get to the data portion exactly how many registers I'm going to have to read (and therefore how many variables I'm going to need). Based on your last paragraph though, it appears that I'll have to either have a separate case for each possible number of data words, or read them one at a time in a loop and assign them to a variable in the loop. Neither of those is the optimal way to go but one must do what one must do. :-) So by the time you get to tFunctionCode you know how many bytes will be coming in the stream, right? That's the x data? I still think something like this is the easiest and most maintainable way to go. How many functionCodes are you dealing with? local tData1, tData2, tData3, tData4, ... read from socket for 6 bytes put it into tData get binaryDecode(m3, tData, tSequence, tProto, tBytes) read from socket for 1 byte put it into tRemoteID read from socket for 1 byte put it into tFunctionCode switch tFunctionCode case kFunc1 put 2 into tWordCount break case kFunc3 case kFunc4 put 3 into tWordCount break case kFunc2 put 10 into tWordCount break case -- ok - you get the idea break end switch read from socket for (2*tWordCount) bytes put it into tData put binaryDecode(m3, tData, tData1, tData2, tData3, tData4, etc.) into tActual if tActual is not tWordCount then -- oops end if -- -Mark Wieder mwie...@ahsoftware.net ___ 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: Socket reading problem
On 2/19/2012 8:50 PM, Mark Wieder wrote: Len- Sunday, February 19, 2012, 5:25:32 PM, you wrote: LC doesn't know from uints. Your best bet is to read them as chars (or more precisely as bytes), as you're doing in your second example. I thought this was true until I looked it up in the dictionary. It states that those are valid chunkTypes. Has that changed from 4.5 to 5.0? To be honest, I don't remember seeing that there before today and it would have been handy. Also available: int, int2, int4, uInt, uInt2, uInt4 - at least according to the dictionary. Well whaddya know about that! I'm gonna have to rtfm one of these days. Grasping at straws here, you specified uInt2s rather than uint2 ... it's possible that the plural form doesn't work. If you look at the last example in the dictionary, it says ... 30 uInt2s so I'm guessing that the plural form is ok. However, doesn't seem to work either way. This would be very handy if I could make it work. len ___ 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: Does 'quit' have a place in iOS apps?
Yup, LC apps can't take advantage of background functioning...yet. Hopefully that will change in a future release. Gerry On 20/02/2012, at 12:12 PM, Ken Ray wrote: I assume is the case with LC apps. ___ 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: binaryDecode with variable number of parameters
On 2/19/2012 9:05 PM, Mark Wieder wrote: Len- Sunday, February 19, 2012, 5:23:11 PM, you wrote: Related to my problem with reading binary data from a socket, how do I handle a variable number of numbers that will come in with binaryDecode? To explain, I get a number in the packet header that tells me there are x number of bytes to follow in this packet. I know the first byte is a remote ID and the second is a function code. Based on the function code, the number of two byte integers that follows is going to be (the number of bytes in the message / 2) - 1 (for the function code and remote ID). One time there might be 2 integers to follow, another there might be 10. There is a number of words number that is part of the command so I know how many words there will be but the binaryDecode function requires that I specify a name for each variable that is going to get a value. Ideally, I'd like to put all of these words in an array so I can process them, but this doesn't seem to be an option for the binaryDecode command. Should I build up a string that has ...,var[0],var[1],...,var[x] in it to account for all the variables and then use a do or dispatch to actually do the binaryDecode? Also, if I use var[0], var[1], etc., do I need to create ALL of the indexes first (for binaryDecode) or will just creating the first one (var[0]) be sufficient? I think I'd do something like: read from socket for 1 bytes put it into tRemoteID read from socket for 1 bytes put it into tFunctionCode switch tFunctionCode case kFunc1 put 2 into tWordCount break case kFunc2 put 10 into tWordCount break case -- ok - you get the idea break end switch read from socket for (2*tWordCount) bytes put it into tData put binaryDecode(m3, tData, tSeq, tProto, tBytes) into tActual if tActual is not tWordCount then -- oops end if ...and yes, you do need to have the maximum number of variables already defined. There's no penalty for having extra compartments in the binaryDecode line, but you don't want to have too few. Thanks for the reply Mark but it's not quite the problem. The order that the data comes in is: tSequence, tProto, tBytes (all 16 bit), tRemoteID, tFunctionCode, x After the function code, if you are doing a write multiple registers for example, you will have a beginning register, and the count of registers, followed by the actual data you are trying to write. This is where things start to fall down for me because of this variable number of items and the requirement to have a predefined variable for each possible answer. I know when I get to the data portion exactly how many registers I'm going to have to read (and therefore how many variables I'm going to need). Based on your last paragraph though, it appears that I'll have to either have a separate case for each possible number of data words, or read them one at a time in a loop and assign them to a variable in the loop. Neither of those is the optimal way to go but one must do what one must do. :-) So by the time you get to tFunctionCode you know how many bytes will be coming in the stream, right? That's the x data? I still think something like this is the easiest and most maintainable way to go. How many functionCodes are you dealing with? local tData1, tData2, tData3, tData4, ... read from socket for 6 bytes put it into tData get binaryDecode(m3, tData, tSequence, tProto, tBytes) read from socket for 1 byte put it into tRemoteID read from socket for 1 byte put it into tFunctionCode switch tFunctionCode case kFunc1 put 2 into tWordCount break case kFunc3 case kFunc4 put 3 into tWordCount break case kFunc2 put 10 into tWordCount break case -- ok - you get the idea break end switch read from socket for (2*tWordCount) bytes put it into tData put binaryDecode(m3, tData, tData1, tData2, tData3, tData4, etc.) into tActual if tActual is not tWordCount then -- oops end if Mark, As it turns out, there are only two function codes I have to worry about (i.e., ones we actually use): FC 3 - Read multiple registers, and FC 16 - write multiple registers. FC3 is easy (on the way in) because it has a fixed length. The RESPONSE however will be variable depending on how many registers the Master controller wants to read. It can be up to 100 at a time but all of our commands read 80 registers so this could be almost hard coded. FC 16 on the other hand gives me the number of words to write and then that many words which I have to read, convert to ASCII and send out a serial port. The response is easy since it only tells me how many registers it actually wrote (which should be the same). So, I pay for it either coming or going depending on the command. I've managed to get it to work by getting the number of registers to write and then in a loop: create the next index value (tArray[i]) convert 1 word into tArray[i] delete
Re: How to use an array to solve the following...
I am an old HyperCarder, so I tend to attack things in an old fashioned way. I use arrays, but think that the decisions needed here may not use them to any great advantage. I am usually wrong. I tried this with a worst case list of 20,000 lines, that is, no adjacent lines in your sense, to maximize the length of the derived list. It works fine, but took three minutes to run. The resulting list was 60,000 lines long. Given a field yourField with lots of data in it, a field for the results, and a button, place this in the button script: on mouseup put fld 1 into temp repeat for each line tLine in temp put item 1 of tLine - 10 , 0 return before tLine put return item 1 of line 2 of tLine + 10 , 0 return after tLine put tLine after accum end repeat sort accum numeric by item 1 of each delete line 1 of accum delete the last line of accum repeat with y = the number of lines of accum down to 1 switch case item 1 of line y of accum = item 1 of line (y-1) of accum and item 2 of line y of accum = 0 delete line y of accum break case item 1 of line y of accum = item 1 of line (y-1) of accum and item 2 of line y-1 of accum = 0 delete line y-1 of accum break end switch end repeat put accum into fld 2 end mouseup Someone will find a better algorithm. Craig Newman ___ 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: binaryDecode with variable number of parameters
Len- Sunday, February 19, 2012, 8:09:11 PM, you wrote: As it turns out, there are only two function codes I have to worry about (i.e., ones we actually use): FC 3 - Read multiple registers, and FC 16 - write multiple registers. FC3 is easy (on the way in) because it has a fixed length. The RESPONSE however will be variable depending on how many registers the Master controller wants to read. It can be up to 100 at a time but all of our commands read 80 registers so this could be almost hard coded. Ah! I misinterpreted your original post then. I thought each function code had a fixed number of registers in the response. Now I see what you're up against. -- -Mark Wieder mwie...@ahsoftware.net ___ 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 use an array to solve the following...
Kay's is much faster than mine. Well done. Craig Newman -Original Message- From: Glen Bojsza gboj...@gmail.com To: How to use LiveCode use-livecode@lists.runrev.com Sent: Sun, Feb 19, 2012 9:49 pm Subject: Re: How to use an array to solve the following... Hi Kay, This looks very good mainly the use of case with the decision being the switch... never thought about that. Also, I didn't realize that arrays would be slower... I will test this with some of the data sets ... currently up to 80,000 lines but with values I have indicated... but I like the simplicity. I posted the bigger picture but it got jammed due to size so I just pasted the new info here... The biggest picture would be having 10 lists with each list having the xs column but a different ?t column (wt, gt, st, mt, qt, ... etc) The first and last xs value for each list will always be the same and can start at 10 and go to 100,000+ but other than that there will be randomness in the step increments. The goal would be the same but towards building a master list where each associated column would meet the neighbor criteria with the xs column. You can see the xs column increments grow and the already established column values (in this case wt) get a value of 0 for the new xs increments. Given this and the possible number of columns and values is there still a good approach in using arrays? For example... we see from Pacer List xs wt 10 6 80 7 13023 we got Master list xs wt 10 6 20 0 this is added 70 0 this is added 80 7 90 0 this is added 1200 this is added 13023 Train List xs gt 10 32 40 67 130 55 new master list would be xs wtgt 10 632 20 0 0 30 0 0 -- added to xs updated wt value 40 0 67 -- added to xs updated wt value 50 0 0 -- added to xs updated wt value 70 0 0 80 7 0 90 0 0 1200 0 1302355 ___ 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 use an array to solve the following...
On Mon, Feb 20, 2012 at 10:47 AM, Glen Bojsza gboj...@gmail.com wrote: The biggest picture would be having 10 lists with each list having the xs column but a different ?t column (wt, gt, st, mt, qt, ... etc) If you are going to many more columns, then an array might be faster, and if speed is the ultimate goal, then you would have to benchmark it to compare, just to be sure. For the repeat for each line approach, you basically have to process each list, create the master list by combining and sorting, then do one final run through the master list whilst confirming there are no repeat values (left column number). Fortunately, because you are using 0, it would be simply a matter of adding all the items of each repeated line together to form a single line with all the correct values. With arrays, time could be saved by not dealing with all the 0 values. ie if you only create array elements for those that exist. If you later test for an element, and it doesn't exist, the result is empty, which is equivalent to 0. The following is not verified so you would have to check the results for accuracy. I've left a breakpoint at the end so you can inspect both tStore which contains all the dummy data, and the final array aData. This should give you a rough idea of how to proceed. I used 76923 repeats of 13 lists so I got a total of 99 cycles so I could roughly compare to the other script. I got 5246ms but it must be appreciated, this is doing a lot more than the previous script, even so, it's pretty quick for a million cycles. HTH on mouseUp --create some dummy data put at,bt,ct,dt,et,ft,gt,ht,it,jt,kt,lt,mt into tHeader put 76923 into tRepeat repeat for each item tItem in tHeader put tItem cr 10 tab 5 cr after tStore put 10 into tLast repeat tRepeat times put (10 * random(4) + tLast) into tLast put tLast tab random(30) cr after tStore end repeat end repeat --work done here set the itemDelimiter to tab put the millisec into tStartTime repeat for each line tLine in tStore put item 1 of tLine into tCheck switch case (tCheck is not an integer) put tCheck into tElement --because of the way I created the list put 0 into tLastItem break case (tCheck - tLastItem 20) put 0 into aData[(tLastItem + 10)][tElement] put 0 into aData[(tCheck - 10)][tElement] put item 2 of tLine into aData[tCheck][tElement] put tCheck into tLastItem break case (tCheck - tLastItem 10) put 0 into aData[(tCheck - 10)][tElement] put item 2 of tLine into aData[tCheck][tElement] put tCheck into tLastItem break case (tCheck - tLastItem = 10) put item 2 of tLine into aData[tCheck][tElement] put tCheck into tLastItem break end switch end repeat put the millisec into tEndTime put (tEndTime - tStartTime) msfor (13 * tRepeat) \ cycles. cr into msg put tStore: cr after msg put tStore after msg put cr cr after msg breakpoint end mouseUp ___ 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 use an array to solve the following...
On Feb 19, 2012, at 8:47 PM, Kay C Lan lan.kc.macm...@gmail.com wrote: I'm sure others will now improve on that. I doubt it. You're using repeat for each in a sensible way, and there's rarely something faster than that. If you really wanted to tighten up the repeat, you could do something like this, but I doubt that it would be much faster: put item 1 of tStore into tLastItem repeat for each line tLine in tStore put item 1 of tLine into tCheck put tCheck - tLastItem into x switch case (x 20) put tLastItem + 10 tab 0 cr after tStore2 case (x 10) put tCheck - 10 tab 0 cr after tStore2 end switch put tLine cr after tStore2 put tCheck into tLastItem end repeat ___ 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: [OT] HyperCard and the Interactive Web
On Mon, Feb 20, 2012 at 1:12 AM, Richmond richmondmathew...@gmail.comwrote: I wouldn't worry about that. In our flat one cannot see the living-room walls (in some places 3 books deep). You've seen the TV series Hoarders I presume ___ 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: use-livecode Digest, Vol 101, Issue 43
Thanks for that mark. Yes, I had know the site. And you know there's gonna be a Yes, But. If you happen to look at the last modified date you will see that was 6/26/2007. So it would seem to me that nothing has been done to this handy little tool in over 4 years. I fired off an e-mail to the site and got the cold shoulder. That's the reason for my original question The problem I'm having with the tool is in plug-in mode when I load it into the development environment of LC 5.0.2. It crashes on a handler, or function that it doesn't seem to be able to find. . ___ 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