Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ADEL() problem/bug/pain
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
ADEL() problem/bug/pain
Divers
Thread ID:
00213854
Message ID:
00213854
Vues:
53
One of my fellow programmers has found a condition where the ADEL() causes an error to happen. He uses the following code:

with thisform
error
dimension .lstnalcnsn.aitems[alen(.lstnalcnsn.aitems,1),2]
.lstnalcnsn.numberofelements = alen(.lstnalcnsn.aitems,1)
* Below is a strange situation: the commands boxed-in below work correctly.
* The problem is that when the messagebox's are removed, the adel command will
* result in a "subscript is outside defined range" error when there is only
* one row left in the array. In summary, with messageboxes, works.... without
* messageboxes, doesn't work. The workaround is to set the array elements to
* .f. when there is only one row instead of issuing an adel command.
*******************************************************************************
*** messagebox(" alen lstnalcnsn aitems ="+str(alen(.lstnalcnsn.aitems))) ***
*** messagebox(" lstnalcnsn listindex = "+str(.lstnalcnsn.listindex)) ***
*** adel(.lstnalcnsn.aitems,.lstnalcnsn.listindex) ***
*** if alen(.lstnalcnsn.aitems,1) > 1 ***
*******************************************************************************
if alen(.lstnalcnsn.aitems,1) > 1
adel(.lstnalcnsn.aitems,.lstnalcnsn.listindex)
dimension .lstnalcnsn.aitems[alen(.lstnalcnsn.aitems,1)-1,2]
else
.lstnalcnsn.aitems[1,1]=""
.lstnalcnsn.aitems[1,2]=""
endif
.lstnalcnsn.numberofelements = .lstnalcnsn.numberofelements - 1
.lstnalcnsn.refresh()
endwith


As he noted in his comments above when the message boxes are in place the code does not error, but when you take them out and try to adel() the last element in the array the program errors. He has since tried to program a work around for this situation. If anyone else has seen this before or can think of why his code is flawed, please respond.

TIA
Bret Hobbs

"We'd have been called juvenile delinquents only our neighborhood couldn't afford a sociologist." Bob Hope
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform