mac load dir issue

Started by wadmixfm, August 23, 2020, 13:09:53

Previous topic - Next topic

wadmixfm

' loaddir.bmx
SuperStrict

' declare a string array
Local files:String[]
files = LoadDir("\Applications\Specdrum\Kits\Standard\")

For Local t:String = EachIn files
Print t
Next


** note **

the path you see is just a folder with my .wav sounds in there
i want to load them in to an array

for example

the files in the folder are like this

01) Bass Drum.wav
02) Snare.wav
03) Hi Tom.wav
04) Lo Tom.wav
05) Cowbell.wav
06) HHat CL.wav
07) HiHat Open.wav
08) Claps.wav
09) Rim Shot.wav
10) Guiro.wav

Building .loaddir
[ 97%] Processing:.loaddir.bmx
[ 98%] Compiling:.loaddir.bmx.gui.debug.macos.x64.c
[100%] Linking:.loaddir.debug

Executing:.loaddir.debug

01) Bass Drum.wav
06) HHat CL.wav
03) Hi Tom.wav
05) Cowbell.wav
02) Snare.wav
04) Lo Tom.wav
09) Rim Shot.wav
07) HiHat Open.wav
08) Claps.wav
10) Guiro.wav


Process complete

in windows the same code produces it in order but mac os catalina it produces the above

can someone help as its doing my head in :)

Lee

iWasAdam

The Mac and windows file systems are completely different. You can't assume they are the same. If you need files in a certain order - then you will need to load them exactly, or sort them yourself

wadmixfm

so what is the mac looking at then when it sees the folder ???

is it looking at the size of the file , the date ,the length of the filename or when it was modified for example

i just can't work it out

i dont understand tmaps

the windows way was great you could look at a directory , load into an array like stands$[11]

then call them back in a loop

for example
Local namestd$[11]
Local folder$
Local jl
'get data from folder

' Define what folder To start with ...
folder$="\Applications\Specdrum\Kits\Standard"

Local myDir:Byte Ptr = ReadDir(folder$)

If myDir=0 Then RuntimeError folder+" does not exist!"
Global file:String=NextFile$(myDir)

While file
   If Lower(ExtractExt(file))="wav"
      namestd=namestd[..jl+1]
      namestd$[jl]=file$
      jl=jl+1
   EndIf
   file$=NextFile$(myDir)
Wend
CloseDir myDir


For Local i = 0 To 9

Print namestd$

Next

this works but its all jumbled

not in order

lee




Derron

Loaddir...returns an array of strings.

ThisArray = ThisArray.sort(true)
Will sort it for you

Bye
Ron

wadmixfm

cheers sorted

Import Brl.StandardIO
Local namestd$[11]
Local folder$
Local jl

Local list:TList = CreateList()

' add some string objects to the begin of the list

'get data from folder

' Define what folder To start with ...
folder$="\Applications\Specdrum\Kits\Standard"

Local myDir:Byte Ptr = ReadDir(folder$)

If myDir=0 Then RuntimeError folder+" does not exist!"
Global file:String=NextFile$(myDir)

While file
If Lower(ExtractExt(file))="wav"

namestd=namestd[..jl+1]
namestd$[jl]=file$
ListAddLast(list, namestd$[jl])
jl=jl+1
EndIf
file$=NextFile$(myDir)
Wend
CloseDir myDir

SortList(list, True)

' enumerate all the strings in the list
For Local a:String = EachIn list
Print a
Next



this prints out

Building untitled2
[ 97%] Processing:untitled2.bmx
[ 98%] Compiling:untitled2.bmx.gui.debug.macos.x64.c
[100%] Linking:untitled2.debug
Executing:untitled2.debug

01) Bass Drum.wav
02) Snare.wav
03) Hi Tom.wav
04) Lo Tom.wav
05) Cowbell.wav
06) HHat CL.wav
07) HiHat Open.wav
08) Claps.wav
09) Rim Shot.wav
10) Guiro.wav

Process complete

thanks for the help peeps

lee