I have a program in VFP 6.0 that allows the user to change a table sturcture. The fields are displayed for the user in a list box. In the validation routines I check for duplicate field names. The routine looks like this:
The first 'if' statement eliminates checking the field name aginst itself if a field is being changed.
OK. The problem: This routine was giving false positives for duplicate field names. The only thing I could figure out, since the routine worked in debug mode, was a timing issue. I added one line of code after 'for statement:
This produced a slight pause in the program before the second 'if' statement executed, and it worked. Has anyone ran accross this kind of problem before? It's the first time I've seen it. Do you know of a solution that might be a little more elegant? This one is kind of ugly.
Thanks,
WJS
Code:
For ThisForm.lstResults.listindex = 1 to ThisForm.lstResults.listcount step 1
If SaveIndex = ThisForm.lstResults.listindex and ;
ThisForm.txtFieldComplete.Value = 'Change'
Else
Namelen = atc(' ',ThisForm.lstResults.value(ThisForm.lstResults.listindex)) - 1
OldName = substr(ThisForm.lstResults.value(ThisForm.lstResults.listindex),1,Namelen)
OldName = padr(OldName,10,' ')
Namelen = len(rtrim(ThisForm.txtFName.value))
NewName = substr(ThisForm.txtFName.value,1,Namelen)
NewName = padr(NewName,10,' ')
If NewName = OldName
Thisform.txtFieldComplete.value = 'Duplicate Field Name'
Thisform.txtFName.setfocus
Exit
Endif
Endif
Endfor
The first 'if' statement eliminates checking the field name aginst itself if a field is being changed.
OK. The problem: This routine was giving false positives for duplicate field names. The only thing I could figure out, since the routine worked in debug mode, was a timing issue. I added one line of code after 'for statement:
Code:
For ThisForm.lstResults.listindex = 1 to ThisForm.lstResults.listcount step 1
=Inkey(0.0001)
Thanks,
WJS