Re: using an input string from prompt_string
- Posted by CChris <christian.cuvier at agriculture.gouv.fr> Feb 01, 2007
- 508 views
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 ?? > > > include file.e > --include file_ln.e ------------- USE ONE or THE OTHER > ------------- > NOT Both !!!!!!! > include get.e > constant TRUE=1 > object exit_code > integer tabs tabs=0 > atom k,w k=0 > sequence name > > function look_at(sequence path_name,sequence entry) > if k=0 then > 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 > end if > return 0 > end function > > name = prompt_string("Directory ") > printf(1,"%s\n" ,{name}) > > exit_code = walk_dir("c:\\'name'", routine_id("look_at"), TRUE) > > k=0 > > w=wait_key() > > > If it is too difficult ......... O.K. > I'll plod on > > But thanks for reading my message > > les.r. If I correctly understand what you are doing, you want to add the contents of the sequence name to something (which designates a drive), and then pass the resulting sequence to walk_dir()? If so, just change
exit_code = walk_dir("c:\\'name'", routine_id("look_at"), TRUE)
to
exit_code = walk_dir("c:\\" & name, routine_id("look_at"), TRUE)
& adds together two sequences together to make a longer one. Yhis is called the concatenation of the two sequences (a string is just a sequence all elements of which are integers small enough to map to printable characters. HTH CChris