Ah, that's one of my favorite tricks. The documentation for GetMapLayers() says it returns 3 array elements.  You can use
 
    {layers, current_idx, current_name} = GetMapLayers(, "Point")
 
instead of doing
 
    x = GetMapLayers(, "Point")
    layers = x[1]
    current_idx = x[2]
    current_name = x[3]
 
As you see in comparison, the first example is a nice shorthand.  It's also fairly flexible and forgiving, you don't have to match up the number of array elements quite correctly (as I did in the code you highlighted).  Also, were GetMapLayers() to return null, the second "equivalent" example would fail, because you can't do
 
    layers = x[1]
 
if x is null.  In the first example, all the elements would be set to null if GetMapLayers() were to return null.
 
-Kjartan
 
 


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Chandler Coleman
Sent: Thursday, June 01, 2006 11:42 AM
To: [email protected]
Subject: RE: [Maptitude] taking elements out of an array

Thanks.  This work exactly how I needed it to do.  Question, in your example you use:

{a, } = GetMapLayers(, "Point")
{b, } = GetMapLayers(, "Active")

Setting a & b in {} with a coma after it…

What does this do?  How is this different then the following

a = GetMapLayers(, "Point")
b = GetMapLayers(, "Active")

 

Thanks for the help.

 

 

Chandler Coleman

Research & Market Analysis

Albertsons, Inc.

(208) 395-4650

 


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Kjartan Stefansson
Sent: Thursday, June 01, 2006 6:58 AM
To: [email protected]
Subject: Re: [Maptitude] taking elements out of an array

 

Chandler,

 

You can loop over one array and remove from it any elements that don't occur in the other one.

 

{a, } = GetMapLayers(, "Point")
{b, } = GetMapLayers(, "Active")
for i = a.length to 1 step -1 do
    if ArrayPosition(b, {a[i]}, ) = 0 then

        // a[i] is not in b so remove it
        a = ExcludeArrayElements(a, i, 1)
end

ShowArray(a)

-Kjartan

 


From: Chandler Coleman [mailto:[EMAIL PROTECTED]]
To: [email protected]
Sent: Wed, 31 May 2006 18:48:26 -0400
Subject: [Maptitude] taking elements out of an array

I have used two functions:
GetMapLayers(, "Point")
GetMapLayers(, "Active")

I now have an array with 43 elements and another with 6. I want to now
compare the two and include only the layers that are in both. However,
I have tried the ExcludeArrayElements() and the InsertArrayElements()
with zero success.

What functions do I use to get a new array with what both these arrays
have in common?
Thanks
Chandler






------------------------ Yahoo! Groups Sponsor --------------------~-->
Everything you need is one click away.  Make Yahoo! your home page now.
http://us.click.yahoo.com/AHchtC/4FxNAA/yQLSAA/C5grlB/TM
--------------------------------------------------------------------~->


Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Maptitude/

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/




 

 

 



SPONSORED LINKS
Geographic information systems Geography game Geography


YAHOO! GROUPS LINKS




Reply via email to