Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Objects cannot be assigned to arrays

Status
Not open for further replies.

tkee

Programmer
Feb 6, 2004
55
US
I need to create an array to fill in information on a calendar for a printout. I create the array, then populate it. It works fine in a .prg file. I put the same code in LOAD or INIT of my form and the code itself runs fine, but when finishing I get the "Objects cannot be assigned to arrays" message. The only object on my form so far is an exit button to release the form. If I add code after populating the array it runs fine until it finishes the LOAD or INIT method - then the error. I also tried making a method and running it from there with the same results. I made the array a form property with the same result. I made the array public. Any help on the error message I can find simply repeats the error message. What am I missing?
 
In general, objects can be assigned to arrays. For example, if loObj is an object, VFP will happily let you do this:
Code:
laArray(1) = loObj

As far as I know, the only time you see the "Objects cannot be assigned to arrays" message is if you try to do this:
Code:
laArray = loObj

But why would you do that?

You'll probably need to show us your code so that we can understand what you are doing and what you are trying to achieve.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
The code is very simple:

Code:
do form getdate to mdate
PUBLIC ARRAY citecal(42,3)
STORE '' TO citecal
* code to populate array from queries using mdate info in a do while loop 
* result similar to citecal(1,1) = 1 ...

I don't assign anything to objects. The code runs fine, but throws the error upon completion. I have tried it in LOAD, INIT and in a method.
 
Thanks very much for your attempted help. I am completely lost as to what happened. I tried a cursor instead of an array and had the same error each time as the LOAD procedure finished. I gave up and started on a completely new form with a new name, and the code I copied and pasted from the old form worked fine. It's frustrating when you spend half a day on a very simple form with something so well hidden. I'd really like to know what it was to prevent future problems. I only added one button and only had the one portion of code and didn't change anything else. I wonder whether it might be related to my coworker's occasional upside down captions. That is a puzzler, too.
 
How about running a form, before you modify it, to see if you start from something working and there is no error you inherit and that has nothing to do with what you add?
Like Mike I sill don't see any code assigning anything to any array element, that could cause that error, so it MUST be part of code you didn't add.

Bye, Olaf.
 
I'm glad to hear you've got it working. But I have to say that your description of the problem did nothing to help. If you had just posted the code that caused the error, it might have been easy to see what was going wrong. As it is, I'm totally confused.

Never mind. Don't let me discourage you from coming back next time you have problem.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Upside down capions? Spurious error messages? Something in your environment is definitely messing with you!

Like the others, I see nothing in the code you posted that would beget the error you cite. That means it's coming from elsewhere in your form, and that is further born out by the fact that the problem went away when you moved to a new form.

What could it be? Nobody knows. There isn't enough diagnostic information here for anyone to guess.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top