Re: Help with Arrays

2013-10-14 Thread Mark Wieder
Andrew-

Monday, October 14, 2013, 5:45:15 PM, you wrote:

> I wish we had a mongodb native driver with aggregate queries availiable.
> ::drools::

In my spare time *someday*... yeah, the commandline-driven interface
still leaves something to be desired.

-- 
-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: Help with Arrays

2013-10-14 Thread Andrew Kluthe
I wish we had a mongodb native driver with aggregate queries availiable.
::drools::


On Mon, Oct 14, 2013 at 7:25 PM, Mark Wieder  wrote:

> Bill Vlahos  writes:
>
> > How would I do this using an array?
>
> Well, Phil beat me to it, but I was going to suggest much the same thing.
> That repeat loop is what does the trick.
>
> Of course, the real-world answer probably depends on where the list of
> names
> is coming from... if it's in a mongodb database, just issue an aggregate
> command and get your results much faster with a one-liner than anything you
> could think of doing in a script.
>
> --
>  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
>



-- 
Regards,

Andrew Kluthe
and...@ctech.me
___
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: Help with Arrays

2013-10-14 Thread Mark Wieder
Bill Vlahos  writes:

> How would I do this using an array?

Well, Phil beat me to it, but I was going to suggest much the same thing.
That repeat loop is what does the trick.

Of course, the real-world answer probably depends on where the list of names
is coming from... if it's in a mongodb database, just issue an aggregate
command and get your results much faster with a one-liner than anything you
could think of doing in a script.

-- 
 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: Help with Arrays

2013-10-14 Thread Phil Davis

Oops. See below.

On 10/14/13 2:16 PM, Phil Davis wrote:

Hi Bill,

Here is a clunky and simplistic way that works:

on mouseUp
-- get the number of occurrences for each name
put myList() into tList
repeat for each line tLine in tList
add 1 to tCountsByName[tLine]
end repeat

-- reformat the 'counts' data
combine tCountsByName with CR and "="
sort lines of tCountsByName word 1 to -2 of each -- the minor sort

should be:
sort lines of tCountsByName by word 1 to -2 of each -- the 
minor sort


sort lines of tCountsByName numeric descending by last word of each -- 
the major sort

replace "=" " (" in tCountsByName
replace CR with ")" & CR in tCountsByName
put ")" after tCountsByName

-- you're done!
answer tCountsByName
end mouseUp


function myList
get "Bill,Mary,Bill,John,Jim,Jane,Bill,Jim,Jane"
replace comma with CR in it
return it
end myList


HTH -
Phil Davis


On 10/14/13 1:52 PM, Bill Vlahos wrote:
I have a list of names many of which repeat and I want to get a count 
of how many times each name appears in the list and sort it.


This seems like a perfect example of using an array but I'm 
struggling to figure it out.


Sample list:
Bill
Mary
Bill
John
Jim
Jane
Bill
Jim
Jane

The popularity result should look like this:
Bill (3)
Jane (2)
Jim (2)
John (1)
Mary (1)

How would I do this using an array?

Thanks,
Bill Vlahos
___
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





--
Phil Davis


___
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: Help with Arrays

2013-10-14 Thread Phil Davis

Hi Bill,

Here is a clunky and simplistic way that works:

on mouseUp
-- get the number of occurrences for each name
put myList() into tList
repeat for each line tLine in tList
add 1 to tCountsByName[tLine]
end repeat

-- reformat the 'counts' data
combine tCountsByName with CR and "="
sort lines of tCountsByName word 1 to -2 of each -- the minor sort
sort lines of tCountsByName numeric descending by last word of each 
-- the major sort

replace "=" " (" in tCountsByName
replace CR with ")" & CR in tCountsByName
put ")" after tCountsByName

-- you're done!
answer tCountsByName
end mouseUp


function myList
get "Bill,Mary,Bill,John,Jim,Jane,Bill,Jim,Jane"
replace comma with CR in it
return it
end myList


HTH -
Phil Davis


On 10/14/13 1:52 PM, Bill Vlahos wrote:

I have a list of names many of which repeat and I want to get a count of how 
many times each name appears in the list and sort it.

This seems like a perfect example of using an array but I'm struggling to 
figure it out.

Sample list:
Bill
Mary
Bill
John
Jim
Jane
Bill
Jim
Jane

The popularity result should look like this:
Bill (3)
Jane (2)
Jim (2)
John (1)
Mary (1)

How would I do this using an array?

Thanks,
Bill Vlahos
___
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



--
Phil Davis


___
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


Help with Arrays

2013-10-14 Thread Bill Vlahos
I have a list of names many of which repeat and I want to get a count of how 
many times each name appears in the list and sort it.

This seems like a perfect example of using an array but I'm struggling to 
figure it out.

Sample list:
Bill
Mary
Bill
John
Jim
Jane
Bill
Jim
Jane

The popularity result should look like this:
Bill (3)
Jane (2)
Jim (2)
John (1)
Mary (1)

How would I do this using an array?

Thanks,
Bill Vlahos
___
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: groove blox - started already. Need help with arrays and snap to

2011-08-11 Thread Bob Sneidar
Arrays are easy. To create one, simply put something into the first element: 
put "~/Music/GrooveBox/groovyarp.wav" into arps["track1"]. If instead, you want 
a multidimensional array containing all your categories: put 
"~/Music/GrooveBox/groovyarp.wav" into aTracks[arps]["track1"]. 

If you need multiple elements for each track:
put "Groovy Arp" into aTracks[arps]["track1"]["name"]
put "~/Music/GrooveBox/groovyarp.wav" into aTracks[arps]["track1"]["path"]
put "Groovy Rythm" into aTracks[drums]["track1"]["name"]
put "~/Music/GrooveBox/groovyrythm.wav" into aTracks[drums]["track1"]["path"]

If the tracks are the top level key:
put "Groovy Rythm" into aTracks["track1"]["name"]
put "Drums" into aTracks["track1"]["type"]
put "~/Music/GrooveBox/groovyrythm.wav" into aTracks["track1"]["path"]
put "Groovy Arp" into aTracks["track2"]["name"]
put "Arps" into aTracks["track2"]["type"]
put "~/Music/GrooveBox/groovyarp.wav" into aTracks["track2"]["path"]

A few caveats: It does not follow that the order of the keys will be the order 
you created them. I do not know why this is. For this reason, you could not put 
the keys of aTracks and expect them to be in the order "track1,track2,track3, 
...". Refer to them by name. Secondly, you cannot test to see if atracks is 
empty, because an array will return true. I do not know why this is. To see if 
an array variable is empty, use: atracks is an array. 

If you have Trevor Devore's excellent and highly recommended sqlYoga, you can 
use his printkeys() function to turn an array into text that can be searched or 
filtered. Using the above example it would look like this:
track1
 name: Groovy Rythm
 type: Drums
 path: ~/Music/GrooveBox/groovyrythm.wav
track2
 name: Groovy Arp
 type: Arps
 path: ~/Music/GrooveBox/groovyarp.wav

Now you can use the filter command to get all the paths: 
   filter thetracks with "*path:*"

which produces: 
 path: ~/Music/GrooveBox/groovyrythm.wav
 path: ~/Music/GrooveBox/groovyarp.wav

Now delete the headers using: 
   replace " path: " with empty in thetracks

Which magically and without fuss produces a list of file paths to your tracks:
~/Music/GrooveBox/groovyrythm.wav
~/Music/GrooveBox/groovyarp.wav

Very handy with large arrays! Don't have to create repeat loops! (Trevor did 
that for you). :-)

Bob


On Aug 10, 2011, at 3:44 PM, Admin wrote:

> 
> 
> Dear All, 
> 
> I already got drag and drop sort of working - can drag
> a wave file to a rectangle and it retains the name of the file - so now
> I can play that file once it is dragged to the track view. 
> 
> I am not
> sure how to make an array - and I assume an array is what I need to keep
> track of multiple blocks (there are 4 categories of blocks - drum, arp,
> bass and fxfill) 
> 
> Also, how would I implement a 'snap to' interface?
> 
> 
> Mike 
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


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


Re: groove blox - started already. Need help with arrays and snap to

2011-08-10 Thread Admin
  

Dear All, 

I already got drag and drop sort of working - can drag
a wave file to a rectangle and it retains the name of the file - so now
I can play that file once it is dragged to the track view. 

I am not
sure how to make an array - and I assume an array is what I need to keep
track of multiple blocks (there are 4 categories of blocks - drum, arp,
bass and fxfill) 

Also, how would I implement a 'snap to' interface?


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