Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Ains() bug
Message
De
31/01/2019 17:38:07
 
 
À
31/01/2019 16:26:31
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2003
Database:
MS SQL Server
Divers
Thread ID:
01665830
Message ID:
01665855
Vues:
68
>>>The last column will be .f., but the rest of the elements won't move correctly. You'd expect that the old 6th element (the 1st element of the 2nd row before redimensioning) would now be the 7th element, but no - it's now .f., and the a(2,1) doesn't contain a filename, it contains a length. Check in the debugger. When you do ains() without the third parameter, all the elements below the starting position shift nCol positions down, so if you do aIns(a,4), you get a(4,1) to a(4,5) as .f., a(5,1) contains what was in a(4,1) etc. Doesn't work when inserting a column.
>>
>>When applied to two-dimensional array with column insert option, elements don't "shift" from one row to another -- elements at the end of the row "fall off" the end rather than "wrapping" into the following row. The workaround would be use AINS() with the array as if it was a one-dimensional and insert the desired item one (logical) row at a time (using AELEMENT() to get the proper element number from the row, column subscripts). That should prevent the loss of the data and "realign" the data into the proper columns.
>
>IOW, aIns() has a bug when inserting columns and we should roll our own.
>
>Not that I ever needed it... just got a question from a friend (kind of apprentice... for about 11 years now) and just had to take a look. This is how weird threads start.

I wouldn't say that the behavior of AINS() is buggy. Let's say we have the following:.
DIMENSION ATest[4,3]
ATest[1,1] = 1
ATest[1,2] = 2
ATest[1,3] = 3
ATest[2,1] = 4
ATest[2,2] = 5
ATest[2,3] = 6
ATest[3,1] = 7
ATest[3,2] = 8
ATest[3,3] = 9
ATest[4,1] = 10
ATest[4,2] = 11
ATest[4,3] = 12

If I were to perform =AINS(ATest,2,2), this would be the result I'd expect to see:
ATest[1,1] = 1
ATest[1,2] = .F.
ATest[1,3] = 2
ATest[2,1] = 4
ATest[2,2] = .F.
ATest[2,3] = 5
ATest[3,1] = 7
ATest[3,2] = .F.
ATest[3,3] = 8
ATest[4,1] = 10
ATest[4,2] = .F.
ATest[4,3] = 11

NOT
ATest[1,1] = 1
ATest[1,2] = .F.
ATest[1,3] = 2
ATest[2,1] = 3
ATest[2,2] = .F.
ATest[2,3] = 4
ATest[3,1] = 5
ATest[3,2] = .F.
ATest[3,3] = 6
ATest[4,1] = 7
ATest[4,2] = .F.
ATest[4,3] = 8
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform