Jump to content

Recommended Posts

Posted (edited)
Hello guys, I've got a problem that is driving me crazy and I'm prety sure the solution is simple :s So, ive got some strucutres and I'm parsing values from one to the other (same strucutre scheme) in ST language. But if I put all the code in a FOR cicle it give me the error 'Invalid array index'. If instead of an index i put a real value, i've got no error. Can somebody help me with this? what I'm I doeing wrong? -----CODE------ ----DATA TYPES---- ----SYMBOLS----- Regards Edited by FET_Destroyer

Posted
Yes, if you use constant instead of symbol index, it will work. If you search cx-programmer help for struct key word you'll get a topic named Structure Symbols, and there you will find the following: Subscripts of Array Data Structures The subscripts must be constants. Symbols, addresses, and formulas cannot be used. I think this is referring to your problem. regards
Posted (edited)
Well, Gama_Temporary and Gama_Memory are identical structures. you need only one structure of a kind and then create variables memory and temporary that are types of that structure of yours. then try to simply assign one variable to another, e.g. temporary := memory; I didn't test, I can only see that no error is reported on compiling. the question is if all the data from the structure variable memory is transferred to a temporary structure variable. you should test this. Edited by tashinz
Posted (edited)
It works in simulator. And as I can see, now you can use FOR to address a structure variable array, not a member of a structure variable (now you don't need to parse all members to assign values). I've created a simple program (not a FB) in ST: FOR index := 0 TO 4 DO temp_1 := test_1[index]; END_FOR; where temp_1 and test_1 are structure variables. in this example, temp_1 members get values from members of test_1[4], (it works in simulator). regards Edited by tashinz

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...