realbasic-nug
[Top] [All Lists]

Re: Store colors in an array

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Store colors in an array
From: Gary Edge <rb at panamind dot com>
Date: Tue, 28 Feb 2006 15:16:05 -0500
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <31F233E8-AF2B-4E05-ACF6-4513DCFEAB81 at panamind dot com> <a06200700c02a534fd55d at [10 dot 71 dot 2 dot 34]>

On Feb 28, 2006, at 2:23 PM, Joseph J. Strout wrote:

OK.  So you've created a local array, and stuffed colors into it.

Then in another method write:

Wait a second -- what you created above was a LOCAL array. It doesn't exist in any other method.

for i = 0 to ubound(colors)
    g.forecolor = colors(i)  // crashes here

What sort of crash, exactly? Frankly I'm surprised it compiles at all -- you must have some other identifier called "colors" that's not the same as what you showed above.

You certainly CAN store colors in an array, but of course if you want it to be used in more than one method, then you want to use a property, not a local variable.


Sorry for not clarifying. The array is returned from the function which creates it to a method that defines the local variable colors().

For example:

dim colors(-1) as color
colors = getColorArray()
for i = 0 to ubound(colors)
g.forecolor = colors(i) // crashes here with debugger quitting back to the IDE
        g.drawline ...
next

Where getColorArray is:


dim c(-1) as color

c.append &c75A2DD
etc...

return c



Gary

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>