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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter repeated files

Status
Not open for further replies.

starrytwinkle

Technical User
Dec 23, 2002
28
SG
I have a dropdownlist that will display one of the fields in a property list text file.
The problem is I do not want to have repeated items in the list. Is there anywhere I can solve?
Thank You.
 
Ok, first thing is to load it all into a list. We'll call it listA. We'll also create an empty list named listB and set a variable named exists to 0.

------------
listA = [1,2,3,1,4,5,2]
listB = [:]
exists = 0

--Next we'll make a little repeat statement.--

repeat with k = 1 to listA.count

if listB.count > 0 then

exists = 0
repeat with j = 1 to listB.count
if listA[k] = listB[j] then exists = 1
end repeat

end if

if exists = 0 then listB.append(listA[k])

end repeat
--------

Now the raw data from listA will be processed and put into listB with no repeating values. So:

listA [1,2,3,1,4,5,2] ---> listB[1,2,3,4,5]

Cool huh? Enjoy, tell me if you have any problems or the script doesnt work (it's late here, kinda tired).
 
oh......... thanks. I try it out tomorrow. Everything I have is in the office. Thank You again.
 
I have this error :
"Script error. Handler not found in object. if exists = 0 then listB.append(listA[k])"

I think for append I need to add in an xtra? or isit another one? Thanks.


 
There is no error now but there is still no filter of the members.

~~~~~~~~~~~~~~~~~~~~~

global gDatabase -- List with all the database records
global gCurrentRecord -- The index of the current record


-- Initialise of sprite properties
on startmovie

myFile = new(xtra "fileio") -- Create an instance of FileIO
openFile(myFile,the moviePath&"Cssp_Database5.TXT",1) --Open the file with read access

text = readFile(myFile) --set the variable 'myVariable' to the text of the file 'info.txt'

gdatabase = value(text)
listB = [value(text)]
exists= 0

-- html header
htext = &quot;<HTML><BODY BGCOLOR=#FFFFFF>&quot;&RETURN

-- put the table headings
put &quot;<TABLE align=left border=2 cellspacing=2 cellpadding=2><TR><TH align=center width=200>SMC/GRC</th></TR>&quot;¬
&RETURN after htext


repeat with i = 1 to gDatabase.count

put &quot;<TR>&quot; after htext

put &quot;<TD align= left width=200>&quot;&gDatabase.smc&&quot;</TD>&quot; after htext

if listB.count > 0 then

exists = 0

repeat with j = 1 to listB.count

if gDatabase.smc = listB[j] then exists = 1

end repeat

end if

if exists = 0 then listB.append(gDatabase.smc)

end repeat
put &quot;</TR>&quot;&RETURN after htext
-- close out table and HTML
put &quot;</TABLE></BODY></HTML>&quot; after htext

-- the member for the list to appear in. For this, it is in a field not the ddl yet.
member(&quot;Database List&quot;).html = htext

end

~~~~~~~~~~~~~~~`
 
I tried this codes but they still do not work properly... any idea y? THANK YOU.

============================================================
repeat with i = 1 to gDatabase.count
k=2
if gDatabase.smc = gDatabase[k].smc then
gDatabase.deleteAt(i)
end if

put &quot;<TR>&quot; after htext
put &quot;<TD align= left width=280>&quot;&gDatabase.smc&&quot;</TD>&quot; after htext
end repeat

put &quot;</TR>&quot;&RETURN after htext
-- close out table and HTML
put &quot;</TABLE></BODY></HTML>&quot; after htext
put &quot;d&quot;

member(&quot;smc data text&quot;).html = htext
put &quot;e&quot;

member(&quot;smc data field&quot;).text = member(&quot;smc data text&quot;).text
===========================================================
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top