Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Local var not local
Message
De
24/10/2001 17:40:25
John Deupree
Long Term Care Authority
Tulsa, Oklahoma, États-Unis
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
00572823
Message ID:
00572921
Vues:
22
The problem was setting nColumnCount to the grid columncount. When I re-exectuted the SQL statement, it closed the cursor and recreated it. That meant that all the grid controls were gone and had to be reset. When I reset the grid record source to the cursor, it automatically set the grid columns to the # of columns in the cursor (5). Something probably everyone else knew but that I just learned.

Thanks

John

>>I have declared a variable local in a form class method, yet it seems not to be local. Here is the code:
>>
>>
>>THISFORM.grdfind.RECORDSOURCE = THIS.ccursorname
>>LOCAL nColumnCount, nColNumber
>>nColumnCount = THIS.grdfind.COLUMNCOUNT
>>
>>FOR nColNumber = 1 TO nColumnCount
>>	THIS.grdfind.COLUMNS(nColNumber).CONTROLSOURCE = ;
>>		THIS.ccursorname + "." + THIS.afieldnames(nColNumber)
>>ENDFOR
>>
>>
>>If I run through this method twice it blows up because nColNumber = 5 (nColumnCount = 4). If I suspend the code below the ENDFOR, nColNumber = 5 at the end of the first pass. Is this normal? I thought that nColNumber would never be greater than 4?

>
>Yes, that's the way FOR loop works. The variable of the loop (nColNumber) gets incremented before it's compared to the TO value (nColumnCount).
>
>On the second call to the method, nColNumber starts out at 5. I use this same variable in the calling program (declared local) and another method in the same form class (also local).
>
>It looks like you have variable nColNumber in the calling program. Anyway, at the begining of the loop nColNumber variable would start from 1 again.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform