REM Hi there, REM Ludovik wrote: REM > REM > I try to make a pgm which list all files in my Psion 3a. Here is my PGM but REM > there is a problem about recursive. REM > [...] REM > Proc DIR3:(C$) REM > local d$(128),e$(128) REM > d$=DIR$(c$) REM > while d$<>"" REM > if exist(d$) REM > print d$ REM > else REM > e$=d$+"\" REM > DIR3:(e$) REM > endif REM > d$=dir$("") REM > endwh REM > ENDP REM The trouble is that when you recurse and call DIR$ again REM it clobbers the results of the DIR$("") which are called REM when you return. You need to get all the names from DIR$ REM first before recursing. Whether you want to do this using REM linked lists or just stuffing values in arrays is up to REM you. Here's a simple version but note that it won't cope REM well if your directory tree is too wide/deep. proc main: global names%(200) : rem Simple stack global nameidx% : rem Stack pointer (free slot) rem ALWAYS use the cache when recursing otherwise rem the code for the recursive procedure is alloced rem at each call instead of just the locals/params cache 8000, 8000 nameidx% = 1 doDir:("loc::m:\") giprint "Done" get endp proc doDir:(path$) local nam$(130) local start% rem Save the stack pointer start% = nameidx% rem Collect all the names nam$ = dir$(path$) while (nam$ <> "") push:(nam$) nam$ = dir$("") endwh rem Sort the names if you want to: rem mysort: rem Display the names. while (nameidx% > start%) nam$ = pop$: if (exist(nam$)) print nam$ else rem Recurse doDir:(nam$ + "\") endif endwh endp proc push:(nam$) rem We ought to check array bounds and check rem to see if the ALLOC failed ... rem Create a slot and store the name on the stack names%(nameidx%) = alloc(len(nam$) + 1) poke$ names%(nameidx%), nam$ rem Increment stack pointer nameidx% = nameidx% + 1 endp proc pop$: local result$(130) rem Decrement the stack pointer. nameidx% = nameidx% - 1 rem Retrieve the name and free slot result$ = peek$(names%(nameidx%)) freealloc names%(nameidx%) return result$ endp REM This could be improved by using a linked list rather REM than array, adding all sorts of sanity checks such REM as making sure your ALLOCs don't fail. You ought to REM use FilChangeDirectory to move down directories rather REM than using DIRNAM$ + "\" since this will only work on REM DOS-like file systems. REM Just for reference, on my Psion I only needed 70 entries REM in the name stack rather than 200. REM Cheers, REM Martin