Disclaimer: My FoxPro 2.5 skills are weak at best, it's been over 2 years since I last worked with this language. And the last time was the first time I ever programmed in FoxPro. I'm a c# dev most of the time. on to the problem...
I have a de-normalized table. where there are a series of columns for each day of the week. example:
[tt]amo | bmo | cmo | atu | btu | ctu | awe | bwe | cwe | ...[/tt]
there are always the same number of columns per day so I decided to create a set of procedures which loads an array for each day of the week.
my first procedure is monday
example of calling the code
this returns the correct values
add a procedure for tuesday
calling [tt]get_columns_for_monday[/tt] I get values for [tt]get_columns_for_tuesday[/tt]
here is the complete code example
What I can't explain is that when I either remove or comment out [tt]get_columns_for_tuesday[/tt], or switch the positions of [tt]get_columns_for_tuesday[/tt] and [tt]get_columns_for_monday[/tt] the results are correct.
Any ideas on how to avoid this behavior, and/or what I'm doing wrong.
Jason Meckley
Programmer
Specialty Bakers, Inc.
I have a de-normalized table. where there are a series of columns for each day of the week. example:
[tt]amo | bmo | cmo | atu | btu | ctu | awe | bwe | cwe | ...[/tt]
there are always the same number of columns per day so I decided to create a set of procedures which loads an array for each day of the week.
my first procedure is monday
Code:
PROCEDURE get_columns_for_monday
PARAMETER the_id, the_array
select amo, bmo, cmo;
from table;
where id = the_id;
INTO ARRAY the_array;
example of calling the code
Code:
DIMENSION days[1]
DO get_columns_for_monday WITH 1, days
add a procedure for tuesday
Code:
PROCEDURE get_columns_for_tuesday
PARAMETER the_id, the_array
select atu, btu, ctu;
from table;
where id = the_id;
INTO ARRAY the_array;
here is the complete code example
Code:
SET DEFAULT TO [directory]
CLEAR
id = 1
DIMENSION mondays[1]
DO get_columns_for_monday WITH id, mondays
&& this incorrectly returns 4,5,6. the correct result is 1,2,3
int i = 1
DO WHILE i <= ALEN(mondays)
@i,1 SAY mondays[i]
i = i + 1
ENDDO
&& should return 1, 2, 3
PROCEDURE get_columns_for_monday
PARAMETER the_id, the_array
select amo, bmo, cmo;
from table;
where id = the_id;
INTO ARRAY the_array;
&& should return 4, 5, 6
PROCEDURE get_columns_for_tuesday
PARAMETER the_id, the_array
select atu, btu, ctu;
from table;
where id = the_id;
INTO ARRAY the_array;
Any ideas on how to avoid this behavior, and/or what I'm doing wrong.
Jason Meckley
Programmer
Specialty Bakers, Inc.