GETFILELIST() question

Previous topic - Next topic

okee

when i do the following
Quotenum = GETFILELIST("*.png", files$[])

I assume GETFILELIST populates the files$[] array with the names of the files
that match the find string "*.png"

but when i do

QuoteFOR i=0 TO BOUNDS(files$[], 0)-1
  PRINT files$, 0, (i+3)*font_y
NEXT

It outputs
.
..
for directories
should it not skip those, as i've specified to list *.png

okee
Android: Samsung Galaxy S2 -  ZTE Blade (Orange San Francisco) - Ainol Novo 7 Aurora 2
IOS: 2 x Ipod Touch (1G)

fuzzy70

I think every version of Basic I have used gets the "." & ".." with or without a file mask like "*.png". Normally the examples have some string formatting when outputting or remove them from the array before use  :(
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

Kitty Hello

yes. If you want no directories, just drop them with DIMDEL from the array.
It's important, because people might have a subdirectory with the name "images_in_format.png".

okee

Android: Samsung Galaxy S2 -  ZTE Blade (Orange San Francisco) - Ainol Novo 7 Aurora 2
IOS: 2 x Ipod Touch (1G)

Slydog

QuoteIt's important, because people might have a subdirectory with the name "images_in_format.png".

Gernot, but couldn't you at least remove the "." and ".." from the GETFILELIST() results (ie, update the actual command)?
Every result set includes a 'current directory [.]' and 'parent directory [..]' so including those only confuses matters.

The only problem is that people's existing code may trip if they are expecting / handling this already.
Or give the command an optional parameter to not include those?

I really don't care myself, just thought it may prevent confusion in the future.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

fuzzy70

If it can't be changed (command wise) perhaps a note and/or example in the docs stating that "." & ".." are added to the list. Out of interest are they always the 1st 2 entries in the array?. I'm not at home at the moment so unable to check & not got round to playing with files/directories in GLB yet

Lee
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

Kitty Hello

#6
I'll drop the "." directory.
The ".." is very important beause it tells you whether you can go one directory up or not.

ampos

It will make bad things on current programs (mine, for example).

Currently I am making

Quotegetfilelist blahblah
DIMDEL temp$[],0;DIMDEL temp$[],0

If someone want to get rif of "..", it is as easy/hard as to type DIMDEL temp$[],0 once or twice.

Slydog

#8
Quote from: Slydog on 2011-Nov-04
The only problem is that people's existing code may trip if they are expecting / handling this already.

Quote from: ampos on 2011-Nov-09
It will make bad things on current programs (mine, for example).

That's what I was worried about!  :o

I'd say the only advantage would be get rid of both.
But as you mentioned Gernot, the ".." lets you know you're not in a root folder.

I'd say leave it as it is. 
If you have to handle one, might as well handle both.

[Edit] Or get rid of both, and add an 'ISROOTFOLDER(path$)' command.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Ruidesco

Or add a boolean optional last  parameter "dropDirectoryReferences%" that defaults to FALSE to keep the current behaviour in old code.
Infinite possibilities! :good:

Kitty Hello

OK, I'll dopr the changes now. Please just delete the "." and ".." directories yourself if you don't need them.