Meeting Sept 1 2016

Discussion forum for the Southern California LiveCode Developer Group

Moderators: Klaus, FourthWorld, robinmiller

chipsm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 199
Joined: Wed May 11, 2011 7:50 pm
Location: Southern California

Meeting Sept 1 2016

Post by chipsm » Tue Aug 16, 2016 11:56 pm

I know that this was discussed at the August meeting, so I will attend the Sept. meeting.
Richard, I'll have several things to ask about and will present the "Mostly Finished" project that I presented last meeting.
I would also like Paul to have a heads up on His Book - I'll be looking forward to more information about his Text Based Database ( I have read your book and find it very intriguing).
I do have a request to you, Richard - please give us a demo of an application where you do a client - Server simulation without a server using Stacks.
Clarence Martin

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5939
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Meeting Sept 1 2016

Post by FourthWorld » Wed Aug 17, 2016 8:30 pm

Where
Du-par's, back room
214 S. Lake Avenue
Pasadena CA 91101
http://www.du-pars.com/dupars_locations.html

When
Thursday, Sep 1, 7:00PM

Who
The meetings are open to any and all who have an interest in chatting about LiveCode.

What
We can have a brief intro to LiveCode if we get enough newcomers RSVP'd through Meetup. We should also have plenty of time for general Q&A and problem-solving. Any of our regulars bringing a project to share?

Please RSV
We're now on Meetup.com, as part of the SGV Tech group:
https://www.meetup.com/SGVTech/events/230904996/
Our meeting room has limited seating, so please RSVP there to reserve a seat.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5939
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Meeting Sept 1 2016

Post by FourthWorld » Wed Aug 17, 2016 8:34 pm

chipsm wrote:I do have a request to you, Richard - please give us a demo of an application where you do a client - Server simulation without a server using Stacks.
Be careful what you wish for. :)

I always bring four or five projects to share when time permits, that's one of them. But we always have so much going on we never get to them.

The challenge with my "server emulator" is that it requires using a standalone for CGIs rather than LC Server. If you're delivering HTML pages to a browser the conveniences provided for that with LC Server are pretty great. But if you're delivering data to clients also made in LC, then a standalone can be a good option, and with it an emulator can boost productivity.

Happy to talk more about that at the meeting. Just remind me when we get there.

See ya' then -
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

bvlahos
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 60
Joined: Tue May 01, 2012 1:52 am

Re: Meeting Sept 1 2016

Post by bvlahos » Wed Aug 31, 2016 1:33 am

I'm looking forward to seeing you at the meeting.

jiml
Posts: 150
Joined: Sat Dec 09, 2006 1:27 am
Location: Los Angeles

Re: Meeting Sept 1 2016

Post by jiml » Wed Aug 31, 2016 9:08 pm

Can't make it this month.

JimL

chipsm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 199
Joined: Wed May 11, 2011 7:50 pm
Location: Southern California

Re: Meeting Sept 1 2016

Post by chipsm » Fri Sep 02, 2016 2:49 pm

Thanks all, for your participation in viewing my LiveCode application.
We spent quite a bit of time doing code optimization and I am supplying a copy of the application for you to review and use any way you amy want.
Please note there are some things to know about the application:
1. the basis of this app is build a viewable Matrix of the Past Cal. lottery Fantasy Five pick so that you can analyze the numbers that were drawn. You can download these picks on a daily basis frorm this link: http://www.calottery.com/play/draw-game ... ng-numbers. You can actually include the following link in the code to do this automatically: http://www.calottery.com/sitecore/conte ... &Order=Yes
2. it is not complete. There are 3 stacks and only one has some true functions, and that is the Fantasy Five Stack.
3. there are a couple of buttons to take note of: You must first import the "Past Games" . then you can "Load the Matrix" There are 2 Load Matrix buttons and the Load Matrix2 Button has the optimized code.
4. As Richard explained in the Meetup, naming things :fields and variables, can be a daunting task for all coders. I think that as things start out we use names that just pop into our minds. Certainly the solution to this is to go back and rename these things, which I plan to do or to take the time out in the beginning to think these things out (that makes things go a little slow for me).
Please enjoy and change things to your hearts desire and bring back any changes that you come up with and share them at an upcoming meeting.

Thanks!
Attachments
Optimized lotto parser.zip
(6.3 KiB) Downloaded 99 times
Clarence Martin

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5939
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Meeting Sept 1 2016

Post by FourthWorld » Tue Sep 06, 2016 3:50 pm

Clarence, I took the liberty of making an experimental version of your "Load Matrix 2" script that turned out to be worthwhile: rather than loading tMatrix by item, which requires counting items, it now makes a fixed-length template line, copying it for each line in tNums and and filling it in using byte offsets instead of item counts.

The nice thing about bytes is that it's something the computer inherently knows; everything else (items, words, lines, etc.) has to be figured out on the fly by examining each character and keeping count as it goes.

In order to test it I need to bypas the "ask" dialog, so this test script uses a fixed value instead of one entered by the user. I chose a high number to make the results more easily measurable. On smaller sets (say, 500 lines) the new script is about twice as fast. But the benefit grows larger with the number of input lines: at 5000 lines the new script runs about four times faster.

To run the old repeat loop hold down the Shift key when clicking; to run the new just click without the Shift key.

Also, I remembered why my original attempt to combine the totals in tA wasn't working: associative arrays are hash-based and as such have no inherent sense of order. The result I was getting back was indeed correct, but not in a reliably-usable order. The loop we're using now seems reasonably efficient, though I suspect if Dick Kreisel discovers this thread he'll boost overall performance by at least another two-fold. :)

Code: Select all

on mouseUp
   -- Capture start time:
   put the millisecs into t
   --
   put empty into field "tNums"
   put empty into field "tRCount"
   put empty into field "totNumsFtr"
   -- Bypass ask to use fixed value for timing:
   # ask "how Many Games do you want to Analyze" 
   get 5000
   put it into tGames2Analyze
   -- Load Matrix
   set itemdel to tab
   set the cursor to watch
   put field "nums" into vNums
   put 1 into tCounter
   -- Orig method:
   if the shiftKey is "down" then
      repeat for each line tRow in  vNums
         repeat with  tPicks = 6 to 10
            put word tPicks of tRow into tColumn
            put  "X" into item tColumn of line TCounter of tMatrix         
         end repeat 
         put cr after tMatrix
         add 1 to tCounter
         if tCounter >tGames2Analyze then   
            exit repeat
         end if
      end repeat
   else
      -- New method using a template line which is filled in
      -- each time through the loop to avoid item counts:
      --
      -- Load template line:
      put empty into tTemplateLine
      repeat 39
         put space & tab after tTemplateLine
      end repeat
      -- Use a copy for each line, filling in appropriate columns
      -- as it goes:
      repeat for each line tRow in vNums
         put tTemplateLine into tThisLine
         repeat with  tPicks = 6 to 10
            put word tPicks of tRow into tColumn
            put "X" into byte (tColumn *2)-1 of tThisLine         
         end repeat
         put tThisLine & cr after tMatrix
         add 1 to tCounter
         if tCounter >tGames2Analyze then   
            exit repeat
         end if
      end repeat
   end if
   --
   put tMatrix into field "tNums"
   --
   repeat for each line tLine in tMatrix
      put 0 into i
      repeat for each item tItem in tLine
         add 1 to i
         if tItem is "X" then 
            add 1 to tA[i]
         else add 0 to tA[i]
      end repeat
   end repeat
   repeat with i = 1 to 39
      put tA[i] &tab after tVals
   end repeat
   put tVals into fld "totNumsFtr"
   --
   -- Display elapsed time:
   put the millisecs - t
end mouseUp
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

chipsm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 199
Joined: Wed May 11, 2011 7:50 pm
Location: Southern California

Re: Meeting Sept 1 2016

Post by chipsm » Tue Sep 06, 2016 7:02 pm

I have to try this out. Maybe a little later today.
I have a few errands to run this morning but I will get to it this afternoon.
So, I should load this code into the On shiftMouseUp for the Load Martix2 button?
And, Thanks
I always like learning new code for doing things.
Clarence Martin

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5939
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Meeting Sept 1 2016

Post by FourthWorld » Tue Sep 06, 2016 7:06 pm

chipsm wrote:So, I should load this code into the On shiftMouseUp for the Load Martix2 button?
Yep. Or play it safe and make a new "Load Matrix 3" button.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

chipsm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 199
Joined: Wed May 11, 2011 7:50 pm
Location: Southern California

Re: Meeting Sept 1 2016

Post by chipsm » Tue Sep 06, 2016 7:14 pm

Yes, a new button is the key. For some reason, I wasn't able to do a "on shiftMouseUp". The code responds to the "on mouseUp" first.
I think it's because of the messe path - I'm not sure.
I'll keep you posted.
Clarence Martin

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5939
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Meeting Sept 1 2016

Post by FourthWorld » Tue Sep 06, 2016 7:18 pm

chipsm wrote:Yes, a new button is the key. For some reason, I wasn't able to do a "on shiftMouseUp". The code responds to the "on mouseUp" first.
I think it's because of the messe path - I'm not sure.
I'll keep you posted.
There is no "shiftMouseUp" message. In LC you can query the state of a modifier key from within a mouse event handler. But I've already written that into the code above. All you need to do is copy it into a button and click it to run the new loop, or click it while holding the Shift key down to run the old loop.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

chipsm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 199
Joined: Wed May 11, 2011 7:50 pm
Location: Southern California

Re: Meeting Sept 1 2016

Post by chipsm » Tue Sep 06, 2016 7:31 pm

OK, I am blind. For some reason I did not see the the shiftKey part of the code. Thanks.
Clarence Martin

chipsm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 199
Joined: Wed May 11, 2011 7:50 pm
Location: Southern California

Re: Meeting Sept 1 2016

Post by chipsm » Wed Sep 07, 2016 12:51 am

Richard,
Outstanding results:
Old Method: 5000 games took 409726 ms
New Method: 5000 Games took 1314 ms

that's less than 5ms per game
Outstanding results!

Oops! Wrong Math. .263 ms per game!
Clarence Martin

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5939
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Meeting Sept 1 2016

Post by FourthWorld » Wed Sep 07, 2016 1:23 am

Glad that was useful, Clarence.

Now if only we can get Dick Kreisel to drop in, he'll probably cut that time in half. :)
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

chipsm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 199
Joined: Wed May 11, 2011 7:50 pm
Location: Southern California

Re: Meeting Sept 1 2016

Post by chipsm » Wed Sep 07, 2016 12:52 pm

Ok, Richard and fellow SoCal LiveCode Group members.
I want to thank Richard for enhancing the optimization of the lotto parser application and I have included a zipped file with a sample past lotto imported text file.
You can get newer files by following the link provided ( http://www.calottery.com/play/draw-game ... ng-numbers )
Again, use it as you need and think about how this application can be used for other applications for analysis applications.
Attachments
Lotto Parser.zip
(231.12 KiB) Downloaded 92 times
Clarence Martin

Post Reply

Return to “SoCal LiveCode Group”