You are here:

FoxPro/Foxpro 6 code to Foxpro 9 code


In foxpro 6 this code worked. But not in Foxpro 9
I initiate a program that does the following:

kh_array[ alen( kh_array),1 ] = createobject("monthC", m.d_date, m.person_id, m.id_name )
kh_array[ alen( kh_array),1 ].show

the monthn init executes the following code: = "MonthViews"

then another program code performs the following:
kh_array[ alen( kh_array),1 ] = createobject("monthn", m.d_date, m.person_id, m.id_name )
kh_array[ alen( kh_array),1 ].show

the monthn init executes the following code: = "MonthView"

The click event in the window created from above "monthn" executes the following:

hide window monthview
show window monthviews

the program successfully hides the window monthview but I get the following error message when it tries to execute show window monthviews:


Can you help?

Hi, Ken

  I'll start with the easy version of the bad news.  I don't know.  That being said, I can try a guess, but it is just a guess, so no guarantees.

  The generation of "MonthN" and "MonthC" are identical except for the object name.  Since "MonthN" is replacing "MonthC" in an element of the array "KH_ARRAY," there may be a cause and effect thing there.  I would have had more confidence in that as the cause if you hadn't told me it worked in VFP6.

  In what MAY be a related issue, I am somewhat confused by the use of
         kH_ARRAY[ ALEN( KH_ARRAY),1 ]

      ALEN(KH_ARRAY) refers to the last element in the array, and
      KH_ARRAY[ALEN(KH_ARRAY),1] refers to the first element in that row number, but, if it
         was defined as a 2-dimensional array, that row number shouldn't exist.
      Example:  DIME ARY(3,2)
         ALEN(ARY) will return 6 (the last element in a 3 row, 2 column array)
         So, ARY(alen(ARY),1) = ARY(6,1) which is the first column in row 6 which is the
         same as ARY(3,2).  EXCEPT if the array was defined as 3,2 - referencing 6,1 will
         produce an error ("Subscript is outside defined range.")
         When VFP9 creates a 2-dimensional array, it can be reference by a single number,
         but the result is not very intuitive.
         Another major difference is that ALEN(ARY,1) will produce different results
         depending on how it was last defined.  If the array was dimensioned as ary(3,2)
         alen(ary,1) will return 3.  If the array was dimensioned as ary(6), alen(ary,1)
         will return 6.  ALSO (the not very intuitive part), a 2-dimensional reference to
         the array seems to ignore the row reference.  For example DIME ARY(6), then
         assign the values A through F.  ARY(2,3) will be "C" and ARY(42,3) will be "C" and
         only if the column value is too high do you get the subscript error.

I don't know if any of this has anything to do with your current issue, but it's worth looking into.  If your problem is still unsolved, I will try to find out what's going on but, to do so, I will need ALL of the code involved.

Good Luck,


All Answers

Answers by Expert:

Ask Experts


Fred Frase


Questions about development only. No installation or hardware specific questions, please. Your first step in requesting assistance should be to identify the version of FoxPro you are using. I can write short functions but, PLEASE do not ask me to write programs for you.


Nearly 30 years professional programming experience using FoxPro (FoxBase through VFP 9) or other xbase language, primarily in Windows environments.

Completed a 1,000 hour diploma course in programming at International Academy of Ohio (subsequently merged with Southern Ohio College).

©2017 All rights reserved.