Page 1 of 1 1
Topic Options
#130553 - 2004-12-03 09:35 PM Filer Array of Files
@lejo @rias Offline
Starting to like KiXtart

Registered: 2003-09-02
Posts: 100
Loc: Medellin, Colombia
Hi, I need exclude some files from an array of elements (files & path)

Ex: array
$files =
e:\dir3\lis.doc
c:\temp\file1.xls
c:\programfiles\prog1\file1.mdb
c:\windows\text.doc
d:\program2\dir3\text.jar

I use
Code:

$excl="text","file1"
For Each $Ex In $Excl
$Archivos=FilterArray($archivos,$Ex)
Next



but the filter not exclude, only work if I write the full path, exist some way to work without full path? only the filename?
_________________________
Look always 4 the best...

Top
#130554 - 2004-12-03 10:46 PM Re: Filer Array of Files
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
I'm not sure what problem you are having. when i run the following code

Code:

break on

$Archivos =
'e:\dir3\lis.doc',
'c:\temp\file1.xls',
'c:\programfiles\prog1\file1.mdb',
'c:\windows\text.doc',
'd:\program2\dir3\text.jar'

$excl="text","file1"

? "-------- Before -----------"
for each $f in $Archivos
? $f
next

For Each $Ex In $Excl
$Archivos=FilterArray($Archivos,$Ex)
Next

? ? ? "-------- After -----------"
for each $f in $Archivos
? $f
next


Function FilterArray($array,$find, optional $inclusive)
Dim $lf, $t, $l, $sp
$lf=chr(10) $sp=chr(32)
If Not VarType($Array) & 8192 Exit(1) EndIf
for each $l in $array
if (instr($l,$find) and $inclusive and trim($l)> $sp) OR
(not instr($l,$find) and not $inclusive and trim($l)> $sp)

$t=$t+$lf+$l

endif
next
$FilterArray=split(substr($t,2),$lf)
EndFunction



I get the following output

Quote:


-------- Before -----------
e:\dir3\lis.doc
c:\temp\file1.xls
c:\programfiles\prog1\file1.mdb
c:\windows\text.doc
d:\program2\dir3\text.jar


-------- After -----------
e:\dir3\lis.doc



_________________________
Eric

Top
#130555 - 2004-12-03 10:50 PM Re: Filer Array of Files
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
i think i understand...

your array is

$files =
e:\dir3\lis.doc
c:\temp\file1.xls
c:\programfiles\prog1\file1.mdb
c:\windows\text.doc
d:\program2\dir3\text.jar

and you want to filter for only "filel.*", "text.*". To make your array equal like this....

$FilterdArray =
c:\temp\file1.xls
c:\programfiles\prog1\file1.mdb
c:\windows\text.doc
d:\program2\dir3\text.jar

is this correct?


Top
#130556 - 2004-12-03 11:23 PM Re: Filer Array of Files
@lejo @rias Offline
Starting to like KiXtart

Registered: 2003-09-02
Posts: 100
Loc: Medellin, Colombia
Not Bryce, I need the maciep response, but in my script don't work

i will post full code monday.. tks
_________________________
Look always 4 the best...

Top
#130557 - 2004-12-04 03:33 AM Re: Filer Array of Files
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ja, I will also be online and working when I want.
but not on monday, that's finnish independence day.
it should be holiday for everyone, no matter what nationality he's representing.
_________________________
!

download KiXnet

Top
#130558 - 2004-12-06 11:21 PM Re: Filer Array of Files
@lejo @rias Offline
Starting to like KiXtart

Registered: 2003-09-02
Posts: 100
Loc: Medellin, Colombia
Hi, I found the problem but not the solution.

Well, if I use the following code:

$excludes="frunlog","DBLIB4","favorite","helplt4","iccon","log","lsxlc","perweb","readme","leame","java"

the filter function work, but if I use readprofilestring, not return an array, return the full string and the function not work.

$excludes=ReadProfileString("N:\REN\DAT.INI","VR","EXCL")

_________________________
Look always 4 the best...

Top
#130559 - 2004-12-06 11:59 PM Re: Filer Array of Files
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
THat is because the first is an array and the second is not. Take a look at the Split() function to turn a string into an array.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#130560 - 2004-12-07 12:12 AM Re: Filer Array of Files
@lejo @rias Offline
Starting to like KiXtart

Registered: 2003-09-02
Posts: 100
Loc: Medellin, Colombia
Tks Les, work fine.
_________________________
Look always 4 the best...

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1636 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.13 seconds in which 0.09 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org