Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Search an Array for duplicates
Message
 
 
To
22/05/2003 12:56:34
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00791559
Message ID:
00791739
Views:
24
Try
        ASORT(laDBFInfo)
	for i=1 to lnFieldNumber-1
		if laDBFInfo[i,1] == laDBFInfo[i+1,1]
			llFoundErrors = .t.
			gcmessage = gcmessage + 'Duplicate column ' + laDBFInfo[i,1] + ' found.'
			EXIT
		endif
	endfor
>I am trying the For lopp, but am getting 'subscript is out of range' errors. Perhaps I need to give a little more info. The array I am trying to search is created by AFields().
>I am searching for a duplicate field name in the table.
>(I know it is not supposed to happen, but it is a weird thing from an EXCEL export)
>so, I get the number of fields from the temp table:
>lnFieldNumber = afields(laDBFInfo,'temp')
>

>The want to use ASCAN() to find any duplicate coloumn names.
>This is the section of code I have now:
>
>if ascan(laDBFInfo,'primekey',1,lnFieldNumber,1,1) = 0
>  llFoundErrors = .t.
>  gcmessage = gcmessage + 'Required column PRIMEKEY is missing.<br>'
>else
>  lnOccurs = 0
>  for i=1 to lnFieldNumber
>    if ascan(laDBFInfo,'primekey',i,lnfieldnumber,1,7) <> 0
>	lnOccurs = lnOccurs + 1
>    endif
>  endfor
>  if lnOccurs > 1
>    llFoundErrors = .t.
>    gcmessage = gcmessage + 'Duplicate column PRIMEKEY found.<br>'
>endif
>
>CAn anyone see what I am doing wrong here?
>TIA
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform