SEt_LENGTH_ARRAY not working
javedwahid
Posts: 37
Hi,
I have the following and it doesn't seem to be working. I've been debugging it and it seems that the SET_LENGTH_ARRAY doesn't seem to get set
STRUCTURE _Person
{
CHAR FirstName[20]
CHAR LastName[20]
}
NON_VOLATILE CHAR FirstName[20]
NON_VOLATILE CHAR LastName[20]
_Person People
In a button push event I have the following
PUSH:
{
WHILE (x < 5)
{
FirstName = REMOVE_STRING(Name, ' ')
LastName = Name
FirstName = LEFT_STRING(FirstName, LENGTH_ARRAY(Name) - 1)
People[MAX_LENGTH_ARRAY(People)].FirstName = FirstName
People[MAX_LENGTH_ARRAY(People)].LastName = LastName
SET_LENGTH_ARRAY(People, MAX_LENGTH_ARRAY(People) + 1)
x = x + 1
}
}
This loops 5 times, but my People structure at the end only contains 1 name, the last name. I want it to store all names that it receives. Some code regarding where the name is coming from is not included for simplicity sake.
It looks like the SET_LENGTH_ARRAY function doesn't expand the array. Am I doing something wrong here?
Thanks,
Javed
I have the following and it doesn't seem to be working. I've been debugging it and it seems that the SET_LENGTH_ARRAY doesn't seem to get set
STRUCTURE _Person
{
CHAR FirstName[20]
CHAR LastName[20]
}
NON_VOLATILE CHAR FirstName[20]
NON_VOLATILE CHAR LastName[20]
_Person People
In a button push event I have the following
PUSH:
{
WHILE (x < 5)
{
FirstName = REMOVE_STRING(Name, ' ')
LastName = Name
FirstName = LEFT_STRING(FirstName, LENGTH_ARRAY(Name) - 1)
People[MAX_LENGTH_ARRAY(People)].FirstName = FirstName
People[MAX_LENGTH_ARRAY(People)].LastName = LastName
SET_LENGTH_ARRAY(People, MAX_LENGTH_ARRAY(People) + 1)
x = x + 1
}
}
This loops 5 times, but my People structure at the end only contains 1 name, the last name. I want it to store all names that it receives. Some code regarding where the name is coming from is not included for simplicity sake.
It looks like the SET_LENGTH_ARRAY function doesn't expand the array. Am I doing something wrong here?
Thanks,
Javed
0
Comments