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!

Time issue??

Status
Not open for further replies.

wjs2

Programmer
Jan 3, 2001
102
US
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:
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)
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
 
The beginning of the last paragraph should have read; 'before the first 'if' statement.' This paused the system right after the 'for' clause and prior to the first 'if' being executed. This had to be the command giving the problem since the executable worked once this 'inkey' command was inserted.

Thanks,
WJS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top