Re: using an input string from prompt_string

new topic     » goto parent     » topic index » view thread      » older message » newer message

Les Rogers wrote:
> 
> 
> hi there , 
> 
> one more question .......... 
> sorry for my lack of knowledge ........
> but, just new and learning the dir,file stuff etc.
> 
> the programme below gives me any file, sub directory, directory etc.
> 
> but I have to open the file in the editor 
> then type the directory I want the files from .
> 
> I wonder how I use the answer to prompt_string 
> to get programme 
> 
> to output the directory ??
> 
>  Is there a line to use ?
> 
> ********************** below is prompt_string
> name takes string
>                      now,
>  how can 
> exit_code understand is the directory I want ??
> 
<SNIP> 
> 
> If it is too difficult ......... O.K. 
>          I'll plod on 
> 
> But thanks for reading my message 

It's never too difficult :)
The challenge is the fun!

One simple change..

exit_code = walk_dir(name,routine_id("look_at"),FALSE)

aside from changing the first argument to just name, notice that I changed TRUE
to FALSE. see below


Your look_at() function is not quite right still.
I had assumed you fixed it yourself, since your were satisfied with the code I
posted the other day.

It doesn't unindent, when it leaves a subdirectory.

Using the function the way it is, you will get:
C:\
  C:\subdir1\
    C:\subdir1\file1.txt
    C:\subdir1\subdir2\
      C:\subdir1\subdir2\file2.txt
      C:\subdir3\
        C:\subdir3\file3.txt

What you really want is:
C:\
  C:\subdir1\
    C:\subdir1\file1.txt
    C:\subdir1\subdir2\
      C:\subdir1\subdir2\file2.txt
  C:\subdir3\
    C:\subdir3\file3.txt


Here is the function ya need..
function look_at(sequence path_name,sequence entry)
 integer ret
    ret = 0 -- default exit code
    if k=0 then
       -- it's not a good idea to put multiple statements on one line
       -- the 2nd statement is easily missed
       printf(1,"%s \n\n",{path_name}) k=1
    end if
    puts(1,"\t")
    if find('d',entry[D_ATTRIBUTES]) then
       puts(1,"\n\t\t<SUB DIR> ")
    end if
    printf(1,"%s%s\n",{repeat('\t',tabs),entry[D_NAME]})
    if find('d',entry[D_ATTRIBUTES]) then
       puts(1," \n")
       tabs += 1
       -- recurse into subdirectory
-- we need to walk the subdirectories ourself so we know when they are
       finished
       ret = walk_dir(path_name&"\\"&entry[D_NAME],routine_id("look_at"),FALSE)
       tabs -= 1 -- unindent
    end if
    return ret
end function

-- Using FALSE instead of TRUE, walk_dir() will traverse only the top-level in
the specified directory.
-- Subdirectories are traversed via the look_at() function.

exit_code = walk_dir(name,routine_id("look_at"),FALSE)


Hopefully I got it right this time.

Chris Bensler
~ The difference between ordinary and extraordinary is that little extra ~
http://empire.iwireweb.com - Empire for Euphoria

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu