>>I have a Legacy Foxpro 2.6 for Windows App here to maintain.
>>
>>I found that they are using on this particular form a listbox. This listbox gets its input from a SQL Select feeding to an Array. The selected value goes to a variable (character).
>>
>>One problem.
>>
>>I am starting fresh with the code to create a new layer of input, so I copied this to use. I am starting with blank databases, so the SQL statement gets NO records, hence the array is non-existant, and the form crashes upon starting.
>>
>>What is a solution for this? I have placed code to check _TALLY, and then intialize the Array with 1 element, and placed values in the array element.
>>
>>Is there a cleaner way?
>>What would you do?
>>
>>Tommy
>
>Tommy,
>My approach is a little different. I never dimension the array before SQL and explicitly release array if by any means I would do another SQL into the same array.
>Because if array exists SQL doesn't shrink its size in cases resulting a wrong assumption that there were elements.
>Instead whenever I select into array I explicitly check :
>if type('arrSQL[1,1]') # 'U'
>...
>else
>..
>endif
>If SQL returned no reults it would be 'U'. If you really ever need a nonempty array you could take care of it in else part in safer way.
>_Tally is not always reliable IMHO.
>Cetin
Why not always reliable?
If it's not broken, fix it until it is.
My Blog