Thanks for trying to help, but...
Quote:
Original post by Anonymous Poster
Quote:
Original post by RolandofGilead
...I cannot do this for some strange reason.
There are two things wrong with your first block of code
Could you elaborate on the second?
Quote:
First, the idiom var = { ... } is a table constructor. It's what you use, simply, to create a table. But you're table constructor reads environment[1] = { ... }. So you're trying to ACCESS the value in table "environment" with key 1, the problem being that an "enviroment" table hasn't been created yet! Error.
Sorry, I should have said I was getting syntax errors and not run-time errors. I thought it was covered because in all the examples, environment is accessed the same and in some of them it runs, as I said, implying that environment[1] wasn't causing the problem.
I also could have explained it better if the title were allowed to be longer. I'm parsing a file and generating the code. I want to make each instance of a variable, no matter which one, a member in a numerically indexed master list of all the other variables like it, but I also want each table to have a member with the appropriate name. You see, I was trying to make a member of a table be also the member of another table, which you cannot apparently do. I can assign the member of a table to the value found somewhere else, but I cannot make accessing one, fully equal to accessing the other.
Oh, my goodness, I just thought of a way to do it, but it's not that great. I could generate the code to assign the next in the array the appropriate value, and in the other, when it's accessed as a named member of a table, I simply make the named member equal to the index it takes up in the master list. That would require retrieving the name of the variable as a string, which I'm not sure how to do, but if nothing else, instead of equalling an index I can make it a table with the index and a string which is its name.