Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unusual behavior of ADEL()

Status
Not open for further replies.

justamistere

Programmer
Jul 25, 2002
67
US
Has anyone found the following to be true in VFP-6/SP-5?
The ADEL() command syntax states: "nElementNumber specifies the number of the element, row, or column to delete from an array."

gnFiles = 3
DIMENSION gaMyArray[gnFiles, 4]

gaMyArray[1, 1] = "1-aaa"
gaMyArray[1, 2] = "1-bbb"
gaMyArray[1, 3] = "1-ccc"
gaMyArray[1, 4] = "1-ddd"

gaMyArray[2, 1] = "2-aaa"
gaMyArray[2, 2] = "2-bbb"
gaMyArray[2, 3] = "2-ccc"
gaMyArray[2, 4] = "2-ddd"

gaMyArray[3, 1] = "3-aaa"
gaMyArray[3, 2] = "3-bbb"
gaMyArray[3, 3] = "3-ccc"
gaMyArray[3, 4] = "3-ddd"

***---| Error message: "Subscript is outside of defined range."!!!
gnPos = ASCAN(gaMyArray, "3-aaa")
?ADEL(gaMyArray, gnPos)

***---| Works
gnRow = ASUB(gaMyArray, ASCAN(gaMyArray, "3-aaa"), 1)
?ADEL(gaMyArray, gnRow)

***---| Works Incorrectly !!!
gnCol = ASUB(gaMyArray, ASCAN(gaMyArray, "3-aaa"), 2)
?ADEL(gaMyArray, gnCol, 2)
 
Since your array is dimensioned with two dimensions( DIMENSION gaMyArray[gnFiles, 4]), when you retrieve the position of the first search term(gnPos = ASCAN(gaMyArray, "3-aaa")) and issue a delete(adel(gaMyArray,gnPos)), you are passing a truly invalid array subscript(gnPos = 9).

The second adel() is passed a valid subscript reference since you first convert it to a row element.

Darrell
'We all must do the hard bits so when we get bit we know where to bite' :)
 
To: "darrellblackhawk". According to the "Syntax" in the help file you could send it the "nElement". "gnPos", IS the element number. ASCAN returns the Element number, just as the parameter description states.

Just to be an "English" stickler, maybe if the Help file had put an "; " after the word "element" and called the parameter "nSubscript", then it might make some sense.
It could be Bad help-documentation.
 
There are many confusing issues in the help file(s).

The only way I've resolved them is trial and error or talking to others.

Darrell 'We all must do the hard bits so when we get bit we know where to bite' :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top